diff --git a/README.md b/README.md index 2e137a3..c1135f1 100644 --- a/README.md +++ b/README.md @@ -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...` 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 diff --git a/bin/run.js b/bin/run.js index f3782d1..d83806a 100755 --- a/bin/run.js +++ b/bin/run.js @@ -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() { diff --git a/lib/cli.js b/lib/cli.js index 4a74309..a232682 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -37,6 +37,7 @@ const yargv = yargs .describe('saveCompiledTests', 'Write the compiled version of path/to/test.js as path/to/test.js... 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') diff --git a/test/test.js b/test/test.js index 55533c5..1bfe6e3 100644 --- a/test/test.js +++ b/test/test.js @@ -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', @@ -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();