diff --git a/src/cmake/__tests__/cmake.test.ts b/src/cmake/__tests__/cmake.test.ts index ed34e78e..97ec26f5 100644 --- a/src/cmake/__tests__/cmake.test.ts +++ b/src/cmake/__tests__/cmake.test.ts @@ -1,6 +1,8 @@ import { setupCmake } from "../cmake" import { spawnSync as spawn } from "child_process" import { setupTmpDir, cleanupTmpDir } from "../../utils/tests/test-helpers" +import { addBinExtension } from "../../utils/setup/setupBin" +import { join } from "path" jest.setTimeout(100000) @@ -19,7 +21,9 @@ describe("setup-cmake", () => { expect(cmakePath).toBeDefined() 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", }) expect(error).toBeUndefined() diff --git a/src/ninja/__tests__/ninja.test.ts b/src/ninja/__tests__/ninja.test.ts index af8fa5ad..69249cf4 100644 --- a/src/ninja/__tests__/ninja.test.ts +++ b/src/ninja/__tests__/ninja.test.ts @@ -1,6 +1,8 @@ import { setupNinja } from "../ninja" import { spawnSync as spawn } from "child_process" import { setupTmpDir, cleanupTmpDir } from "../../utils/tests/test-helpers" +import { addBinExtension } from "../../utils/setup/setupBin" +import { join } from "path" jest.setTimeout(100000) @@ -19,7 +21,9 @@ describe("setup-ninja", () => { expect(ninjaPath).toBeDefined() expect(ninjaPath).not.toHaveLength(0) - const { status } = spawn(ninjaPath, ["--version"], { + const ninjaBin = join(ninjaPath, addBinExtension("ninja")) + + const { status } = spawn(ninjaBin, ["--version"], { encoding: "utf8", }) expect(status).toBe(0) diff --git a/src/utils/setup/setupBin.ts b/src/utils/setup/setupBin.ts index 0b2d05a0..a63e48e1 100644 --- a/src/utils/setup/setupBin.ts +++ b/src/utils/setup/setupBin.ts @@ -75,3 +75,10 @@ export async function setupPackage( 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 +}