Skip to content

Commit

Permalink
Ensure doctests run in sequence to avoid mangled stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
Avaq committed Apr 12, 2020
1 parent 84afa33 commit cb273b3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 26 deletions.
16 changes: 10 additions & 6 deletions lib/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@ exports.runDoctests = function(doctest, program) {
]));
process.exit (1);
}
Promise.all (program.args.map (function(path) {
return (doctest (path, program)).then (function(results) {
return results.reduce (function(status, tuple) {
return tuple[0] ? status : 1;
}, 0);
program.args.reduce (function(promise, path) {
return promise.then (function(statuses) {
return doctest (path, program).then (function(results) {
var status = results.reduce (function(status, tuple) {
return tuple[0] ? status : 1;
}, 0);
return statuses.concat ([status]);
});
});
})).then (function(statuses) {
}, Promise.resolve ([]))
.then (function(statuses) {
process.exit (statuses.every (function(s) { return s === 0; }) ? 0 : 1);
}, function(err) {
process.stderr.write (exports.formatErrors ([err.message]));
Expand Down
40 changes: 20 additions & 20 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,26 +158,26 @@ testCommand ('bin/doctest test/shared/index.coffee', {
stderr: ''
});

// testCommand ('bin/doctest test/shared/index.js test/shared/index.coffee', {
// status: 1,
// stdout: unlines ([
// 'running doctests in test/shared/index.js...',
// '......x.x...........x........x',
// 'FAIL: expected 5 on line 31 (got 4)',
// 'FAIL: expected ! TypeError on line 38 (got 0)',
// 'FAIL: expected 9.5 on line 97 (got 5)',
// 'FAIL: expected "on automatic semicolon insertion" on line 155 ' +
// '(got "the rewriter should not rely")',
// 'running doctests in test/shared/index.coffee...',
// '......x.x...........x........x',
// 'FAIL: expected 5 on line 31 (got 4)',
// 'FAIL: expected ! TypeError on line 38 (got 0)',
// 'FAIL: expected 9.5 on line 97 (got 5)',
// 'FAIL: expected "on automatic semicolon insertion" on line 155 ' +
// '(got "the rewriter should not rely")'
// ]),
// stderr: ''
// });
testCommand ('bin/doctest test/shared/index.js test/shared/index.coffee', {
status: 1,
stdout: unlines ([
'running doctests in test/shared/index.js...',
'......x.x...........x........x',
'FAIL: expected 5 on line 31 (got 4)',
'FAIL: expected ! TypeError on line 38 (got 0)',
'FAIL: expected 9.5 on line 97 (got 5)',
'FAIL: expected "on automatic semicolon insertion" on line 155 ' +
'(got "the rewriter should not rely")',
'running doctests in test/shared/index.coffee...',
'......x.x...........x........x',
'FAIL: expected 5 on line 31 (got 4)',
'FAIL: expected ! TypeError on line 38 (got 0)',
'FAIL: expected 9.5 on line 97 (got 5)',
'FAIL: expected "on automatic semicolon insertion" on line 155 ' +
'(got "the rewriter should not rely")'
]),
stderr: ''
});

testCommand ('bin/doctest --silent test/shared/index.js', {
status: 1,
Expand Down

0 comments on commit cb273b3

Please sign in to comment.