Skip to content

Commit 9141453

Browse files
committed
fix(test-runner): exit process when test awaiting timeout
1 parent 70a81dc commit 9141453

2 files changed

Lines changed: 16 additions & 8 deletions

File tree

src/core/tester/http-reporter.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ interface ResultDataBase {
99
}
1010

1111
interface ResultS {
12-
type: "start" | "pending" | "debug";
12+
type: "start" | "pending" | "debug" | "error";
1313
data?: ResultDataBase | any;
1414
}
1515

@@ -173,6 +173,12 @@ export class TestHttpReporter {
173173
else
174174
logger.fail(`Test run completed - ${this.passed} passed, ${this.failed} failed`);
175175
break;
176+
177+
case "error":
178+
logger.error(body.data?.title);
179+
this.failed++;
180+
break;
181+
176182
default:
177183
logger.log(data);
178184
break;

src/core/tester/test-bundler-template/raw/bootstrap.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,16 @@ async function startup({ id, version, resourceURI, rootURI }, reason) {
2222
"http://localhost:__PORT__/update",
2323
{
2424
body: JSON.stringify({
25-
type: "fail",
25+
type: "error",
2626
data: {
27-
title: "Internal: Plugin awaiting timeout",
28-
stack: "",
29-
str: "Plugin awaiting timeout",
27+
title: error.message,
3028
},
3129
}),
3230
}
3331
);
32+
// Although this is an exception, we still need to use the status code 0,
33+
// because status code 1 will cause Zotero to auto-restart.
34+
Zotero.Utilities.Internal.quit(0);
3435
});
3536
}
3637

@@ -53,10 +54,11 @@ function uninstall(data, reason) {}
5354

5455
async function launchTests() {
5556
// Delay to allow plugin to fully load before opening the test page
56-
await Zotero.Promise.delay(__STARTUP_DELAY__);
57+
if (__STARTUP_DELAY__) {
58+
await Zotero.Promise.delay(__STARTUP_DELAY__);
59+
}
5760

5861
const waitForPlugin = "__WAIT_FOR_PLUGIN__";
59-
6062
if (waitForPlugin) {
6163
// Wait for a plugin to be installed
6264
await waitUtilAsync(() => {
@@ -66,7 +68,7 @@ async function launchTests() {
6668
return false;
6769
}
6870
}).catch(() => {
69-
throw new Error("Plugin awaiting timeout");
71+
throw new Error("Internal: Plugin awaiting timeout");
7072
});
7173
}
7274

0 commit comments

Comments
 (0)