test: check for existence of binDir in the tests

This commit is contained in:
Amin Yahyaabadi 2022-01-30 17:31:30 -08:00
parent 970f52c9f9
commit 625ffbd77f
1 changed files with 3 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import * as path from "path"
import { addBinExtension } from "../extension/extension"
import { join } from "path"
import spawn from "cross-spawn"
import { existsSync } from "fs"
export async function setupTmpDir(testName: string) {
const tempDirectory = path.join(tmpdir(), "setup-cpp", testName)
@ -38,10 +39,12 @@ export async function testBin(
if (typeof binDir === "string") {
expect(binDir).toBeDefined()
expect(binDir).not.toHaveLength(0)
expect(existsSync(binDir)).toBeTruthy()
bin = join(binDir, addBinExtension(name))
}
if (args !== null) {
console.log(`Running ${bin} ${args.join(" ")}`)
const { status } = spawn.sync(bin, args, { stdio: "inherit" })
expect(status).toBe(0)
}