From 09a5e16c4fd2c120e12a154f8f7cdcd52fac8aaa Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Fri, 17 Sep 2021 05:21:00 -0500 Subject: [PATCH] test: use cross-spawn in the tests --- package.json | 5 +++-- pnpm-lock.yaml | 16 ++++++++++------ src/utils/tests/test-helpers.ts | 7 ++----- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 032f90c1..98c724b1 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bb1d5f8c..5d24abcf 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,13 +11,14 @@ importers: '@actions/exec': ^1.1.0 '@actions/io': ^1.1.1 '@actions/tool-cache': ^1.7.1 + '@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 - escape-path-with-spaces: ^1.0.0 + cross-spawn: ^7.0.3 eslint-config-atomic: ^1.16.2 hasha: ^5.2.2 jest: ^27.2.0 @@ -39,13 +40,14 @@ importers: semver: 7.3.5 which: 2.0.2 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 - escape-path-with-spaces: 1.0.0 + cross-spawn: 7.0.3 eslint-config-atomic: 1.16.2 jest: 27.2.0 npm-run-all2: 5.0.2 @@ -1480,6 +1482,12 @@ packages: '@babel/types': 7.15.6 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: resolution: {integrity: sha512-anKkLmZZ+xm4p8JWBf4hElkM4XR+EZeA2M9BAkkTldmcyDY4mbdIJnRghDJH3Ov5ooY7/UAoENtmdMSkaAd7Cw==} dependencies: @@ -3375,10 +3383,6 @@ 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'} diff --git a/src/utils/tests/test-helpers.ts b/src/utils/tests/test-helpers.ts index f0ff9c65..d5499b99 100644 --- a/src/utils/tests/test-helpers.ts +++ b/src/utils/tests/test-helpers.ts @@ -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) @@ -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) }