Skip to content
This repository has been archived by the owner on Jun 18, 2021. It is now read-only.

Commit

Permalink
Validate only one report is produced
Browse files Browse the repository at this point in the history
  • Loading branch information
richardlau committed Nov 3, 2016
1 parent bea2420 commit f228aa0
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 23 deletions.
6 changes: 3 additions & 3 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ const REPORT_SECTIONS = [
'System Information'
];

exports.locate = (pid) => {
exports.findReports = (pid) => {
// Default NodeReport filenames are of the form NodeReport.<date>.<time>.<pid>.<seq>.txt
const filePattern = new RegExp('^NodeReport\\.\\d+\\.\\d+\\.' + pid + '\\.\\d+\\.txt$');
var files = fs.readdirSync(".");
return files.find((file) => filePattern.test(file));
const files = fs.readdirSync(".");
return files.filter((file) => filePattern.test(file));
};

exports.validate = (t, report, pid) => {
Expand Down
9 changes: 4 additions & 5 deletions test/test-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ if (process.argv[2] === 'child') {
tap.plan(3);
tap.equal(code, 0, 'Process exited cleanly');
// Locate and validate the NodeReport
const report = common.locate(child.pid);
tap.ok(report, 'found report ' + report);
if (report) {
common.validate(tap, report, child.pid);
}
const reports = common.findReports(child.pid);
tap.equal(reports.length, 1, 'Found reports ' + reports);
const report = reports[0];
common.validate(tap, report, child.pid);
});
};
9 changes: 4 additions & 5 deletions test/test-exception.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ if (process.argv[2] === 'child') {
tap.equal(signal, expectedSignal, 'Process should exit with signal ' + expectedSignal);

// Locate and validate the NodeReport
const report = common.locate(child.pid);
tap.ok(report, 'found report ' + report);
if (report) {
common.validate(tap, report, child.pid);
}
const reports = common.findReports(child.pid);
tap.equal(reports.length, 1, 'Found reports ' + reports);
const report = reports[0];
common.validate(tap, report, child.pid);
});
};
9 changes: 4 additions & 5 deletions test/test-fatal-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ if (process.argv[2] === 'child') {
tap.plan(3);
tap.notEqual(code, 0, 'Process should not exit cleanly');
// Locate and validate the NodeReport
const report = common.locate(child.pid);
tap.ok(report, 'found report ' + report);
if (report) {
common.validate(tap, report, child.pid);
}
const reports = common.findReports(child.pid);
tap.equal(reports.length, 1, 'Found reports ' + reports);
const report = reports[0];
common.validate(tap, report, child.pid);
});
};
9 changes: 4 additions & 5 deletions test/test-signal.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@ if (process.argv[2] === 'child') {
tap.equal(code, null, 'Process should not exit cleanly');
tap.equal(signal, 'SIGTERM', 'Process should exit with SIGTERM');
// Locate and validate the NodeReport
const report = common.locate(child.pid);
tap.ok(report, 'found report ' + report);
if (report) {
common.validate(tap, report, child.pid);
}
const reports = common.findReports(child.pid);
tap.equal(reports.length, 1, 'Found reports ' + reports);
const report = reports[0];
common.validate(tap, report, child.pid);
});
};

0 comments on commit f228aa0

Please sign in to comment.