test: escape path in the exec in the test

This commit is contained in:
Amin Yahyaabadi 2021-09-17 04:49:13 -05:00
parent bf456808b6
commit a8477cb234
3 changed files with 12 additions and 2 deletions

View File

@ -61,7 +61,8 @@
"shx": "0.3.3",
"terser-config-atomic": "^0.1.1",
"ts-jest": "^27.0.5",
"typescript": "^4.4.3"
"typescript": "^4.4.3",
"escape-path-with-spaces": "^1.0.0"
},
"keywords": [
"github-actions",

View File

@ -17,6 +17,7 @@ importers:
'@types/which': ^2.0.1
caxa: ^2.1.0
cross-env: 7.0.3
escape-path-with-spaces: ^1.0.0
eslint-config-atomic: ^1.16.2
hasha: ^5.2.2
jest: ^27.2.0
@ -44,6 +45,7 @@ importers:
'@types/which': 2.0.1
caxa: 2.1.0
cross-env: 7.0.3
escape-path-with-spaces: 1.0.0
eslint-config-atomic: 1.16.2
jest: 27.2.0
npm-run-all2: 5.0.2
@ -3373,6 +3375,10 @@ packages:
resolution: {integrity: sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=}
dev: true
/escape-path-with-spaces/1.0.0:
resolution: {integrity: sha512-+98Hh0yzVa0hldJXlzr0M/8B8LVXW9vNT5boC9k6o896Z52DGRplm3NwMGX0590ryGSegzTf/uaUiusFj2SQbQ==}
dev: true
/escape-string-regexp/1.0.5:
resolution: {integrity: sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=}
engines: {node: '>=0.8.0'}

View File

@ -4,6 +4,9 @@ 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"
export async function setupTmpDir(testName: string) {
const tempDirectory = path.join(tmpdir(), "setup-cpp", testName)
@ -41,7 +44,7 @@ export async function testBin(name: string, args: string[] = ["--version"], binD
bin = join(binDir, addBinExtension(name))
}
const status = await exec(bin, args)
const status = await exec(escape(bin) as string, args)
expect(status).toBe(0)
expect(await io.which(name, true)).toBe(bin)