mirror of https://github.com/aminya/setup-cpp
feat: add which test to testBin
This commit is contained in:
parent
dc5ab1bf50
commit
dde8036194
|
@ -4,7 +4,7 @@ import { setupTmpDir, cleanupTmpDir, testBin } from "../../utils/tests/test-help
|
||||||
jest.setTimeout(200000)
|
jest.setTimeout(200000)
|
||||||
async function testCmake(directory: string) {
|
async function testCmake(directory: string) {
|
||||||
const { binDir } = await setupCmake("3.20.2", directory, "")
|
const { binDir } = await setupCmake("3.20.2", directory, "")
|
||||||
testBin("cmake", binDir)
|
await testBin("cmake", ["--version"], binDir)
|
||||||
return binDir
|
return binDir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { setupTmpDir, cleanupTmpDir, testBin } from "../../utils/tests/test-help
|
||||||
jest.setTimeout(200000)
|
jest.setTimeout(200000)
|
||||||
async function testNinja(directory: string) {
|
async function testNinja(directory: string) {
|
||||||
const { binDir } = await setupNinja("1.10.2", directory, "")
|
const { binDir } = await setupNinja("1.10.2", directory, "")
|
||||||
testBin("ninja", binDir)
|
await testBin("ninja", ["--version"], binDir)
|
||||||
return binDir
|
return binDir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,16 +33,20 @@ export async function cleanupTmpDir(testName: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function testBin(binName: string, binDir: string) {
|
export async function testBin(name: string, args: string[] = ["--version"], binDir: string | undefined = undefined) {
|
||||||
expect(binDir).toBeDefined()
|
let bin = name
|
||||||
expect(binDir).not.toHaveLength(0)
|
if (binDir !== undefined) {
|
||||||
|
expect(binDir).toBeDefined()
|
||||||
|
expect(binDir).not.toHaveLength(0)
|
||||||
|
bin = join(binDir, addBinExtension(name))
|
||||||
|
}
|
||||||
|
|
||||||
const cmakeBin = join(binDir, addBinExtension(binName))
|
const { status } = spawn(bin, args, {
|
||||||
|
|
||||||
const { status } = spawn(cmakeBin, ["--version"], {
|
|
||||||
encoding: "utf8",
|
encoding: "utf8",
|
||||||
})
|
})
|
||||||
expect(status).toBe(0)
|
expect(status).toBe(0)
|
||||||
|
|
||||||
|
expect(await io.which(name, true)).toBe(bin)
|
||||||
|
|
||||||
return binDir
|
return binDir
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue