Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modified test-repl-persistent-history to use common.mustCall #12703

Closed
wants to merge 1 commit into from
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