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:
Calvin 2023-05-08 02:14:59 -06:00 committed by GitHub
parent 3a7cfe300a
commit 13be6dc8b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 14 deletions

View file

@ -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(() => {