Skip to content

Commit

Permalink
Fix log printing on Safari/Firefox (#214)
Browse files Browse the repository at this point in the history
Thought I tested this, but error.stack does not contain the error
message on Safari and Firefox. So include it explicitly when printing.
  • Loading branch information
kainino0x authored Jun 10, 2020
1 parent 8ffa354 commit afcbdc6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
8 changes: 3 additions & 5 deletions src/common/framework/logging/log_message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ export class LogMessageWithStack extends Error {
}

toJSON(): string {
let m = this.name + ': ';
let m = this.name;
if (this.message) m += ': ' + this.message;
if (!this.stackHidden && this.stack) {
// this.message is already included in this.stack
m += extractImportantStackTrace(this);
} else {
m += this.message;
m += '\n' + extractImportantStackTrace(this);
}
if (this.timesSeen > 1) {
m += `\n(seen ${this.timesSeen} times with identical stack)`;
Expand Down
6 changes: 3 additions & 3 deletions src/unittests/loaders_and_trees.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const specsData: { [k: string]: SpecFile } = {
t.debug('OK');
});
g.test('bluh,a').fn(t => {
t.fail('bye');
t.fail('goodbye');
});
return g;
})(),
Expand Down Expand Up @@ -223,7 +223,7 @@ g.test('end2end').fn(async t => {

t.expect(log.results.get(name) === res);
t.expect(res.status === status);
t.expect(res.timems > 0);
t.expect(res.timems >= 0);
assert(res.logs !== undefined); // only undefined while pending
t.expect(logs(res.logs.map(l => JSON.stringify(l))));
};
Expand All @@ -240,7 +240,7 @@ g.test('end2end').fn(async t => {
'fail',
logs =>
logs.length === 1 &&
logs[0].startsWith('"EXPECTATION FAILED: Error: bye\\n') &&
logs[0].startsWith('"EXPECTATION FAILED: goodbye\\n') &&
logs[0].indexOf('loaders_and_trees.spec.') !== -1
);
});
Expand Down

0 comments on commit afcbdc6

Please sign in to comment.