Skip to content

Commit

Permalink
Implement CLI flag, --errorForFailures
Browse files Browse the repository at this point in the history
  • Loading branch information
jugglinmike authored and rwaldron committed May 25, 2021
1 parent ae3a3f0 commit 7716f30
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ test262-harness --hostType=X --hostPath=`which X` test/**/*.js
| `--acceptVersion` | Execute tests from a version of Test262 that differs from the versions supported by this utility. This may cause the utility to report invalid test results. | No | Inferred from `test262Dir/package.json` |
| `--saveCompiledTests` | Write the compiled version of `path/to/test.js` as `path/to/test.js.<hostType>.<default\|strict>.<pass\|fail>` so that it can be easily re-run under that host. Run `test262-harness --help` for examples. | No | n/a
| `--saveOnlyFailed` | Only save the compiled version of the test if it failed, to help easily repro failed tests (implies `--saveCompiledTests`). | No | n/a
| `--errorForFailures` | Return a non-zero exit code if one or more tests fail. | No | n/a


### Preprocessor
Expand Down
7 changes: 7 additions & 0 deletions bin/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,13 @@ const results = zip(pool, tests).pipe(
);

const emitter = new ResultsEmitter(results);

if (argv.errorForFailures) {
emitter.on('fail', function () {
process.exitCode = 1;
});
}

reporter(emitter, reporterOpts);

function printVersion() {
Expand Down
1 change: 1 addition & 0 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const yargv = yargs
.describe('saveCompiledTests', 'Write the compiled version of path/to/test.js as path/to/test.js.<hostType>.<default|strict>.<pass|fail> so that it can be easily re-run under that host')
.boolean('saveOnlyFailed')
.describe('saveOnlyFailed', 'Only save the compiled version of the test if it failed, to help easily repro failed tests (implies --saveCompiledTests)')
.describe('errorForFailures', 'Return a non-zero exit code if one or more tests fail')
.example('test262-harness path/to/test.js')
.example('test262-harness --hostType ch --hostPath path/to/host path/to/test262/test/folder/**/*.js')
.example('test262-harness --hostType ch --hostPath path/to/host --saveCompiledTests path/to/test262/test/folder/**/*.js')
Expand Down
16 changes: 16 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ const tests = [
],
{ cwd: 'test/collateral-with-harness/test262' },
],
[
[
'test/**/*.js', '--error-for-failures',
],
{ cwd: 'test/collateral-with-harness/test262' },
],
[
[
'--test262Dir', './test/collateral-with-harness/test262',
Expand Down Expand Up @@ -117,6 +123,16 @@ const tests = [
'./test/collateral-preprocessor/test/autofail.js',
],
],
[
[
'--includesDir', './test/test-includes',
'--preprocessor', './test/preprocessor/autofail.js',
'--reporter-keys', 'attrs,result,rawResult',
'./test/collateral-preprocessor/test/autofail.js',
'--errorForFailures',
],
{ exitCode: 1 },
],
].reduce((accum, a) => {
let b = a.slice();

Expand Down

0 comments on commit 7716f30

Please sign in to comment.