Skip to content

Commit

Permalink
test: use cross-spawn in the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Sep 17, 2021
1 parent 00f3a11 commit 09a5e16
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@
}
},
"devDependencies": {
"@types/cross-spawn": "^6.0.2",
"@types/jest": "^27.0.1",
"@types/node": "^16.9.1",
"@types/semver": "^7.3.8",
"@types/which": "^2.0.1",
"caxa": "^2.1.0",
"cross-env": "7.0.3",
"cross-spawn": "^7.0.3",
"eslint-config-atomic": "^1.16.2",
"jest": "^27.2.0",
"npm-run-all2": "^5.0.2",
Expand All @@ -61,8 +63,7 @@
"shx": "0.3.3",
"terser-config-atomic": "^0.1.1",
"ts-jest": "^27.0.5",
"typescript": "^4.4.3",
"escape-path-with-spaces": "^1.0.0"
"typescript": "^4.4.3"
},
"keywords": [
"github-actions",
Expand Down
16 changes: 10 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions src/utils/tests/test-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ import { tmpdir } from "os"
import * as path from "path"
import { addBinExtension } from "../setup/setupBin"
import { join } from "path"
import { exec } from "@actions/exec"
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import escape from "escape-path-with-spaces"
import spawn from "cross-spawn"

export async function setupTmpDir(testName: string) {
const tempDirectory = path.join(tmpdir(), "setup-cpp", testName)
Expand Down Expand Up @@ -49,7 +46,7 @@ export async function testBin(
}

if (args !== null) {
const status = await exec(escape(bin) as string, args)
const { status } = spawn.sync(bin, args, { stdio: "inherit" })
expect(status).toBe(0)
}

Expand Down

0 comments on commit 09a5e16

Please sign in to comment.