Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -193,12 +193,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 @@ -214,6 +208,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 @@ -283,8 +279,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