-
Notifications
You must be signed in to change notification settings - Fork 73
Fix halt test #1318
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
base: master
Are you sure you want to change the base?
Fix halt test #1318
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -454,6 +454,8 @@ export class Testplane extends BaseTestplane { | |
| message: this._profiler.sanitizeMessage(err?.message ?? "Testplane run was aborted"), | ||
| }); | ||
|
|
||
| signalHandler.emit(MasterEvents.EXIT, err); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this one needed?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need for send event to reporter |
||
|
|
||
| if (timeout > 0) { | ||
| setTimeout(() => { | ||
| logger.error("Forcing shutdown..."); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| export const formatError = (err: Error): Error => { | ||
| const TRIM_MARKERS = ["Tests were stopped by the user"]; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove stack for some errors, now only for force stop |
||
|
|
||
| if (!TRIM_MARKERS.some(marker => err.stack?.includes(marker))) { | ||
| return err; | ||
| } | ||
|
|
||
| const newErr = new Error(err.message); | ||
|
|
||
| if (err.stack) { | ||
| newErr.stack = err.stack.split("\n")[0]; | ||
| } | ||
|
|
||
| return newErr; | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import { formatError } from "../../../src/utils/format-error"; | ||
|
|
||
| describe("utils/format-error", () => { | ||
| describe("when stack does not contain trigger string", () => { | ||
| it("should return the same error instance", () => { | ||
| const err = new Error("some error"); | ||
| err.stack = "Error: some error\n at foo (foo.js:1:1)\n at bar (bar.js:2:2)"; | ||
|
|
||
| const result = formatError(err); | ||
|
|
||
| assert.strictEqual(result, err); | ||
| }); | ||
| }); | ||
|
|
||
| describe("when stack contains 'Tests were stopped by the user'", () => { | ||
| it("should return a new Error instance", () => { | ||
| const err = new Error("Tests were stopped by the user"); | ||
| err.stack = "Error: Tests were stopped by the user\n at foo (foo.js:1:1)"; | ||
|
|
||
| const result = formatError(err); | ||
|
|
||
| assert.notStrictEqual(result, err); | ||
| }); | ||
|
|
||
| it("should preserve original error message", () => { | ||
| const err = new Error("Tests were stopped by the user"); | ||
| err.stack = "Error: Tests were stopped by the user\n at foo (foo.js:1:1)"; | ||
|
|
||
| const result = formatError(err); | ||
|
|
||
| assert.equal(result.message, err.message); | ||
| }); | ||
|
|
||
| it("should trim stack to first line only", () => { | ||
| const err = new Error("Tests were stopped by the user"); | ||
| err.stack = "Error: Tests were stopped by the user\n at foo (foo.js:1:1)\n at bar (bar.js:2:2)"; | ||
|
|
||
| const result = formatError(err); | ||
|
|
||
| assert.equal(result.stack, "Error: Tests were stopped by the user"); | ||
| }); | ||
| }); | ||
|
|
||
| describe("when stack is undefined", () => { | ||
| it("should return the same error instance", () => { | ||
| const err = new Error("some error"); | ||
| err.stack = undefined; | ||
|
|
||
| const result = formatError(err); | ||
|
|
||
| assert.strictEqual(result, err); | ||
| }); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove stack for no ref image error