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)
|
||||
async function testCmake(directory: string) {
|
||||
const { binDir } = await setupCmake("3.20.2", directory, "")
|
||||
testBin("cmake", binDir)
|
||||
await testBin("cmake", ["--version"], binDir)
|
||||
return binDir
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import { setupTmpDir, cleanupTmpDir, testBin } from "../../utils/tests/test-help
|
|||
jest.setTimeout(200000)
|
||||
async function testNinja(directory: string) {
|
||||
const { binDir } = await setupNinja("1.10.2", directory, "")
|
||||
testBin("ninja", binDir)
|
||||
await testBin("ninja", ["--version"], binDir)
|
||||
return binDir
|
||||
}
|
||||
|
||||
|
|
|
@ -33,16 +33,20 @@ export async function cleanupTmpDir(testName: string) {
|
|||
}
|
||||
}
|
||||
|
||||
export function testBin(binName: string, binDir: string) {
|
||||
expect(binDir).toBeDefined()
|
||||
expect(binDir).not.toHaveLength(0)
|
||||
export async function testBin(name: string, args: string[] = ["--version"], binDir: string | undefined = undefined) {
|
||||
let bin = name
|
||||
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(cmakeBin, ["--version"], {
|
||||
const { status } = spawn(bin, args, {
|
||||
encoding: "utf8",
|
||||
})
|
||||
expect(status).toBe(0)
|
||||
|
||||
expect(await io.which(name, true)).toBe(bin)
|
||||
|
||||
return binDir
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue