test: enable CircleCI's "re-run failed tests only" feature (#38178)
* test: enable CircleCI rerun failed *tests* only
* .
* .
* console.log never fails 🤷
* normalize the filtered paths
circleci gives us a list of absolute paths here
* remove test output check
sometimes rerunning only failed tests results in some runners having
no tests to run, and thus no output
* keep relative paths the same
* error for when no tests match
* cleanup
* .
This commit is contained in:
parent
3a7cfe300a
commit
13be6dc8b4
2 changed files with 15 additions and 14 deletions
|
@ -452,7 +452,7 @@ step-get-more-space-on-mac: &step-get-more-space-on-mac
|
|||
fi
|
||||
background: true
|
||||
|
||||
# On macOS delete all .git directories under src/ expect for
|
||||
# On macOS delete all .git directories under src/ except for
|
||||
# third_party/angle/ and third_party/dawn/ because of build time generation of files
|
||||
# gen/angle/commit.h depends on third_party/angle/.git/HEAD
|
||||
# https://chromium-review.googlesource.com/c/angle/angle/+/2074924
|
||||
|
@ -1492,7 +1492,7 @@ commands:
|
|||
export LLVM_SYMBOLIZER_PATH=$PWD/third_party/llvm-build/Release+Asserts/bin/llvm-symbolizer
|
||||
export MOCHA_TIMEOUT=180000
|
||||
echo "Piping output to ASAN_SYMBOLIZE ($ASAN_SYMBOLIZE)"
|
||||
(cd electron && node script/yarn test --runners=main --trace-uncaught --enable-logging --files $(circleci tests glob spec/*-spec.ts | circleci tests split --split-by=timings)) 2>&1 | $ASAN_SYMBOLIZE
|
||||
(cd electron && (circleci tests glob "spec/*-spec.ts" | circleci tests run --command="xargs node script/yarn test --runners=main --trace-uncaught --enable-logging --files" --split-by=timings 2>&1)) | $ASAN_SYMBOLIZE
|
||||
else
|
||||
if [ "$TARGET_ARCH" == "arm" ] || [ "$TARGET_ARCH" == "arm64" ]; then
|
||||
export ELECTRON_SKIP_NATIVE_MODULE_TESTS=true
|
||||
|
@ -1501,18 +1501,9 @@ commands:
|
|||
if [ "$TARGET_ARCH" == "ia32" ]; then
|
||||
npm_config_arch=x64 node electron/node_modules/dugite/script/download-git.js
|
||||
fi
|
||||
(cd electron && node script/yarn test --runners=main --trace-uncaught --enable-logging --files $(circleci tests glob spec/*-spec.ts | circleci tests split --split-by=timings))
|
||||
(cd electron && (circleci tests glob "spec/*-spec.ts" | circleci tests run --command="xargs node script/yarn test --runners=main --trace-uncaught --enable-logging --files" --split-by=timings))
|
||||
fi
|
||||
fi
|
||||
- run:
|
||||
name: Check test results existence
|
||||
command: |
|
||||
cd src
|
||||
|
||||
# Check if test results exist and are not empty.
|
||||
if [ ! -s "junit/test-results-main.xml" ]; then
|
||||
exit 1
|
||||
fi
|
||||
- store_test_results:
|
||||
path: src/junit
|
||||
|
||||
|
|
|
@ -107,6 +107,11 @@ app.whenReady().then(async () => {
|
|||
if (argv.grep) mocha.grep(argv.grep);
|
||||
if (argv.invert) mocha.invert();
|
||||
|
||||
const baseElectronDir = path.resolve(__dirname, '..');
|
||||
const validTestPaths = argv.files && argv.files.map(file =>
|
||||
path.isAbsolute(file)
|
||||
? path.relative(baseElectronDir, file)
|
||||
: file);
|
||||
const filter = (file) => {
|
||||
if (!/-spec\.[tj]s$/.test(file)) {
|
||||
return false;
|
||||
|
@ -121,8 +126,7 @@ app.whenReady().then(async () => {
|
|||
return false;
|
||||
}
|
||||
|
||||
const baseElectronDir = path.resolve(__dirname, '..');
|
||||
if (argv.files && !argv.files.includes(path.relative(baseElectronDir, file))) {
|
||||
if (validTestPaths && !validTestPaths.includes(path.relative(baseElectronDir, file))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -135,6 +139,12 @@ app.whenReady().then(async () => {
|
|||
mocha.addFile(file);
|
||||
});
|
||||
|
||||
if (validTestPaths && validTestPaths.length > 0 && testFiles.length === 0) {
|
||||
console.error('Test files were provided, but they did not match any searched files');
|
||||
console.error('provided file paths (relative to electron/):', validTestPaths);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const cb = () => {
|
||||
// Ensure the callback is called after runner is defined
|
||||
process.nextTick(() => {
|
||||
|
|
Loading…
Reference in a new issue