Skip to content

Commit 7716f30

Browse files
jugglinmikerwaldron
authored andcommitted
Implement CLI flag, --errorForFailures
1 parent ae3a3f0 commit 7716f30

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ test262-harness --hostType=X --hostPath=`which X` test/**/*.js
5757
| `--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` |
5858
| `--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
5959
| `--saveOnlyFailed` | Only save the compiled version of the test if it failed, to help easily repro failed tests (implies `--saveCompiledTests`). | No | n/a
60+
| `--errorForFailures` | Return a non-zero exit code if one or more tests fail. | No | n/a
6061

6162

6263
### Preprocessor

bin/run.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,13 @@ const results = zip(pool, tests).pipe(
178178
);
179179

180180
const emitter = new ResultsEmitter(results);
181+
182+
if (argv.errorForFailures) {
183+
emitter.on('fail', function () {
184+
process.exitCode = 1;
185+
});
186+
}
187+
181188
reporter(emitter, reporterOpts);
182189

183190
function printVersion() {

lib/cli.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const yargv = yargs
3737
.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')
3838
.boolean('saveOnlyFailed')
3939
.describe('saveOnlyFailed', 'Only save the compiled version of the test if it failed, to help easily repro failed tests (implies --saveCompiledTests)')
40+
.describe('errorForFailures', 'Return a non-zero exit code if one or more tests fail')
4041
.example('test262-harness path/to/test.js')
4142
.example('test262-harness --hostType ch --hostPath path/to/host path/to/test262/test/folder/**/*.js')
4243
.example('test262-harness --hostType ch --hostPath path/to/host --saveCompiledTests path/to/test262/test/folder/**/*.js')

test/test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ const tests = [
1111
],
1212
{ cwd: 'test/collateral-with-harness/test262' },
1313
],
14+
[
15+
[
16+
'test/**/*.js', '--error-for-failures',
17+
],
18+
{ cwd: 'test/collateral-with-harness/test262' },
19+
],
1420
[
1521
[
1622
'--test262Dir', './test/collateral-with-harness/test262',
@@ -117,6 +123,16 @@ const tests = [
117123
'./test/collateral-preprocessor/test/autofail.js',
118124
],
119125
],
126+
[
127+
[
128+
'--includesDir', './test/test-includes',
129+
'--preprocessor', './test/preprocessor/autofail.js',
130+
'--reporter-keys', 'attrs,result,rawResult',
131+
'./test/collateral-preprocessor/test/autofail.js',
132+
'--errorForFailures',
133+
],
134+
{ exitCode: 1 },
135+
],
120136
].reduce((accum, a) => {
121137
let b = a.slice();
122138

0 commit comments

Comments
 (0)