mirror of https://github.com/aminya/setup-cpp
fix: spawn the bin in the tests
This commit is contained in:
parent
9bf59efb6c
commit
4824306aab
|
@ -1,6 +1,8 @@
|
||||||
import { setupCmake } from "../cmake"
|
import { setupCmake } from "../cmake"
|
||||||
import { spawnSync as spawn } from "child_process"
|
import { spawnSync as spawn } from "child_process"
|
||||||
import { setupTmpDir, cleanupTmpDir } from "../../utils/tests/test-helpers"
|
import { setupTmpDir, cleanupTmpDir } from "../../utils/tests/test-helpers"
|
||||||
|
import { addBinExtension } from "../../utils/setup/setupBin"
|
||||||
|
import { join } from "path"
|
||||||
|
|
||||||
jest.setTimeout(100000)
|
jest.setTimeout(100000)
|
||||||
|
|
||||||
|
@ -19,7 +21,9 @@ describe("setup-cmake", () => {
|
||||||
expect(cmakePath).toBeDefined()
|
expect(cmakePath).toBeDefined()
|
||||||
expect(cmakePath).not.toHaveLength(0)
|
expect(cmakePath).not.toHaveLength(0)
|
||||||
|
|
||||||
const { status, error } = spawn(cmakePath, ["--version"], {
|
const cmakeBin = join(cmakePath, addBinExtension("cmake"))
|
||||||
|
|
||||||
|
const { status, error } = spawn(cmakeBin, ["--version"], {
|
||||||
encoding: "utf8",
|
encoding: "utf8",
|
||||||
})
|
})
|
||||||
expect(error).toBeUndefined()
|
expect(error).toBeUndefined()
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import { setupNinja } from "../ninja"
|
import { setupNinja } from "../ninja"
|
||||||
import { spawnSync as spawn } from "child_process"
|
import { spawnSync as spawn } from "child_process"
|
||||||
import { setupTmpDir, cleanupTmpDir } from "../../utils/tests/test-helpers"
|
import { setupTmpDir, cleanupTmpDir } from "../../utils/tests/test-helpers"
|
||||||
|
import { addBinExtension } from "../../utils/setup/setupBin"
|
||||||
|
import { join } from "path"
|
||||||
|
|
||||||
jest.setTimeout(100000)
|
jest.setTimeout(100000)
|
||||||
|
|
||||||
|
@ -19,7 +21,9 @@ describe("setup-ninja", () => {
|
||||||
expect(ninjaPath).toBeDefined()
|
expect(ninjaPath).toBeDefined()
|
||||||
expect(ninjaPath).not.toHaveLength(0)
|
expect(ninjaPath).not.toHaveLength(0)
|
||||||
|
|
||||||
const { status } = spawn(ninjaPath, ["--version"], {
|
const ninjaBin = join(ninjaPath, addBinExtension("ninja"))
|
||||||
|
|
||||||
|
const { status } = spawn(ninjaBin, ["--version"], {
|
||||||
encoding: "utf8",
|
encoding: "utf8",
|
||||||
})
|
})
|
||||||
expect(status).toBe(0)
|
expect(status).toBe(0)
|
||||||
|
|
|
@ -75,3 +75,10 @@ export async function setupPackage(
|
||||||
|
|
||||||
return installDir
|
return installDir
|
||||||
}
|
}
|
||||||
|
/** Add bin extension to a binary. This will be `.exe` on Windows. */
|
||||||
|
export function addBinExtension(name: string) {
|
||||||
|
if (process.platform === "win32") {
|
||||||
|
return `${name}.exe`
|
||||||
|
}
|
||||||
|
return name
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue