@c9up/helix-plugin-ream 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/runTests.d.ts +19 -5
- package/dist/runTests.d.ts.map +1 -1
- package/dist/runTests.js +10 -10
- package/dist/runTests.js.map +1 -1
- package/package.json +1 -1
- package/src/runTests.ts +35 -14
package/dist/runTests.d.ts
CHANGED
|
@@ -24,6 +24,22 @@ import type { TestsConfig } from "@c9up/ream";
|
|
|
24
24
|
export interface RunTestsOptions {
|
|
25
25
|
/** Project root the suites resolve against. Defaults to `process.cwd()`. */
|
|
26
26
|
root?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Watch for a run that finishes but leaves the process alive, and after a
|
|
29
|
+
* grace period say what is still open — then exit with the run's code.
|
|
30
|
+
*
|
|
31
|
+
* OFF by default, because it ends the process and this function is a
|
|
32
|
+
* library: it is called from a `bin/test.ts`, from a console command, and
|
|
33
|
+
* from tests of its own, and the documented contract is that the caller
|
|
34
|
+
* decides what to do with the returned code. Arming it unconditionally
|
|
35
|
+
* broke that — a caller's own runner was killed mid-run by an exit it never
|
|
36
|
+
* asked for.
|
|
37
|
+
*
|
|
38
|
+
* `ream test` turns it on: there the process IS the run, and a summary
|
|
39
|
+
* followed by an unexplained hang is worse than an exit that names what is
|
|
40
|
+
* still open.
|
|
41
|
+
*/
|
|
42
|
+
drainGuard?: boolean;
|
|
27
43
|
/**
|
|
28
44
|
* Suite names to run. Empty (the default) runs every declared suite, in
|
|
29
45
|
* order — the AdonisJS behaviour for `ream test` with no argument.
|
|
@@ -67,12 +83,10 @@ export declare class SuiteConfigureUnreachableError extends Error {
|
|
|
67
83
|
/**
|
|
68
84
|
* The flags the worker processes are spawned with.
|
|
69
85
|
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* rides ALONGSIDE whatever loader is already there — the test files still need
|
|
73
|
-
* theirs to read TypeScript.
|
|
86
|
+
* A project's own flags win; otherwise the workers inherit this process's, so
|
|
87
|
+
* the loader that lets the test files be read as TypeScript carries over.
|
|
74
88
|
*/
|
|
75
|
-
export declare function workerNodeArgs(
|
|
89
|
+
export declare function workerNodeArgs(options: RunTestsOptions): string[];
|
|
76
90
|
/**
|
|
77
91
|
* Run the rc file's test suites. Returns the process exit code; the caller
|
|
78
92
|
* decides what to do with it, so this stays usable from a `bin/test.ts`, from a
|
package/dist/runTests.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runTests.d.ts","sourceRoot":"","sources":["../src/runTests.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,OAAO,KAAK,EAAmB,WAAW,EAAE,MAAM,YAAY,CAAC;AAG/D,wDAAwD;AACxD,MAAM,WAAW,eAAe;IAC/B,4EAA4E;IAC5E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,mCAAmC;IACnC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,iCAAiC;IACjC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,2DAA2D;AAC3D,qBAAa,iBAAkB,SAAQ,KAAK;gBAC/B,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE;CAQ5C;AAED;;;;;;GAMG;AACH,qBAAa,8BAA+B,SAAQ,KAAK;gBAC5C,KAAK,EAAE,MAAM,EAAE;CAU3B;AAED
|
|
1
|
+
{"version":3,"file":"runTests.d.ts","sourceRoot":"","sources":["../src/runTests.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,OAAO,KAAK,EAAmB,WAAW,EAAE,MAAM,YAAY,CAAC;AAG/D,wDAAwD;AACxD,MAAM,WAAW,eAAe;IAC/B,4EAA4E;IAC5E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;;;;;;;;;OAcG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,mCAAmC;IACnC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,iCAAiC;IACjC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,2DAA2D;AAC3D,qBAAa,iBAAkB,SAAQ,KAAK;gBAC/B,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE;CAQ5C;AAED;;;;;;GAMG;AACH,qBAAa,8BAA+B,SAAQ,KAAK;gBAC5C,KAAK,EAAE,MAAM,EAAE;CAU3B;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,EAAE,CAEjE;AAkBD;;;;;;;;;;GAUG;AACH,wBAAsB,QAAQ,CAC7B,KAAK,EAAE,WAAW,GAAG,SAAS,EAC9B,OAAO,GAAE,eAAoB,GAC3B,OAAO,CAAC,MAAM,CAAC,CAmHjB;AA2BD;;;GAGG;AACH,wBAAsB,kBAAkB,CACvC,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,eAAoB,GAC3B,OAAO,CAAC,MAAM,CAAC,CAmBjB"}
|
package/dist/runTests.js
CHANGED
|
@@ -51,12 +51,10 @@ export class SuiteConfigureUnreachableError extends Error {
|
|
|
51
51
|
/**
|
|
52
52
|
* The flags the worker processes are spawned with.
|
|
53
53
|
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* rides ALONGSIDE whatever loader is already there — the test files still need
|
|
57
|
-
* theirs to read TypeScript.
|
|
54
|
+
* A project's own flags win; otherwise the workers inherit this process's, so
|
|
55
|
+
* the loader that lets the test files be read as TypeScript carries over.
|
|
58
56
|
*/
|
|
59
|
-
export function workerNodeArgs(
|
|
57
|
+
export function workerNodeArgs(options) {
|
|
60
58
|
return [...(options.nodeArgs ?? process.execArgv)];
|
|
61
59
|
}
|
|
62
60
|
/** The suites to run, in declaration order, for the given selection. */
|
|
@@ -100,6 +98,8 @@ export async function runTests(tests, options = {}) {
|
|
|
100
98
|
// Assigned either way: a second call in the same process must not inherit
|
|
101
99
|
// the first one's flag. A plugin reads it back off `api.cliArgs.forceExit`.
|
|
102
100
|
const forceExit = tests?.forceExit === true;
|
|
101
|
+
// Opt-in: this is a library, and the guard ends the process.
|
|
102
|
+
const drainGuard = options.drainGuard === true;
|
|
103
103
|
process.env.HELIX_FORCE_EXIT = forceExit ? "1" : "";
|
|
104
104
|
// Only named when a suite actually declares `configure`: pointing at it makes
|
|
105
105
|
// every worker import the rc file, which a project not using the callback
|
|
@@ -119,7 +119,7 @@ export async function runTests(tests, options = {}) {
|
|
|
119
119
|
process.env.HELIX_SUITE_CONFIG_KEY = "tests.suites";
|
|
120
120
|
const base = {
|
|
121
121
|
root,
|
|
122
|
-
nodeArgs: workerNodeArgs(
|
|
122
|
+
nodeArgs: workerNodeArgs(options),
|
|
123
123
|
threads: options.threads,
|
|
124
124
|
timeoutMs: tests?.timeout,
|
|
125
125
|
reporters: options.reporters,
|
|
@@ -134,7 +134,7 @@ export async function runTests(tests, options = {}) {
|
|
|
134
134
|
if (selected.length === 0) {
|
|
135
135
|
try {
|
|
136
136
|
const outcome = await helix.run(base);
|
|
137
|
-
return finish(outcome.exitCode, forceExit, helix.armDrainGuard);
|
|
137
|
+
return finish(outcome.exitCode, forceExit, drainGuard ? helix.armDrainGuard : undefined);
|
|
138
138
|
}
|
|
139
139
|
finally {
|
|
140
140
|
await dropGlobalHooks();
|
|
@@ -164,11 +164,11 @@ export async function runTests(tests, options = {}) {
|
|
|
164
164
|
}
|
|
165
165
|
if (steps.length === 0) {
|
|
166
166
|
await dropGlobalHooks();
|
|
167
|
-
return finish(0, forceExit, helix.armDrainGuard);
|
|
167
|
+
return finish(0, forceExit, drainGuard ? helix.armDrainGuard : undefined);
|
|
168
168
|
}
|
|
169
169
|
try {
|
|
170
170
|
const outcome = await helix.runSuites(steps, base);
|
|
171
|
-
return finish(outcome.exitCode, forceExit, helix.armDrainGuard);
|
|
171
|
+
return finish(outcome.exitCode, forceExit, drainGuard ? helix.armDrainGuard : undefined);
|
|
172
172
|
}
|
|
173
173
|
finally {
|
|
174
174
|
await dropGlobalHooks();
|
|
@@ -191,7 +191,7 @@ function finish(code, forceExit, armDrainGuard) {
|
|
|
191
191
|
// further output, and under a CI timeout that is a non-zero exit for a run in
|
|
192
192
|
// which every test passed. helix's own CLI already said so; this entry point
|
|
193
193
|
// did not, and it is the one `ream test` goes through.
|
|
194
|
-
armDrainGuard(code);
|
|
194
|
+
armDrainGuard?.(code);
|
|
195
195
|
return code;
|
|
196
196
|
}
|
|
197
197
|
/**
|
package/dist/runTests.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runTests.js","sourceRoot":"","sources":["../src/runTests.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"runTests.js","sourceRoot":"","sources":["../src/runTests.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC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QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;QACvC,CAAC,CAAC,MAAM;QACR,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC9B,MAAM,QAAQ,GAAY,MAAM,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC;IACrE,MAAM,EAAE,GACP,QAAQ,KAAK,IAAI,IAAI,OAAO,QAAQ,KAAK,QAAQ;QAChD,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,SAAS,CAAC,IAAI,QAAQ,CAAC;QAChD,CAAC,CAAC,SAAS,CAAC;IACd,MAAM,KAAK,GACV,EAAE,KAAK,IAAI,IAAI,OAAO,EAAE,KAAK,QAAQ;QACpC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,CAAC;QAC1B,CAAC,CAAC,SAAS,CAAC;IACd,OAAO,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,EAAE;QACzD,GAAG,OAAO;QACV,IAAI;QACJ,YAAY,EAAE,QAAQ;KACtB,CAAC,CAAC;AACJ,CAAC;AAED,6DAA6D;AAC7D,SAAS,aAAa,CAAC,KAAc;IACpC,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;AACpD,CAAC"}
|
package/package.json
CHANGED
package/src/runTests.ts
CHANGED
|
@@ -29,6 +29,22 @@ import { loadEnvFiles } from "@c9up/ream/env";
|
|
|
29
29
|
export interface RunTestsOptions {
|
|
30
30
|
/** Project root the suites resolve against. Defaults to `process.cwd()`. */
|
|
31
31
|
root?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Watch for a run that finishes but leaves the process alive, and after a
|
|
34
|
+
* grace period say what is still open — then exit with the run's code.
|
|
35
|
+
*
|
|
36
|
+
* OFF by default, because it ends the process and this function is a
|
|
37
|
+
* library: it is called from a `bin/test.ts`, from a console command, and
|
|
38
|
+
* from tests of its own, and the documented contract is that the caller
|
|
39
|
+
* decides what to do with the returned code. Arming it unconditionally
|
|
40
|
+
* broke that — a caller's own runner was killed mid-run by an exit it never
|
|
41
|
+
* asked for.
|
|
42
|
+
*
|
|
43
|
+
* `ream test` turns it on: there the process IS the run, and a summary
|
|
44
|
+
* followed by an unexplained hang is worse than an exit that names what is
|
|
45
|
+
* still open.
|
|
46
|
+
*/
|
|
47
|
+
drainGuard?: boolean;
|
|
32
48
|
/**
|
|
33
49
|
* Suite names to run. Empty (the default) runs every declared suite, in
|
|
34
50
|
* order — the AdonisJS behaviour for `ream test` with no argument.
|
|
@@ -91,15 +107,10 @@ export class SuiteConfigureUnreachableError extends Error {
|
|
|
91
107
|
/**
|
|
92
108
|
* The flags the worker processes are spawned with.
|
|
93
109
|
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
* rides ALONGSIDE whatever loader is already there — the test files still need
|
|
97
|
-
* theirs to read TypeScript.
|
|
110
|
+
* A project's own flags win; otherwise the workers inherit this process's, so
|
|
111
|
+
* the loader that lets the test files be read as TypeScript carries over.
|
|
98
112
|
*/
|
|
99
|
-
export function workerNodeArgs(
|
|
100
|
-
tests: TestsConfig | undefined,
|
|
101
|
-
options: RunTestsOptions,
|
|
102
|
-
): string[] {
|
|
113
|
+
export function workerNodeArgs(options: RunTestsOptions): string[] {
|
|
103
114
|
return [...(options.nodeArgs ?? process.execArgv)];
|
|
104
115
|
}
|
|
105
116
|
|
|
@@ -153,6 +164,8 @@ export async function runTests(
|
|
|
153
164
|
// Assigned either way: a second call in the same process must not inherit
|
|
154
165
|
// the first one's flag. A plugin reads it back off `api.cliArgs.forceExit`.
|
|
155
166
|
const forceExit = tests?.forceExit === true;
|
|
167
|
+
// Opt-in: this is a library, and the guard ends the process.
|
|
168
|
+
const drainGuard = options.drainGuard === true;
|
|
156
169
|
process.env.HELIX_FORCE_EXIT = forceExit ? "1" : "";
|
|
157
170
|
|
|
158
171
|
// Only named when a suite actually declares `configure`: pointing at it makes
|
|
@@ -178,7 +191,7 @@ export async function runTests(
|
|
|
178
191
|
|
|
179
192
|
const base = {
|
|
180
193
|
root,
|
|
181
|
-
nodeArgs: workerNodeArgs(
|
|
194
|
+
nodeArgs: workerNodeArgs(options),
|
|
182
195
|
threads: options.threads,
|
|
183
196
|
timeoutMs: tests?.timeout,
|
|
184
197
|
reporters: options.reporters,
|
|
@@ -195,7 +208,11 @@ export async function runTests(
|
|
|
195
208
|
if (selected.length === 0) {
|
|
196
209
|
try {
|
|
197
210
|
const outcome = await helix.run(base);
|
|
198
|
-
return finish(
|
|
211
|
+
return finish(
|
|
212
|
+
outcome.exitCode,
|
|
213
|
+
forceExit,
|
|
214
|
+
drainGuard ? helix.armDrainGuard : undefined,
|
|
215
|
+
);
|
|
199
216
|
} finally {
|
|
200
217
|
await dropGlobalHooks();
|
|
201
218
|
}
|
|
@@ -229,12 +246,16 @@ export async function runTests(
|
|
|
229
246
|
}
|
|
230
247
|
if (steps.length === 0) {
|
|
231
248
|
await dropGlobalHooks();
|
|
232
|
-
return finish(0, forceExit, helix.armDrainGuard);
|
|
249
|
+
return finish(0, forceExit, drainGuard ? helix.armDrainGuard : undefined);
|
|
233
250
|
}
|
|
234
251
|
|
|
235
252
|
try {
|
|
236
253
|
const outcome = await helix.runSuites(steps, base);
|
|
237
|
-
return finish(
|
|
254
|
+
return finish(
|
|
255
|
+
outcome.exitCode,
|
|
256
|
+
forceExit,
|
|
257
|
+
drainGuard ? helix.armDrainGuard : undefined,
|
|
258
|
+
);
|
|
238
259
|
} finally {
|
|
239
260
|
await dropGlobalHooks();
|
|
240
261
|
}
|
|
@@ -249,7 +270,7 @@ export async function runTests(
|
|
|
249
270
|
function finish(
|
|
250
271
|
code: number,
|
|
251
272
|
forceExit: boolean,
|
|
252
|
-
armDrainGuard: (code: number) => void,
|
|
273
|
+
armDrainGuard: ((code: number) => void) | undefined,
|
|
253
274
|
): number {
|
|
254
275
|
if (forceExit) {
|
|
255
276
|
process.exitCode = code;
|
|
@@ -261,7 +282,7 @@ function finish(
|
|
|
261
282
|
// further output, and under a CI timeout that is a non-zero exit for a run in
|
|
262
283
|
// which every test passed. helix's own CLI already said so; this entry point
|
|
263
284
|
// did not, and it is the one `ream test` goes through.
|
|
264
|
-
armDrainGuard(code);
|
|
285
|
+
armDrainGuard?.(code);
|
|
265
286
|
return code;
|
|
266
287
|
}
|
|
267
288
|
|