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

test: increase strictness for test-trace-event #11065

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
14 changes: 9 additions & 5 deletions test/parallel/test-trace-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,19 @@ proc_no_categories.once('exit', common.mustCall(() => {

proc.once('exit', common.mustCall(() => {
assert(common.fileExists(FILE_NAME));
fs.readFile(FILE_NAME, (err, data) => {
fs.readFile(FILE_NAME, common.mustCall((err, data) => {
const traces = JSON.parse(data.toString()).traceEvents;
assert(traces.length > 0);
// Values that should be present on all runs to approximate correctness.
assert(traces.some((trace) => { return trace.pid === proc.pid; }));
assert(traces.some((trace) => { return trace.cat === 'v8'; }));
assert(traces.some((trace) => {
return trace.name === 'V8.ScriptCompiler';
if (trace.pid !== proc.pid)
return false;
if (trace.cat !== 'v8')
return false;
if (trace.name !== 'V8.ScriptCompiler')
return false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would prefer to condense these but definitely not necessary to do so:

e.g.

return trace.pid === proc.pid &&
           trace.cat === 'v8' &&
           trace.name === 'V8.ScriptCompiler';

Copy link
Member Author

@Trott Trott Jan 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think changing each to an assert.strictEqual() would be even better because it gives descriptive information about exactly why the throw isn't matching. Otherwise, you kind of have to figure it out.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

D'oh! No, I'm wrong, never mind. I thought this was inside an assert.throws() and not an Array.prototype.some(). Ignore my previous comment.

return true;
}));
});
}));
}));
}));