Browse Source

test: refactored test-repl-persistent-history

PR-URL: https://github.com/nodejs/node/pull/12703
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
v6
cool88 8 years ago
committed by Anna Henningsen
parent
commit
6058c4349f
No known key found for this signature in database GPG Key ID: D8B9F5AEAE84E4CF
  1. 11
      test/parallel/test-repl-persistent-history.js

11
test/parallel/test-repl-persistent-history.js

@ -204,12 +204,6 @@ const tests = [
const numtests = tests.length; const numtests = tests.length;
let testsNotRan = tests.length;
process.on('beforeExit', () =>
assert.strictEqual(testsNotRan, 0)
);
function cleanupTmpFile() { function cleanupTmpFile() {
try { try {
// Write over the file, clearing any history // Write over the file, clearing any history
@ -225,6 +219,8 @@ function cleanupTmpFile() {
fs.createReadStream(historyFixturePath) fs.createReadStream(historyFixturePath)
.pipe(fs.createWriteStream(historyPath)).on('unpipe', () => runTest()); .pipe(fs.createWriteStream(historyPath)).on('unpipe', () => runTest());
const runTestWrap = common.mustCall(runTest, numtests);
function runTest(assertCleaned) { function runTest(assertCleaned) {
const opts = tests.shift(); const opts = tests.shift();
if (!opts) return; // All done if (!opts) return; // All done
@ -294,8 +290,7 @@ function runTest(assertCleaned) {
try { try {
// Ensure everything that we expected was output // Ensure everything that we expected was output
assert.strictEqual(expected.length, 0); assert.strictEqual(expected.length, 0);
testsNotRan--; setImmediate(runTestWrap, cleaned);
setImmediate(runTest, cleaned);
} catch (err) { } catch (err) {
console.error(`Failed test # ${numtests - tests.length}`); console.error(`Failed test # ${numtests - tests.length}`);
throw err; throw err;

Loading…
Cancel
Save