Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
jpinkney-aws committed Dec 20, 2024
1 parent 924b90e commit 5d3ade7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion buildspec/linuxE2ETests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
2 changes: 1 addition & 1 deletion buildspec/linuxIntegrationTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
2 changes: 1 addition & 1 deletion buildspec/linuxTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down
23 changes: 13 additions & 10 deletions scripts/mergeReports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 5d3ade7

Please sign in to comment.