test: use cross-spawn in the tests

This commit is contained in:
Amin Yahyaabadi 2021-09-17 05:21:00 -05:00
parent 00f3a11471
commit 09a5e16c4f
3 changed files with 15 additions and 13 deletions

View File

@ -47,12 +47,14 @@
} }
}, },
"devDependencies": { "devDependencies": {
"@types/cross-spawn": "^6.0.2",
"@types/jest": "^27.0.1", "@types/jest": "^27.0.1",
"@types/node": "^16.9.1", "@types/node": "^16.9.1",
"@types/semver": "^7.3.8", "@types/semver": "^7.3.8",
"@types/which": "^2.0.1", "@types/which": "^2.0.1",
"caxa": "^2.1.0", "caxa": "^2.1.0",
"cross-env": "7.0.3", "cross-env": "7.0.3",
"cross-spawn": "^7.0.3",
"eslint-config-atomic": "^1.16.2", "eslint-config-atomic": "^1.16.2",
"jest": "^27.2.0", "jest": "^27.2.0",
"npm-run-all2": "^5.0.2", "npm-run-all2": "^5.0.2",
@ -61,8 +63,7 @@
"shx": "0.3.3", "shx": "0.3.3",
"terser-config-atomic": "^0.1.1", "terser-config-atomic": "^0.1.1",
"ts-jest": "^27.0.5", "ts-jest": "^27.0.5",
"typescript": "^4.4.3", "typescript": "^4.4.3"
"escape-path-with-spaces": "^1.0.0"
}, },
"keywords": [ "keywords": [
"github-actions", "github-actions",

View File

@ -11,13 +11,14 @@ importers:
'@actions/exec': ^1.1.0 '@actions/exec': ^1.1.0
'@actions/io': ^1.1.1 '@actions/io': ^1.1.1
'@actions/tool-cache': ^1.7.1 '@actions/tool-cache': ^1.7.1
'@types/cross-spawn': ^6.0.2
'@types/jest': ^27.0.1 '@types/jest': ^27.0.1
'@types/node': ^16.9.1 '@types/node': ^16.9.1
'@types/semver': ^7.3.8 '@types/semver': ^7.3.8
'@types/which': ^2.0.1 '@types/which': ^2.0.1
caxa: ^2.1.0 caxa: ^2.1.0
cross-env: 7.0.3 cross-env: 7.0.3
escape-path-with-spaces: ^1.0.0 cross-spawn: ^7.0.3
eslint-config-atomic: ^1.16.2 eslint-config-atomic: ^1.16.2
hasha: ^5.2.2 hasha: ^5.2.2
jest: ^27.2.0 jest: ^27.2.0
@ -39,13 +40,14 @@ importers:
semver: 7.3.5 semver: 7.3.5
which: 2.0.2 which: 2.0.2
devDependencies: devDependencies:
'@types/cross-spawn': 6.0.2
'@types/jest': 27.0.1 '@types/jest': 27.0.1
'@types/node': 16.9.1 '@types/node': 16.9.1
'@types/semver': 7.3.8 '@types/semver': 7.3.8
'@types/which': 2.0.1 '@types/which': 2.0.1
caxa: 2.1.0 caxa: 2.1.0
cross-env: 7.0.3 cross-env: 7.0.3
escape-path-with-spaces: 1.0.0 cross-spawn: 7.0.3
eslint-config-atomic: 1.16.2 eslint-config-atomic: 1.16.2
jest: 27.2.0 jest: 27.2.0
npm-run-all2: 5.0.2 npm-run-all2: 5.0.2
@ -1480,6 +1482,12 @@ packages:
'@babel/types': 7.15.6 '@babel/types': 7.15.6
dev: true dev: true
/@types/cross-spawn/6.0.2:
resolution: {integrity: sha512-KuwNhp3eza+Rhu8IFI5HUXRP0LIhqH5cAjubUvGXXthh4YYBuP2ntwEX+Cz8GJoZUHlKo247wPWOfA9LYEq4cw==}
dependencies:
'@types/node': 16.9.1
dev: true
/@types/graceful-fs/4.1.5: /@types/graceful-fs/4.1.5:
resolution: {integrity: sha512-anKkLmZZ+xm4p8JWBf4hElkM4XR+EZeA2M9BAkkTldmcyDY4mbdIJnRghDJH3Ov5ooY7/UAoENtmdMSkaAd7Cw==} resolution: {integrity: sha512-anKkLmZZ+xm4p8JWBf4hElkM4XR+EZeA2M9BAkkTldmcyDY4mbdIJnRghDJH3Ov5ooY7/UAoENtmdMSkaAd7Cw==}
dependencies: dependencies:
@ -3375,10 +3383,6 @@ packages:
resolution: {integrity: sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=} resolution: {integrity: sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=}
dev: true dev: true
/escape-path-with-spaces/1.0.0:
resolution: {integrity: sha512-+98Hh0yzVa0hldJXlzr0M/8B8LVXW9vNT5boC9k6o896Z52DGRplm3NwMGX0590ryGSegzTf/uaUiusFj2SQbQ==}
dev: true
/escape-string-regexp/1.0.5: /escape-string-regexp/1.0.5:
resolution: {integrity: sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=} resolution: {integrity: sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=}
engines: {node: '>=0.8.0'} engines: {node: '>=0.8.0'}

View File

@ -3,10 +3,7 @@ import { tmpdir } from "os"
import * as path from "path" import * as path from "path"
import { addBinExtension } from "../setup/setupBin" import { addBinExtension } from "../setup/setupBin"
import { join } from "path" import { join } from "path"
import { exec } from "@actions/exec" import spawn from "cross-spawn"
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import escape from "escape-path-with-spaces"
export async function setupTmpDir(testName: string) { export async function setupTmpDir(testName: string) {
const tempDirectory = path.join(tmpdir(), "setup-cpp", testName) const tempDirectory = path.join(tmpdir(), "setup-cpp", testName)
@ -49,7 +46,7 @@ export async function testBin(
} }
if (args !== null) { if (args !== null) {
const status = await exec(escape(bin) as string, args) const { status } = spawn.sync(bin, args, { stdio: "inherit" })
expect(status).toBe(0) expect(status).toBe(0)
} }