Skip to content

Commit

Permalink
test: refactored test-repl-persistent-history
Browse files Browse the repository at this point in the history
PR-URL: #12703
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
  • Loading branch information
cool88 authored and addaleax committed May 7, 2017
1 parent dac9f42 commit 6058c43
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions test/parallel/test-repl-persistent-history.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,6 @@ const tests = [
const numtests = tests.length;


let testsNotRan = tests.length;

process.on('beforeExit', () =>
assert.strictEqual(testsNotRan, 0)
);

function cleanupTmpFile() {
try {
// Write over the file, clearing any history
Expand All @@ -225,6 +219,8 @@ function cleanupTmpFile() {
fs.createReadStream(historyFixturePath)
.pipe(fs.createWriteStream(historyPath)).on('unpipe', () => runTest());

const runTestWrap = common.mustCall(runTest, numtests);

function runTest(assertCleaned) {
const opts = tests.shift();
if (!opts) return; // All done
Expand Down Expand Up @@ -294,8 +290,7 @@ function runTest(assertCleaned) {
try {
// Ensure everything that we expected was output
assert.strictEqual(expected.length, 0);
testsNotRan--;
setImmediate(runTest, cleaned);
setImmediate(runTestWrap, cleaned);
} catch (err) {
console.error(`Failed test # ${numtests - tests.length}`);
throw err;
Expand Down

0 comments on commit 6058c43

Please sign in to comment.