From 328c5c227d2e7df92a9e61cace75301ec43bcbdc Mon Sep 17 00:00:00 2001 From: Timothy Johnson Date: Mon, 21 Oct 2024 08:01:18 -0400 Subject: [PATCH 1/5] Fix jest-stare output in wrong folder Signed-off-by: Timothy Johnson --- jest.config.js | 4 ---- package.json | 8 ++++++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/jest.config.js b/jest.config.js index c3077263a8..ebc84a9074 100644 --- a/jest.config.js +++ b/jest.config.js @@ -137,10 +137,6 @@ module.exports = { "outputDirectory": "__tests__/__results__", "reportTestSuiteErrors": true }], - ["jest-stare", { - "coverageLink": "../unit/coverage/lcov-report/index.html", - "resultDir": "__tests__/__results__/jest-stare" - }], ["github-actions", { "silent": false } ] ], "testResultsProcessor": "jest-sonar-reporter", diff --git a/package.json b/package.json index 1339c31a74..dc705bb400 100644 --- a/package.json +++ b/package.json @@ -82,5 +82,13 @@ }, "jestSonar": { "reportPath": "__tests__/__results__/jest-sonar" + }, + "jest-stare": { + "additionalResultsProcessors": [ + "jest-junit", + "jest-sonar-reporter" + ], + "coverageLink": "../unit/coverage/lcov-report/index.html", + "resultDir": "__tests__/__results__/jest-stare" } } From 4dfd564cd426ae3e6c35b212eaf7b6cb286beee4 Mon Sep 17 00:00:00 2001 From: Timothy Johnson Date: Fri, 1 Nov 2024 12:52:39 -0400 Subject: [PATCH 2/5] Add jest-stare back to reporters list Signed-off-by: Timothy Johnson --- jest.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/jest.config.js b/jest.config.js index ebc84a9074..0e05bcca5d 100644 --- a/jest.config.js +++ b/jest.config.js @@ -133,6 +133,7 @@ module.exports = { ...projectConfig, "reporters": [ "default", + "jest-stare", ["jest-junit", { "outputDirectory": "__tests__/__results__", "reportTestSuiteErrors": true From 725650479d39c0620f4ae9f400359f8707564c07 Mon Sep 17 00:00:00 2001 From: Timothy Johnson Date: Fri, 1 Nov 2024 15:15:53 -0400 Subject: [PATCH 3/5] Add waits to fix transient error in GetJobs test Signed-off-by: Timothy Johnson --- packages/zosjobs/__tests__/__system__/GetJobs.system.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/zosjobs/__tests__/__system__/GetJobs.system.test.ts b/packages/zosjobs/__tests__/__system__/GetJobs.system.test.ts index 5ca70448c9..3e966c7f3e 100644 --- a/packages/zosjobs/__tests__/__system__/GetJobs.system.test.ts +++ b/packages/zosjobs/__tests__/__system__/GetJobs.system.test.ts @@ -719,8 +719,7 @@ describe("Get Jobs - System Tests", () => { it("should be able to get a job that was submitted and get proper error when the job is deleted", async () => { const job = await SubmitJobs.submitJcl(REAL_SESSION, JCL); - const jobStatus = await GetJobs.getStatusForJob(REAL_SESSION, job); - + await wait(3000); await DeleteJobs.deleteJobForJob(REAL_SESSION, job); await wait(3000); // make sure jobs is deleted let error; @@ -978,6 +977,7 @@ describe("Get Jobs - System Tests", () => { describe("invalid request error handling", () => { it("should detect and surface an error for getting JCL that doesnt exist", async () => { const job = await SubmitJobs.submitJcl(REAL_SESSION, JCL); + await wait(3000); await DeleteJobs.deleteJobForJob(REAL_SESSION, job); await wait(3000); let error; From e3600e710cb9c543a0c69b183c3429e90b5d6f65 Mon Sep 17 00:00:00 2001 From: Timothy Johnson Date: Mon, 4 Nov 2024 16:19:09 -0500 Subject: [PATCH 4/5] Don't require shebangs on MacOS Signed-off-by: Timothy Johnson --- __tests__/__packages__/cli-test-utils/CHANGELOG.md | 4 ++++ __tests__/__packages__/cli-test-utils/src/TestUtils.ts | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/__tests__/__packages__/cli-test-utils/CHANGELOG.md b/__tests__/__packages__/cli-test-utils/CHANGELOG.md index bc707aabee..02229e889c 100644 --- a/__tests__/__packages__/cli-test-utils/CHANGELOG.md +++ b/__tests__/__packages__/cli-test-utils/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to the Zowe CLI test utils package will be documented in this file. +## Recent Changes + +- BugFix: Fixed an issue on MacOS where `runCliScript` method failed to run script that is missing shebang line. [#2314](https://github.com/zowe/zowe-cli/pull/2314) + ## `8.1.1` - BugFix: Updated peer dependencies to `^8.0.0`, dropping support for versions tagged `next`. [#2287](https://github.com/zowe/zowe-cli/pull/2287) diff --git a/__tests__/__packages__/cli-test-utils/src/TestUtils.ts b/__tests__/__packages__/cli-test-utils/src/TestUtils.ts index 1c47f617c8..9066f525f9 100644 --- a/__tests__/__packages__/cli-test-utils/src/TestUtils.ts +++ b/__tests__/__packages__/cli-test-utils/src/TestUtils.ts @@ -58,7 +58,8 @@ export function runCliScript(scriptPath: string, testEnvironment: ITestEnvironme return spawnSync(scriptPath, args, { cwd: testEnvironment.workingDir, env: childEnv, - encoding: "buffer" + encoding: "buffer", + shell: true // Don't require shebangs on MacOS }); } else { From 2743305cc97d6ebb37aa0269ca153c45b9a4c2a3 Mon Sep 17 00:00:00 2001 From: Timothy Johnson Date: Tue, 5 Nov 2024 09:19:14 -0500 Subject: [PATCH 5/5] Handle ENOEXEC error for shell scripts on MacOS Signed-off-by: Timothy Johnson --- __tests__/__packages__/cli-test-utils/CHANGELOG.md | 2 +- __tests__/__packages__/cli-test-utils/src/TestUtils.ts | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/__tests__/__packages__/cli-test-utils/CHANGELOG.md b/__tests__/__packages__/cli-test-utils/CHANGELOG.md index 02229e889c..2218f50dfa 100644 --- a/__tests__/__packages__/cli-test-utils/CHANGELOG.md +++ b/__tests__/__packages__/cli-test-utils/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to the Zowe CLI test utils package will be documented in thi ## Recent Changes -- BugFix: Fixed an issue on MacOS where `runCliScript` method failed to run script that is missing shebang line. [#2314](https://github.com/zowe/zowe-cli/pull/2314) +- BugFix: Improved the error message shown on MacOS when `runCliScript` method fails to run script that is missing shebang line. [#2314](https://github.com/zowe/zowe-cli/pull/2314) ## `8.1.1` diff --git a/__tests__/__packages__/cli-test-utils/src/TestUtils.ts b/__tests__/__packages__/cli-test-utils/src/TestUtils.ts index 9066f525f9..90cb8be95a 100644 --- a/__tests__/__packages__/cli-test-utils/src/TestUtils.ts +++ b/__tests__/__packages__/cli-test-utils/src/TestUtils.ts @@ -10,6 +10,7 @@ */ import * as fs from "fs"; +import * as path from "path"; import { spawnSync, SpawnSyncReturns, ExecFileException } from "child_process"; import { ITestEnvironment } from "./environment/doc/response/ITestEnvironment"; import { ICommandDefinition, IHandlerParameters } from "@zowe/imperative"; @@ -55,13 +56,16 @@ export function runCliScript(scriptPath: string, testEnvironment: ITestEnvironme } catch { fs.chmodSync(scriptPath, "755"); } - return spawnSync(scriptPath, args, { + const response = spawnSync(scriptPath, args, { cwd: testEnvironment.workingDir, env: childEnv, - encoding: "buffer", - shell: true // Don't require shebangs on MacOS + encoding: "buffer" }); + if (process.platform === "darwin" && (response.error as ExecFileException)?.errno === -8) { + throw new Error(`The script file ${path.basename(scriptPath)} failed to execute. Check that it starts with a shebang line.`); + } + return response; } else { throw new Error(`The script file ${scriptPath} doesn't exist`);