diff --git a/buildspec/linuxE2ETests.yml b/buildspec/linuxE2ETests.yml index 9ba5c1be9cc..def6dfd1cd0 100644 --- a/buildspec/linuxE2ETests.yml +++ b/buildspec/linuxE2ETests.yml @@ -37,7 +37,7 @@ phases: commands: - export HOME=/home/codebuild-user # Ignore failure until throttling issues are fixed. - - xvfb-run npm run testE2E; PREVIOUS_TEST_EXIT_CODE=$? npm run mergeReports + - xvfb-run npm run testE2E; npm run mergeReports -- "$?" - VCS_COMMIT_ID="${CODEBUILD_RESOLVED_SOURCE_VERSION}" - CI_BUILD_URL=$(echo $CODEBUILD_BUILD_URL | sed 's/#/%23/g') - CI_BUILD_ID="${CODEBUILD_BUILD_ID}" diff --git a/buildspec/linuxIntegrationTests.yml b/buildspec/linuxIntegrationTests.yml index da6a2531620..dacab125b89 100644 --- a/buildspec/linuxIntegrationTests.yml +++ b/buildspec/linuxIntegrationTests.yml @@ -92,7 +92,7 @@ phases: build: commands: - export HOME=/home/codebuild-user - - xvfb-run npm run testInteg; PREVIOUS_TEST_EXIT_CODE=$? npm run mergeReports + - xvfb-run npm run testInteg; npm run mergeReports -- "$?" - VCS_COMMIT_ID="${CODEBUILD_RESOLVED_SOURCE_VERSION}" - CI_BUILD_URL=$(echo $CODEBUILD_BUILD_URL | sed 's/#/%23/g') - CI_BUILD_ID="${CODEBUILD_BUILD_ID}" diff --git a/buildspec/linuxTests.yml b/buildspec/linuxTests.yml index 70fd31274ca..20f5b6a01f7 100644 --- a/buildspec/linuxTests.yml +++ b/buildspec/linuxTests.yml @@ -41,7 +41,7 @@ phases: # Ensure that "foo | run_and_report" fails correctly. set -o pipefail . buildspec/shared/common.sh - 2>&1 xvfb-run npm test --silent; PREVIOUS_TEST_EXIT_CODE=$? npm run mergeReports | run_and_report 2 \ + 2>&1 xvfb-run npm test --silent; npm run mergeReports -- "$?" | run_and_report 2 \ 'rejected promise not handled' \ 'This typically indicates a bug. Read https://developer.mozilla.org/docs/Web/JavaScript/Guide/Using_promises#error_handling' } diff --git a/scripts/mergeReports.ts b/scripts/mergeReports.ts index f2159290a1c..7059162048a 100644 --- a/scripts/mergeReports.ts +++ b/scripts/mergeReports.ts @@ -53,16 +53,19 @@ async function mergeReports() { fs.writeFileSync(path.join(reportsDir, 'report.xml'), xml) - /** - * Retrieves the exit code from the previous test run execution. - * - * This allows us to: - * 1. Merge and upload test reports regardless of the test execution status - * 2. Preserve the original test run exit code - * 3. Report the test status back to CI - */ - const exitCode = parseInt(process.env.PREVIOUS_TEST_EXIT_CODE || '0', 10) - process.exit(exitCode) + const exitCodeArg = process.argv[2] + if (exitCodeArg) { + /** + * Retrieves the exit code from the previous test run execution. + * + * This allows us to: + * 1. Merge and upload test reports regardless of the test execution status + * 2. Preserve the original test run exit code + * 3. Report the test status back to CI + */ + const exitCode = parseInt(exitCodeArg || '0', 10) + process.exit(exitCode) + } } mergeReports()