@quiesco/core 0.2.0 → 0.3.0

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/index.d.ts CHANGED
@@ -46,4 +46,12 @@ export { LogBuffer, killChildProcessesSync, trackChildProcess, trackedChildPids
46
46
  export { SERIAL_WORKER } from './devices/provider.js';
47
47
  export { WORKER_SIMULATOR, workerSimulatorName } from './devices/ios.js';
48
48
  export { CPU_GPU_MODES, WORKER_AVD, emulatorGpu, workerAvdName } from './devices/android.js';
49
+ export { RunEventServer, connectRunEvents, runEventsAddress } from './run-events.js';
50
+ export type { ConnectOptions, RunEventClient, RunEventServerOptions } from './run-events.js';
51
+ export { RUN_EVENTS_ENV, RUN_EVENTS_PROTOCOL, createRunEventDecoder, emptyCounts, encodeRunEvent, isRunEvent } from '@quiesco/protocol';
52
+ export type { RunCounts, RunError, RunEvent, RunEventOf, RunEventType, RunEvents, RunnerName, TestList, TestRef, TestStatus } from '@quiesco/protocol';
53
+ export { RunState } from './run-state.js';
54
+ export type { RunPhase, RunStateSnapshot, RunningTest, TestState } from './run-state.js';
55
+ export { listEntry, listTests } from './run-list.js';
56
+ export type { ListTestsOptions } from './run-list.js';
49
57
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,cAAc,EAAE,cAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElJ,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,eAAe,EAAE,UAAU,EAAE,aAAa,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAC5L,YAA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E,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC9G,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC7F,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACrF,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAC7F,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,WAAW,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACxI,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACvJ,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,YAAY,EAAE,QAAQ,EAAE,gBAAgB,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACzF,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACrD,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC"}
package/dist/index.js CHANGED
@@ -25,4 +25,8 @@ export { LogBuffer, killChildProcessesSync, trackChildProcess, trackedChildPids
25
25
  export { SERIAL_WORKER } from './devices/provider.js';
26
26
  export { WORKER_SIMULATOR, workerSimulatorName } from './devices/ios.js';
27
27
  export { CPU_GPU_MODES, WORKER_AVD, emulatorGpu, workerAvdName } from './devices/android.js';
28
+ export { RunEventServer, connectRunEvents, runEventsAddress } from './run-events.js';
29
+ export { RUN_EVENTS_ENV, RUN_EVENTS_PROTOCOL, createRunEventDecoder, emptyCounts, encodeRunEvent, isRunEvent } from '@quiesco/protocol';
30
+ export { RunState } from './run-state.js';
31
+ export { listEntry, listTests } from './run-list.js';
28
32
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAGrD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,eAAe,EAAE,UAAU,EAAE,aAAa,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAE5L,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGjD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG1D,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAGhF,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAIlE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,OAAO,E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B,CAAC;AAC9G,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC7F,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAErF,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,WAAW,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAExI,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,60 @@
1
+ import type { RunEvent, RunnerName } from '@quiesco/protocol';
2
+ /** A fresh socket address for this process. */
3
+ export declare function runEventsAddress(platform?: NodeJS.Platform, tmpdir?: string): string;
4
+ export interface RunEventServerOptions {
5
+ /** Each decoded event, with the connection it came on (1, 2, …). */
6
+ onEvent: (event: RunEvent, connection: number) => void;
7
+ /** A line that is not a known run event (skipped). */
8
+ onInvalid?: (line: string, reason: string) => void;
9
+ /** Default: runEventsAddress(). */
10
+ address?: string;
11
+ }
12
+ export declare class RunEventServer {
13
+ private readonly options;
14
+ private readonly server;
15
+ private readonly sockets;
16
+ private readonly idleWaiters;
17
+ private nextConnection;
18
+ private listening;
19
+ readonly address: string;
20
+ /** The runners that said hello (a reporter is wired in). */
21
+ readonly hellos: {
22
+ runner: RunnerName;
23
+ protocol: number;
24
+ connection: number;
25
+ }[];
26
+ constructor(options: RunEventServerOptions);
27
+ listen(): Promise<string>;
28
+ /** Environment for the runner process. */
29
+ env(): Record<string, string>;
30
+ /** Number of open connections. */
31
+ get connections(): number;
32
+ /**
33
+ * Resolves once no connection is open, or after `timeoutMs`. Called after the runner exits: its
34
+ * last events may still be in flight on a connection that is closing.
35
+ */
36
+ drain(timeoutMs?: number): Promise<void>;
37
+ /** Stops listening, closes the connections still open and removes the socket file. */
38
+ close(): Promise<void>;
39
+ private accept;
40
+ }
41
+ export interface RunEventClient {
42
+ /** False when QUIESCO_EVENTS is not set or the connection failed: send() does nothing. */
43
+ readonly enabled: boolean;
44
+ send(event: RunEvent): void;
45
+ /** Flushes and closes the connection. Safe to call more than once. */
46
+ close(): Promise<void>;
47
+ }
48
+ export interface ConnectOptions {
49
+ runner: RunnerName;
50
+ runnerVersion?: string;
51
+ env?: NodeJS.ProcessEnv;
52
+ /** Told once when the connection fails. Default: a line on stderr. */
53
+ warn?: (message: string) => void;
54
+ }
55
+ /**
56
+ * Connects to the `quiesco` process named by QUIESCO_EVENTS and sends `hello`. Events sent before the
57
+ * connection is up are buffered by the socket. The connection does not keep the process alive.
58
+ */
59
+ export declare function connectRunEvents(options: ConnectOptions): RunEventClient;
60
+ //# sourceMappingURL=run-events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-events.d.ts","sourceRoot":"","sources":["../src/run-events.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAK9D,+CAA+C;AAC/C,wBAAgB,gBAAgB,CAAC,QAAQ,GAAE,MAAM,CAAC,QAA2B,EAAE,MAAM,GAAE,MAAoB,GAAG,MAAM,CAMnH;AAED,MAAM,WAAW,qBAAqB;IACpC,oEAAoE;IACpE,OAAO,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IACvD,sDAAsD;IACtD,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,mCAAmC;IACnC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,cAAc;IAUb,OAAO,CAAC,QAA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AgB,CAAC,OAAO,EAAE,cAAc,GAAG,cAAc,CAmCxE"}
@@ -0,0 +1,161 @@
1
+ /**
2
+ * Transport of run events (`@quiesco/protocol` run-events) between a runner's Quiesco reporter and the
3
+ * `quiesco` process: a local socket (Unix socket file, or a named pipe on Windows) carrying NDJSON.
4
+ *
5
+ * - The CLI starts a RunEventServer and passes `server.env()` to the runner it spawns.
6
+ * - Reporters (and workers adding evidence) call `connectRunEvents()`: without QUIESCO_EVENTS it
7
+ * returns a client that sends nothing, so running the runner directly is unaffected.
8
+ * - A broken connection never fails a test: the client warns once and drops further events.
9
+ */
10
+ import { randomBytes } from 'node:crypto';
11
+ import { chmodSync } from 'node:fs';
12
+ import net from 'node:net';
13
+ import os from 'node:os';
14
+ import path from 'node:path';
15
+ import { RUN_EVENTS_ENV, RUN_EVENTS_PROTOCOL, createRunEventDecoder, encodeRunEvent } from '@quiesco/protocol';
16
+ /** Longest Unix socket path that works everywhere (sun_path is 104 bytes on macOS, 108 on Linux). */
17
+ const MAX_SOCKET_PATH = 100;
18
+ /** A fresh socket address for this process. */
19
+ export function runEventsAddress(platform = process.platform, tmpdir = os.tmpdir()) {
20
+ const name = `quiesco-${process.pid}-${randomBytes(4).toString('hex')}`;
21
+ if (platform === 'win32')
22
+ return `\\\\.\\pipe\\${name}`;
23
+ const file = path.join(tmpdir, `${name}.sock`);
24
+ // A long TMPDIR (some CI images) would make the path too long for a Unix socket.
25
+ return file.length <= MAX_SOCKET_PATH ? file : path.join('/tmp', `${name}.sock`);
26
+ }
27
+ export class RunEventServer {
28
+ options;
29
+ server;
30
+ sockets = new Set();
31
+ idleWaiters = [];
32
+ nextConnection = 1;
33
+ listening = false;
34
+ address;
35
+ /** The runners that said hello (a reporter is wired in). */
36
+ hellos = [];
37
+ constructor(options) {
38
+ this.options = options;
39
+ this.address = options.address ?? runEventsAddress();
40
+ this.server = net.createServer((socket) => this.accept(socket));
41
+ }
42
+ async listen() {
43
+ await new Promise((resolve, reject) => {
44
+ this.server.once('error', reject);
45
+ this.server.listen(this.address, () => {
46
+ this.server.off('error', reject);
47
+ resolve();
48
+ });
49
+ });
50
+ this.listening = true;
51
+ // Only this user may connect (the socket file is created with the process umask).
52
+ if (process.platform !== 'win32')
53
+ chmodSync(this.address, 0o600);
54
+ return this.address;
55
+ }
56
+ /** Environment for the runner process. */
57
+ env() {
58
+ return { [RUN_EVENTS_ENV]: this.address };
59
+ }
60
+ /** Number of open connections. */
61
+ get connections() {
62
+ return this.sockets.size;
63
+ }
64
+ /**
65
+ * Resolves once no connection is open, or after `timeoutMs`. Called after the runner exits: its
66
+ * last events may still be in flight on a connection that is closing.
67
+ */
68
+ async drain(timeoutMs = 2000) {
69
+ if (this.sockets.size === 0)
70
+ return;
71
+ await new Promise((resolve) => {
72
+ const timer = setTimeout(done, timeoutMs);
73
+ timer.unref();
74
+ function done() {
75
+ clearTimeout(timer);
76
+ resolve();
77
+ }
78
+ this.idleWaiters.push(done);
79
+ });
80
+ }
81
+ /** Stops listening, closes the connections still open and removes the socket file. */
82
+ async close() {
83
+ for (const s of this.sockets)
84
+ s.destroy();
85
+ this.sockets.clear();
86
+ if (!this.listening)
87
+ return;
88
+ this.listening = false;
89
+ // net.Server removes its Unix socket file on close.
90
+ await new Promise((resolve) => this.server.close(() => resolve()));
91
+ }
92
+ accept(socket) {
93
+ const connection = this.nextConnection++;
94
+ this.sockets.add(socket);
95
+ socket.setEncoding('utf8');
96
+ const decoder = createRunEventDecoder((event) => {
97
+ if (event.type === 'hello')
98
+ this.hellos.push({ runner: event.runner, protocol: event.protocol, connection });
99
+ this.options.onEvent(event, connection);
100
+ }, this.options.onInvalid);
101
+ socket.on('data', (chunk) => decoder.push(chunk));
102
+ socket.on('end', () => decoder.end());
103
+ socket.on('error', () => { });
104
+ socket.on('close', () => {
105
+ this.sockets.delete(socket);
106
+ if (this.sockets.size === 0)
107
+ for (const w of this.idleWaiters.splice(0))
108
+ w();
109
+ });
110
+ }
111
+ }
112
+ const disabledClient = {
113
+ enabled: false,
114
+ send() { },
115
+ close: () => Promise.resolve(),
116
+ };
117
+ /**
118
+ * Connects to the `quiesco` process named by QUIESCO_EVENTS and sends `hello`. Events sent before the
119
+ * connection is up are buffered by the socket. The connection does not keep the process alive.
120
+ */
121
+ export function connectRunEvents(options) {
122
+ const address = (options.env ?? process.env)[RUN_EVENTS_ENV];
123
+ if (address === undefined || address === '')
124
+ return disabledClient;
125
+ const warn = options.warn ?? ((m) => process.stderr.write(`quiesco: ${m}\n`));
126
+ let failed = false;
127
+ let closing = null;
128
+ const socket = net.createConnection(address);
129
+ socket.unref();
130
+ socket.on('error', (e) => {
131
+ if (failed)
132
+ return;
133
+ failed = true;
134
+ warn(`run events are not sent (progress / UI will not update): ${e.message}`);
135
+ socket.destroy();
136
+ });
137
+ const client = {
138
+ get enabled() {
139
+ return !failed;
140
+ },
141
+ send(event) {
142
+ if (failed || closing !== null || socket.destroyed)
143
+ return;
144
+ socket.write(encodeRunEvent(event));
145
+ },
146
+ close() {
147
+ closing ??= new Promise((resolve) => {
148
+ if (failed || socket.destroyed)
149
+ return resolve();
150
+ // Unref'd so a forgotten client never holds the runner open; while flushing, keep the process alive.
151
+ socket.ref();
152
+ socket.once('close', () => resolve());
153
+ socket.end();
154
+ });
155
+ return closing;
156
+ },
157
+ };
158
+ client.send({ type: 'hello', protocol: RUN_EVENTS_PROTOCOL, runner: options.runner, pid: process.pid, ...(options.runnerVersion !== undefined ? { runnerVersion: options.runnerVersion } : {}) });
159
+ return client;
160
+ }
161
+ //# sourceMappingURL=run-events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-events.js","sourceRoot":"","sources":["../src/run-events.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,EAAE,MAAM,SAAS,CAAC;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estList } from '@quiesco/protocol';
2
+ export interface ListTestsOptions {
3
+ runner: RunnerName;
4
+ /** The project directory. */
5
+ cwd: string;
6
+ /** Runner arguments: `--config <file>`, paths / filters (cucumber also `--profile`). */
7
+ args?: readonly string[];
8
+ env?: NodeJS.ProcessEnv;
9
+ }
10
+ /** Where the project's @quiesco/<runner>/list is; null when that adapter is not installed. */
11
+ export declare function listEntry(runner: RunnerName, cwd: string): string | null;
12
+ export declare function listTests(options: ListTestsOptions): Promise<TestList>;
13
+ //# sourceMappingURL=run-list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-list.d.ts","sourceRoot":"","sources":["../src/run-list.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE9D,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,UAAU,CAAC;IACnB,6BAA6B;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,wFAAwF;IACxF,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CACzB;AAED,8FAA8F;AAC9F,wBAAgB,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMxE;AAED,wBAAsB,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAuB5E"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * List the tests a runner would run, without running them (`quiesco list`, the UI's test tree): runs
3
+ * the project's own `@quiesco/<runner>/list` in a child process (it loads the project's runner) and
4
+ * reads back the TestList it writes.
5
+ */
6
+ import { spawn } from 'node:child_process';
7
+ import fs from 'node:fs';
8
+ import { createRequire } from 'node:module';
9
+ import os from 'node:os';
10
+ import path from 'node:path';
11
+ /** Where the project's @quiesco/<runner>/list is; null when that adapter is not installed. */
12
+ export function listEntry(runner, cwd) {
13
+ try {
14
+ return createRequire(path.join(cwd, 'package.json')).resolve(`@quiesco/${runner}/list`);
15
+ }
16
+ catch {
17
+ return null;
18
+ }
19
+ }
20
+ export async function listTests(options) {
21
+ const { runner, cwd } = options;
22
+ const entry = listEntry(runner, cwd);
23
+ if (entry === null)
24
+ return { runner, files: [], tests: [], errors: [{ message: `@quiesco/${runner} is not installed in ${cwd} (or is older than 0.3.0)` }] };
25
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'quiesco-list-'));
26
+ const out = path.join(dir, 'list.json');
27
+ let stderr = '';
28
+ try {
29
+ const code = await new Promise((resolve) => {
30
+ const child = spawn(process.execPath, [entry, '--out', out, ...(options.args ?? [])], { cwd, env: options.env ?? process.env, stdio: ['ignore', 'ignore', 'pipe'] });
31
+ child.stderr.setEncoding('utf8').on('data', (d) => (stderr += d));
32
+ child.on('error', () => resolve(127));
33
+ child.on('close', resolve);
34
+ });
35
+ try {
36
+ return JSON.parse(fs.readFileSync(out, 'utf8'));
37
+ }
38
+ catch {
39
+ const tail = stderr.trim().split('\n').slice(-5).join('\n');
40
+ return { runner, files: [], tests: [], errors: [{ message: `listing the ${runner} tests failed (exit ${code})${tail !== '' ? `:\n${tail}` : ''}` }] };
41
+ }
42
+ }
43
+ finally {
44
+ fs.rmSync(dir, { recursive: true, force: true });
45
+ }
46
+ }
47
+ //# sourceMappingURL=run-list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-list.js","sourceRoot":"","sources":["../src/run-list.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAa7B,8FAA8F;AAC9F,MAAM,UAAU,SAAS,CAAC,MAAkB,EAA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AC,EAAE,CAAC,CAAC;YACrK,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC;YAC1E,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;YACtC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;QACH,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,CAAa,CAAC;QAC9D,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC5D,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,eAAe,MAAM,uBAAuB,IAAI,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC;QACxJ,CAAC;IACH,CAAC;YAAS,CAAC;QACT,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACnD,CAAC;AACH,CAAC"}
@@ -0,0 +1,81 @@
1
+ import type { RunCounts, RunError, RunEvent, RunnerName, TestRef, TestStatus } from '@quiesco/protocol';
2
+ export interface TestState {
3
+ test: TestRef;
4
+ status: TestStatus | 'running' | 'queued';
5
+ durationMs?: number;
6
+ error?: RunError;
7
+ logs?: readonly {
8
+ stream: 'stdout' | 'stderr';
9
+ text: string;
10
+ }[];
11
+ /** Absolute paths of Quiesco's evidence files (screenshot, element tree, …). */
12
+ evidence?: readonly string[];
13
+ worker?: number;
14
+ attempt?: number;
15
+ startedAt?: number;
16
+ }
17
+ export interface RunningTest {
18
+ test: TestRef;
19
+ worker?: number;
20
+ startedAt: number;
21
+ }
22
+ export type RunPhase = 'idle' | 'running' | 'ended';
23
+ /** A RunState as plain JSON (`quiesco ui` sends it to a browser that connects mid-run). */
24
+ export interface RunStateSnapshot {
25
+ phase: RunPhase;
26
+ runner: RunnerName | null;
27
+ reportedTotal: number;
28
+ totalIsEstimate: boolean;
29
+ workers?: number;
30
+ files: string[];
31
+ counts: RunCounts;
32
+ done: number;
33
+ running: RunningTest[];
34
+ tests: TestState[];
35
+ fileErrors: [string, RunError][];
36
+ runErrors: RunError[];
37
+ success: boolean | null;
38
+ interrupted: boolean;
39
+ startedAt: number | null;
40
+ endedAt: number | null;
41
+ }
42
+ export declare class RunState {
43
+ private readonly now;
44
+ phase: RunPhase;
45
+ runner: RunnerName | null;
46
+ /** As told by the runner (exact, an estimate, or what is known so far). See `total`. */
47
+ reportedTotal: number;
48
+ totalIsEstimate: boolean;
49
+ workers: number | undefined;
50
+ files: string[];
51
+ counts: RunCounts;
52
+ /** Tests that finished in this run (retries count once, when they stop retrying). */
53
+ done: number;
54
+ readonly running: Map<string, RunningTest>;
55
+ /** Every test seen, by id, also from earlier runs. */
56
+ readonly tests: Map<string, TestState>;
57
+ readonly fileErrors: Map<string, RunError>;
58
+ readonly runErrors: RunError[];
59
+ success: boolean | null;
60
+ interrupted: boolean;
61
+ /** Epoch ms of `run:start` / `run:end` as seen by this process. */
62
+ startedAt: number | null;
63
+ endedAt: number | null;
64
+ /** Evidence that arrived before its test ended (the worker can be faster than the reporter). */
65
+ private readonly earlyEvidence;
66
+ constructor(now?: () => number);
67
+ /** Never below what is already done or running. */
68
+ get total(): number;
69
+ /** The total is not final yet (estimate, or Jest still finding tests). */
70
+ get totalIsApproximate(): boolean;
71
+ get elapsedMs(): number;
72
+ apply(event: RunEvent): void;
73
+ snapshot(): RunStateSnapshot;
74
+ static fromSnapshot(s: RunStateSnapshot, now?: () => number): RunState;
75
+ /** The runner process exited (maybe without `run:end`: crash, Ctrl-C). */
76
+ runnerExited(code: number): void;
77
+ private start;
78
+ private end;
79
+ private finish;
80
+ }
81
+ //# sourceMappingURL=run-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-state.d.ts","sourceRoot":"","sources":["../src/run-state.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAc,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,UAAU,GAAG,SAAS,GAAG,QAAQ,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,IAAI,CAAC,EAAE,SAAS;QAAE,MAAM,EAAE,QAAQ,GAAG,QAAQ,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAChE,gFAAgF;IAChF,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;AAEpD,2FAA2F;AAC3F,MAAM,WAAW,gBAAgB;I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MAAM,GAAG,IAAI,CAAQ;IAC9B,gGAAgG;IAChG,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAwC;gBAEzC,GAAG,GAAE,MAAM,MAAiB;IAEzD,mDAAmD;IACnD,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,0EAA0E;IAC1E,IAAI,kBAAkB,IAAI,OAAO,CAEhC;IAED,IAAI,SAAS,IAAI,MAAM,CAGtB;IAED,KAAK,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;IAuC5B,QAAQ,IAAI,gBAAgB;IAqB5B,MAAM,CAAC,YAAY,CAAC,CAAC,EAAE,gBAAgB,EAAE,GAAG,GAAE,MAAM,MAAiB,GAAG,QAAQ;IAqBhF,0EAA0E;IAC1E,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAKhC,OAAO,CAAC,KAAK;IAkBb,OAAO,CAAC,GAAG;IAsBX,OAAO,CAAC,MAAM;CAcf"}
@@ -0,0 +1,196 @@
1
+ /**
2
+ * The state of a run, built from run events (`@quiesco/protocol` run-events): what the progress bar and
3
+ * `quiesco ui` show. Pure: feed it events with `apply()`, read it back.
4
+ *
5
+ * Several runs in a row (the UI runs again) start over at each `run:start`, keeping what was learned
6
+ * about tests not in the new run.
7
+ */
8
+ import { emptyCounts } from '@quiesco/protocol';
9
+ export class RunState {
10
+ now;
11
+ phase = 'idle';
12
+ runner = null;
13
+ /** As told by the runner (exact, an estimate, or what is known so far). See `total`. */
14
+ reportedTotal = 0;
15
+ totalIsEstimate = false;
16
+ workers;
17
+ files = [];
18
+ counts = emptyCounts();
19
+ /** Tests that finished in this run (retries count once, when they stop retrying). */
20
+ done = 0;
21
+ running = new Map();
22
+ /** Every test seen, by id, also from earlier runs. */
23
+ tests = new Map();
24
+ fileErrors = new Map();
25
+ runErrors = [];
26
+ success = null;
27
+ interrupted = false;
28
+ /** Epoch ms of `run:start` / `run:end` as seen by this process. */
29
+ startedAt = null;
30
+ endedAt = null;
31
+ /** Evidence that arrived before its test ended (the worker can be faster than the reporter). */
32
+ earlyEvidence = new Map();
33
+ constructor(now = Date.now) {
34
+ this.now = now;
35
+ }
36
+ /** Never below what is already done or running. */
37
+ get total() {
38
+ return Math.max(this.reportedTotal, this.done + this.running.size);
39
+ }
40
+ /** The total is not final yet (estimate, or Jest still finding tests). */
41
+ get totalIsApproximate() {
42
+ return this.totalIsEstimate && this.phase !== 'ended';
43
+ }
44
+ get elapsedMs() {
45
+ if (this.startedAt === null)
46
+ return 0;
47
+ return (this.endedAt ?? this.now()) - this.startedAt;
48
+ }
49
+ apply(event) {
50
+ switch (event.type) {
51
+ case 'hello':
52
+ this.runner = event.runner;
53
+ break;
54
+ case 'run:start':
55
+ this.start(event);
56
+ break;
57
+ case 'total:update':
58
+ this.reportedTotal = event.total;
59
+ this.totalIsEstimate = event.totalIsEstimate;
60
+ break;
61
+ case 'file:start':
62
+ break;
63
+ case 'file:end':
64
+ if (event.error !== undefined)
65
+ this.fileErrors.set(event.file, event.error);
66
+ break;
67
+ case 'test:start':
68
+ this.running.set(event.test.id, { test: event.test, startedAt: event.startedAt, ...(event.worker !== undefined ? { worker: event.worker } : {}) });
69
+ this.tests.set(event.test.id, { ...this.tests.get(event.test.id), test: event.test, status: 'running', attempt: event.attempt, startedAt: event.startedAt, ...(event.worker !== undefined ? { worker: event.worker } : {}) });
70
+ break;
71
+ case 'test:end':
72
+ this.end(event);
73
+ break;
74
+ case 'test:evidence': {
75
+ const t = this.tests.get(event.testId);
76
+ if (t !== undefined && t.status !== 'running')
77
+ t.evidence = event.files;
78
+ else
79
+ this.earlyEvidence.set(event.testId, event.files);
80
+ break;
81
+ }
82
+ case 'run:error':
83
+ this.runErrors.push(event.error);
84
+ break;
85
+ case 'run:end':
86
+ this.finish(event.success, event.interrupted);
87
+ break;
88
+ }
89
+ }
90
+ snapshot() {
91
+ return {
92
+ phase: this.phase,
93
+ runner: this.runner,
94
+ reportedTotal: this.reportedTotal,
95
+ totalIsEstimate: this.totalIsEstimate,
96
+ ...(this.workers !== undefined ? { workers: this.workers } : {}),
97
+ files: [...this.files],
98
+ counts: { ...this.counts },
99
+ done: this.done,
100
+ running: [...this.running.values()],
101
+ tests: [...this.tests.values()],
102
+ fileErrors: [...this.fileErrors],
103
+ runErrors: [...this.runErrors],
104
+ success: this.success,
105
+ interrupted: this.interrupted,
106
+ startedAt: this.startedAt,
107
+ endedAt: this.endedAt,
108
+ };
109
+ }
110
+ static fromSnapshot(s, now = Date.now) {
111
+ const state = new RunState(now);
112
+ state.phase = s.phase;
113
+ state.runner = s.runner;
114
+ state.reportedTotal = s.reportedTotal;
115
+ state.totalIsEstimate = s.totalIsEstimate;
116
+ state.workers = s.workers;
117
+ state.files = [...s.files];
118
+ state.counts = { ...s.counts };
119
+ state.done = s.done;
120
+ for (const r of s.running)
121
+ state.running.set(r.test.id, r);
122
+ for (const t of s.tests)
123
+ state.tests.set(t.test.id, t);
124
+ for (const [file, e] of s.fileErrors)
125
+ state.fileErrors.set(file, e);
126
+ state.runErrors.push(...s.runErrors);
127
+ state.success = s.success;
128
+ state.interrupted = s.interrupted;
129
+ state.startedAt = s.startedAt;
130
+ state.endedAt = s.endedAt;
131
+ return state;
132
+ }
133
+ /** The runner process exited (maybe without `run:end`: crash, Ctrl-C). */
134
+ runnerExited(code) {
135
+ if (this.phase === 'ended')
136
+ return;
137
+ this.finish(code === 0, code === 130 || code === 143);
138
+ }
139
+ start(e) {
140
+ this.phase = 'running';
141
+ this.reportedTotal = e.total;
142
+ this.totalIsEstimate = e.totalIsEstimate;
143
+ this.workers = e.workers;
144
+ this.files = [...e.files];
145
+ this.counts = emptyCounts();
146
+ this.done = 0;
147
+ this.running.clear();
148
+ this.fileErrors.clear();
149
+ this.runErrors.length = 0;
150
+ this.earlyEvidence.clear();
151
+ this.success = null;
152
+ this.interrupted = false;
153
+ this.startedAt = this.now();
154
+ this.endedAt = null;
155
+ }
156
+ end(e) {
157
+ this.running.delete(e.test.id);
158
+ const prev = this.tests.get(e.test.id);
159
+ const evidence = this.earlyEvidence.get(e.test.id);
160
+ this.earlyEvidence.delete(e.test.id);
161
+ const state = {
162
+ test: { ...prev?.test, ...e.test },
163
+ status: e.willRetry ? 'queued' : e.status,
164
+ durationMs: e.durationMs,
165
+ ...(e.error !== undefined ? { error: e.error } : {}),
166
+ ...(e.logs !== undefined ? { logs: e.logs } : {}),
167
+ ...(evidence !== undefined ? { evidence } : {}),
168
+ ...(e.worker !== undefined ? { worker: e.worker } : prev?.worker !== undefined ? { worker: prev.worker } : {}),
169
+ ...(prev?.attempt !== undefined ? { attempt: prev.attempt } : {}),
170
+ ...(prev?.startedAt !== undefined ? { startedAt: prev.startedAt } : {}),
171
+ };
172
+ this.tests.set(e.test.id, state);
173
+ if (e.willRetry)
174
+ return;
175
+ this.done++;
176
+ this.counts[e.status]++;
177
+ }
178
+ finish(success, interrupted) {
179
+ if (this.phase === 'idle')
180
+ this.startedAt = this.now();
181
+ for (const [id, r] of this.running) {
182
+ const t = this.tests.get(id);
183
+ if (t !== undefined)
184
+ t.status = 'notRun';
185
+ else
186
+ this.tests.set(id, { test: r.test, status: 'notRun' });
187
+ this.counts.notRun++;
188
+ }
189
+ this.running.clear();
190
+ this.phase = 'ended';
191
+ this.success = success && this.counts.failed === 0 && this.runErrors.length === 0 && this.fileErrors.size === 0;
192
+ this.interrupted = interrupted;
193
+ this.endedAt = this.now();
194
+ }
195
+ }
196
+ //# sourceMappingURL=run-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-state.js","sourceRoot":"","sources":["../src/run-state.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AA4ChD,MAAM,OAAO,QAAQ;IAwBU;IAvB7B,KAAK,GAAa,MAAM,CAAC;IACzB,MAAM,GAAsB,IAAI,CAAC;IACjC,wFAAwF;IACxF,aAAa,GAAG,CAAC,CAAC;IAClB,eAAe,GAAG,KAAK,CAAC;IACxB,OAAO,CAAqB;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I,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;YAC5D,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QACvB,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,CAAC;QAChH,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC5B,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quiesco/core",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Quiesco host side: WebSocket server, Driver, device providers (test-runner agnostic)",
5
5
  "license": "MIT",
6
6
  "author": "h2nology",
@@ -36,6 +36,10 @@
36
36
  ".": {
37
37
  "types": "./dist/index.d.ts",
38
38
  "import": "./dist/index.js"
39
+ },
40
+ "./run-state": {
41
+ "types": "./dist/run-state.d.ts",
42
+ "import": "./dist/run-state.js"
39
43
  }
40
44
  },
41
45
  "files": [
@@ -46,7 +50,7 @@
46
50
  "ios-runner/QuiescoSystemUI.xcodeproj"
47
51
  ],
48
52
  "dependencies": {
49
- "@quiesco/protocol": "0.2.0",
53
+ "@quiesco/protocol": "0.3.0",
50
54
  "ws": "8.22.1"
51
55
  },
52
56
  "devDependencies": {
package/src/index.ts CHANGED
@@ -47,3 +47,11 @@ export { LogBuffer, killChildProcessesSync, trackChildProcess, trackedChildPids
47
47
  export { SERIAL_WORKER } from './devices/provider.js';
48
48
  export { WORKER_SIMULATOR, workerSimulatorName } from './devices/ios.js';
49
49
  export { CPU_GPU_MODES, WORKER_AVD, emulatorGpu, workerAvdName } from './devices/android.js';
50
+ export { RunEventServer, connectRunEvents, runEventsAddress } from './run-events.js';
51
+ export type { ConnectOptions, RunEventClient, RunEventServerOptions } from './run-events.js';
52
+ export { RUN_EVENTS_ENV, RUN_EVENTS_PROTOCOL, createRunEventDecoder, emptyCounts, encodeRunEvent, isRunEvent } from '@quiesco/protocol';
53
+ export type { RunCounts, RunError, RunEvent, RunEventOf, RunEventType, RunEvents, RunnerName, TestList, TestRef, TestStatus } from '@quiesco/protocol';
54
+ export { RunState } from './run-state.js';
55
+ export type { RunPhase, RunStateSnapshot, RunningTest, TestState } from './run-state.js';
56
+ export { listEntry, listTests } from './run-list.js';
57
+ export type { ListTestsOptions } from './run-list.js';
@@ -0,0 +1,185 @@
1
+ /**
2
+ * Transport of run events (`@quiesco/protocol` run-events) between a runner's Quiesco reporter and the
3
+ * `quiesco` process: a local socket (Unix socket file, or a named pipe on Windows) carrying NDJSON.
4
+ *
5
+ * - The CLI starts a RunEventServer and passes `server.env()` to the runner it spawns.
6
+ * - Reporters (and workers adding evidence) call `connectRunEvents()`: without QUIESCO_EVENTS it
7
+ * returns a client that sends nothing, so running the runner directly is unaffected.
8
+ * - A broken connection never fails a test: the client warns once and drops further events.
9
+ */
10
+ import { randomBytes } from 'node:crypto';
11
+ import { chmodSync } from 'node:fs';
12
+ import net from 'node:net';
13
+ import os from 'node:os';
14
+ import path from 'node:path';
15
+
16
+ import { RUN_EVENTS_ENV, RUN_EVENTS_PROTOCOL, createRunEventDecoder, encodeRunEvent } from '@quiesco/protocol';
17
+ import type { RunEvent, RunnerName } from '@quiesco/protocol';
18
+
19
+ /** Longest Unix socket path that works everywhere (sun_path is 104 bytes on macOS, 108 on Linux). */
20
+ const MAX_SOCKET_PATH = 100;
21
+
22
+ /** A fresh socket address for this process. */
23
+ export function runEventsAddress(platform: NodeJS.Platform = process.platform, tmpdir: string = os.tmpdir()): string {
24
+ const name = `quiesco-${process.pid}-${randomBytes(4).toString('hex')}`;
25
+ if (platform === 'win32') return `\\\\.\\pipe\\${name}`;
26
+ const file = path.join(tmpdir, `${name}.sock`);
27
+ // A long TMPDIR (some CI images) would make the path too long for a Unix socket.
28
+ return file.length <= MAX_SOCKET_PATH ? file : path.join('/tmp', `${name}.sock`);
29
+ }
30
+
31
+ export interface RunEventServerOptions {
32
+ /** Each decoded event, with the connection it came on (1, 2, …). */
33
+ onEvent: (event: RunEvent, connection: number) => void;
34
+ /** A line that is not a known run event (skipped). */
35
+ onInvalid?: (line: string, reason: string) => void;
36
+ /** Default: runEventsAddress(). */
37
+ address?: string;
38
+ }
39
+
40
+ export class RunEventServer {
41
+ private readonly server: net.Server;
42
+ private readonly sockets = new Set<net.Socket>();
43
+ private readonly idleWaiters: (() => void)[] = [];
44
+ private nextConnection = 1;
45
+ private listening = false;
46
+ readonly address: string;
47
+ /** The runners that said hello (a reporter is wired in). */
48
+ readonly hellos: { runner: RunnerName; protocol: number; connection: number }[] = [];
49
+
50
+ constructor(private readonly options: RunEventServerOptions) {
51
+ this.address = options.address ?? runEventsAddress();
52
+ this.server = net.createServer((socket) => this.accept(socket));
53
+ }
54
+
55
+ async listen(): Promise<string> {
56
+ await new Promise<void>((resolve, reject) => {
57
+ this.server.once('error', reject);
58
+ this.server.listen(this.address, () => {
59
+ this.server.off('error', reject);
60
+ resolve();
61
+ });
62
+ });
63
+ this.listening = true;
64
+ // Only this user may connect (the socket file is created with the process umask).
65
+ if (process.platform !== 'win32') chmodSync(this.address, 0o600);
66
+ return this.address;
67
+ }
68
+
69
+ /** Environment for the runner process. */
70
+ env(): Record<string, string> {
71
+ return { [RUN_EVENTS_ENV]: this.address };
72
+ }
73
+
74
+ /** Number of open connections. */
75
+ get connections(): number {
76
+ return this.sockets.size;
77
+ }
78
+
79
+ /**
80
+ * Resolves once no connection is open, or after `timeoutMs`. Called after the runner exits: its
81
+ * last events may still be in flight on a connection that is closing.
82
+ */
83
+ async drain(timeoutMs = 2000): Promise<void> {
84
+ if (this.sockets.size === 0) return;
85
+ await new Promise<void>((resolve) => {
86
+ const timer = setTimeout(done, timeoutMs);
87
+ timer.unref();
88
+ function done() {
89
+ clearTimeout(timer);
90
+ resolve();
91
+ }
92
+ this.idleWaiters.push(done);
93
+ });
94
+ }
95
+
96
+ /** Stops listening, closes the connections still open and removes the socket file. */
97
+ async close(): Promise<void> {
98
+ for (const s of this.sockets) s.destroy();
99
+ this.sockets.clear();
100
+ if (!this.listening) return;
101
+ this.listening = false;
102
+ // net.Server removes its Unix socket file on close.
103
+ await new Promise<void>((resolve) => this.server.close(() => resolve()));
104
+ }
105
+
106
+ private accept(socket: net.Socket): void {
107
+ const connection = this.nextConnection++;
108
+ this.sockets.add(socket);
109
+ socket.setEncoding('utf8');
110
+ const decoder = createRunEventDecoder((event) => {
111
+ if (event.type === 'hello') this.hellos.push({ runner: event.runner, protocol: event.protocol, connection });
112
+ this.options.onEvent(event, connection);
113
+ }, this.options.onInvalid);
114
+ socket.on('data', (chunk: string) => decoder.push(chunk));
115
+ socket.on('end', () => decoder.end());
116
+ socket.on('error', () => {});
117
+ socket.on('close', () => {
118
+ this.sockets.delete(socket);
119
+ if (this.sockets.size === 0) for (const w of this.idleWaiters.splice(0)) w();
120
+ });
121
+ }
122
+ }
123
+
124
+ export interface RunEventClient {
125
+ /** False when QUIESCO_EVENTS is not set or the connection failed: send() does nothing. */
126
+ readonly enabled: boolean;
127
+ send(event: RunEvent): void;
128
+ /** Flushes and closes the connection. Safe to call more than once. */
129
+ close(): Promise<void>;
130
+ }
131
+
132
+ const disabledClient: RunEventClient = {
133
+ enabled: false,
134
+ send() {},
135
+ close: () => Promise.resolve(),
136
+ };
137
+
138
+ export interface ConnectOptions {
139
+ runner: RunnerName;
140
+ runnerVersion?: string;
141
+ env?: NodeJS.ProcessEnv;
142
+ /** Told once when the connection fails. Default: a line on stderr. */
143
+ warn?: (message: string) => void;
144
+ }
145
+
146
+ /**
147
+ * Connects to the `quiesco` process named by QUIESCO_EVENTS and sends `hello`. Events sent before the
148
+ * connection is up are buffered by the socket. The connection does not keep the process alive.
149
+ */
150
+ export function connectRunEvents(options: ConnectOptions): RunEventClient {
151
+ const address = (options.env ?? process.env)[RUN_EVENTS_ENV];
152
+ if (address === undefined || address === '') return disabledClient;
153
+ const warn = options.warn ?? ((m: string) => process.stderr.write(`quiesco: ${m}\n`));
154
+ let failed = false;
155
+ let closing: Promise<void> | null = null;
156
+ const socket = net.createConnection(address);
157
+ socket.unref();
158
+ socket.on('error', (e) => {
159
+ if (failed) return;
160
+ failed = true;
161
+ warn(`run events are not sent (progress / UI will not update): ${e.message}`);
162
+ socket.destroy();
163
+ });
164
+ const client: RunEventClient = {
165
+ get enabled() {
166
+ return !failed;
167
+ },
168
+ send(event) {
169
+ if (failed || closing !== null || socket.destroyed) return;
170
+ socket.write(encodeRunEvent(event));
171
+ },
172
+ close() {
173
+ closing ??= new Promise<void>((resolve) => {
174
+ if (failed || socket.destroyed) return resolve();
175
+ // Unref'd so a forgotten client never holds the runner open; while flushing, keep the process alive.
176
+ socket.ref();
177
+ socket.once('close', () => resolve());
178
+ socket.end();
179
+ });
180
+ return closing;
181
+ },
182
+ };
183
+ client.send({ type: 'hello', protocol: RUN_EVENTS_PROTOCOL, runner: options.runner, pid: process.pid, ...(options.runnerVersion !== undefined ? { runnerVersion: options.runnerVersion } : {}) });
184
+ return client;
185
+ }
@@ -0,0 +1,55 @@
1
+ /**
2
+ * List the tests a runner would run, without running them (`quiesco list`, the UI's test tree): runs
3
+ * the project's own `@quiesco/<runner>/list` in a child process (it loads the project's runner) and
4
+ * reads back the TestList it writes.
5
+ */
6
+ import { spawn } from 'node:child_process';
7
+ import fs from 'node:fs';
8
+ import { createRequire } from 'node:module';
9
+ import os from 'node:os';
10
+ import path from 'node:path';
11
+
12
+ import type { RunnerName, TestList } from '@quiesco/protocol';
13
+
14
+ export interface ListTestsOptions {
15
+ runner: RunnerName;
16
+ /** The project directory. */
17
+ cwd: string;
18
+ /** Runner arguments: `--config <file>`, paths / filters (cucumber also `--profile`). */
19
+ args?: readonly string[];
20
+ env?: NodeJS.ProcessEnv;
21
+ }
22
+
23
+ /** Where the project's @quiesco/<runner>/list is; null when that adapter is not installed. */
24
+ export function listEntry(runner: RunnerName, cwd: string): string | null {
25
+ try {
26
+ return createRequire(path.join(cwd, 'package.json')).resolve(`@quiesco/${runner}/list`);
27
+ } catch {
28
+ return null;
29
+ }
30
+ }
31
+
32
+ export async function listTests(options: ListTestsOptions): Promise<TestList> {
33
+ const { runner, cwd } = options;
34
+ const entry = listEntry(runner, cwd);
35
+ if (entry === null) return { runner, files: [], tests: [], errors: [{ message: `@quiesco/${runner} is not installed in ${cwd} (or is older than 0.3.0)` }] };
36
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'quiesco-list-'));
37
+ const out = path.join(dir, 'list.json');
38
+ let stderr = '';
39
+ try {
40
+ const code = await new Promise<number | null>((resolve) => {
41
+ const child = spawn(process.execPath, [entry, '--out', out, ...(options.args ?? [])], { cwd, env: options.env ?? process.env, stdio: ['ignore', 'ignore', 'pipe'] });
42
+ child.stderr.setEncoding('utf8').on('data', (d: string) => (stderr += d));
43
+ child.on('error', () => resolve(127));
44
+ child.on('close', resolve);
45
+ });
46
+ try {
47
+ return JSON.parse(fs.readFileSync(out, 'utf8')) as TestList;
48
+ } catch {
49
+ const tail = stderr.trim().split('\n').slice(-5).join('\n');
50
+ return { runner, files: [], tests: [], errors: [{ message: `listing the ${runner} tests failed (exit ${code})${tail !== '' ? `:\n${tail}` : ''}` }] };
51
+ }
52
+ } finally {
53
+ fs.rmSync(dir, { recursive: true, force: true });
54
+ }
55
+ }
@@ -0,0 +1,234 @@
1
+ /**
2
+ * The state of a run, built from run events (`@quiesco/protocol` run-events): what the progress bar and
3
+ * `quiesco ui` show. Pure: feed it events with `apply()`, read it back.
4
+ *
5
+ * Several runs in a row (the UI runs again) start over at each `run:start`, keeping what was learned
6
+ * about tests not in the new run.
7
+ */
8
+ import { emptyCounts } from '@quiesco/protocol';
9
+ import type { RunCounts, RunError, RunEvent, RunEventOf, RunnerName, TestRef, TestStatus } from '@quiesco/protocol';
10
+
11
+ export interface TestState {
12
+ test: TestRef;
13
+ status: TestStatus | 'running' | 'queued';
14
+ durationMs?: number;
15
+ error?: RunError;
16
+ logs?: readonly { stream: 'stdout' | 'stderr'; text: string }[];
17
+ /** Absolute paths of Quiesco's evidence files (screenshot, element tree, …). */
18
+ evidence?: readonly string[];
19
+ worker?: number;
20
+ attempt?: number;
21
+ startedAt?: number;
22
+ }
23
+
24
+ export interface RunningTest {
25
+ test: TestRef;
26
+ worker?: number;
27
+ startedAt: number;
28
+ }
29
+
30
+ export type RunPhase = 'idle' | 'running' | 'ended';
31
+
32
+ /** A RunState as plain JSON (`quiesco ui` sends it to a browser that connects mid-run). */
33
+ export interface RunStateSnapshot {
34
+ phase: RunPhase;
35
+ runner: RunnerName | null;
36
+ reportedTotal: number;
37
+ totalIsEstimate: boolean;
38
+ workers?: number;
39
+ files: string[];
40
+ counts: RunCounts;
41
+ done: number;
42
+ running: RunningTest[];
43
+ tests: TestState[];
44
+ fileErrors: [string, RunError][];
45
+ runErrors: RunError[];
46
+ success: boolean | null;
47
+ interrupted: boolean;
48
+ startedAt: number | null;
49
+ endedAt: number | null;
50
+ }
51
+
52
+ export class RunState {
53
+ phase: RunPhase = 'idle';
54
+ runner: RunnerName | null = null;
55
+ /** As told by the runner (exact, an estimate, or what is known so far). See `total`. */
56
+ reportedTotal = 0;
57
+ totalIsEstimate = false;
58
+ workers: number | undefined;
59
+ files: string[] = [];
60
+ counts: RunCounts = emptyCounts();
61
+ /** Tests that finished in this run (retries count once, when they stop retrying). */
62
+ done = 0;
63
+ readonly running = new Map<string, RunningTest>();
64
+ /** Every test seen, by id, also from earlier runs. */
65
+ readonly tests = new Map<string, TestState>();
66
+ readonly fileErrors = new Map<string, RunError>();
67
+ readonly runErrors: RunError[] = [];
68
+ success: boolean | null = null;
69
+ interrupted = false;
70
+ /** Epoch ms of `run:start` / `run:end` as seen by this process. */
71
+ startedAt: number | null = null;
72
+ endedAt: number | null = null;
73
+ /** Evidence that arrived before its test ended (the worker can be faster than the reporter). */
74
+ private readonly earlyEvidence = new Map<string, readonly string[]>();
75
+
76
+ constructor(private readonly now: () => number = Date.now) {}
77
+
78
+ /** Never below what is already done or running. */
79
+ get total(): number {
80
+ return Math.max(this.reportedTotal, this.done + this.running.size);
81
+ }
82
+
83
+ /** The total is not final yet (estimate, or Jest still finding tests). */
84
+ get totalIsApproximate(): boolean {
85
+ return this.totalIsEstimate && this.phase !== 'ended';
86
+ }
87
+
88
+ get elapsedMs(): number {
89
+ if (this.startedAt === null) return 0;
90
+ return (this.endedAt ?? this.now()) - this.startedAt;
91
+ }
92
+
93
+ apply(event: RunEvent): void {
94
+ switch (event.type) {
95
+ case 'hello':
96
+ this.runner = event.runner;
97
+ break;
98
+ case 'run:start':
99
+ this.start(event);
100
+ break;
101
+ case 'total:update':
102
+ this.reportedTotal = event.total;
103
+ this.totalIsEstimate = event.totalIsEstimate;
104
+ break;
105
+ case 'file:start':
106
+ break;
107
+ case 'file:end':
108
+ if (event.error !== undefined) this.fileErrors.set(event.file, event.error);
109
+ break;
110
+ case 'test:start':
111
+ this.running.set(event.test.id, { test: event.test, startedAt: event.startedAt, ...(event.worker !== undefined ? { worker: event.worker } : {}) });
112
+ this.tests.set(event.test.id, { ...this.tests.get(event.test.id), test: event.test, status: 'running', attempt: event.attempt, startedAt: event.startedAt, ...(event.worker !== undefined ? { worker: event.worker } : {}) });
113
+ break;
114
+ case 'test:end':
115
+ this.end(event);
116
+ break;
117
+ case 'test:evidence': {
118
+ const t = this.tests.get(event.testId);
119
+ if (t !== undefined && t.status !== 'running') t.evidence = event.files;
120
+ else this.earlyEvidence.set(event.testId, event.files);
121
+ break;
122
+ }
123
+ case 'run:error':
124
+ this.runErrors.push(event.error);
125
+ break;
126
+ case 'run:end':
127
+ this.finish(event.success, event.interrupted);
128
+ break;
129
+ }
130
+ }
131
+
132
+ snapshot(): RunStateSnapshot {
133
+ return {
134
+ phase: this.phase,
135
+ runner: this.runner,
136
+ reportedTotal: this.reportedTotal,
137
+ totalIsEstimate: this.totalIsEstimate,
138
+ ...(this.workers !== undefined ? { workers: this.workers } : {}),
139
+ files: [...this.files],
140
+ counts: { ...this.counts },
141
+ done: this.done,
142
+ running: [...this.running.values()],
143
+ tests: [...this.tests.values()],
144
+ fileErrors: [...this.fileErrors],
145
+ runErrors: [...this.runErrors],
146
+ success: this.success,
147
+ interrupted: this.interrupted,
148
+ startedAt: this.startedAt,
149
+ endedAt: this.endedAt,
150
+ };
151
+ }
152
+
153
+ static fromSnapshot(s: RunStateSnapshot, now: () => number = Date.now): RunState {
154
+ const state = new RunState(now);
155
+ state.phase = s.phase;
156
+ state.runner = s.runner;
157
+ state.reportedTotal = s.reportedTotal;
158
+ state.totalIsEstimate = s.totalIsEstimate;
159
+ state.workers = s.workers;
160
+ state.files = [...s.files];
161
+ state.counts = { ...s.counts };
162
+ state.done = s.done;
163
+ for (const r of s.running) state.running.set(r.test.id, r);
164
+ for (const t of s.tests) state.tests.set(t.test.id, t);
165
+ for (const [file, e] of s.fileErrors) state.fileErrors.set(file, e);
166
+ state.runErrors.push(...s.runErrors);
167
+ state.success = s.success;
168
+ state.interrupted = s.interrupted;
169
+ state.startedAt = s.startedAt;
170
+ state.endedAt = s.endedAt;
171
+ return state;
172
+ }
173
+
174
+ /** The runner process exited (maybe without `run:end`: crash, Ctrl-C). */
175
+ runnerExited(code: number): void {
176
+ if (this.phase === 'ended') return;
177
+ this.finish(code === 0, code === 130 || code === 143);
178
+ }
179
+
180
+ private start(e: RunEventOf<'run:start'>): void {
181
+ this.phase = 'running';
182
+ this.reportedTotal = e.total;
183
+ this.totalIsEstimate = e.totalIsEstimate;
184
+ this.workers = e.workers;
185
+ this.files = [...e.files];
186
+ this.counts = emptyCounts();
187
+ this.done = 0;
188
+ this.running.clear();
189
+ this.fileErrors.clear();
190
+ this.runErrors.length = 0;
191
+ this.earlyEvidence.clear();
192
+ this.success = null;
193
+ this.interrupted = false;
194
+ this.startedAt = this.now();
195
+ this.endedAt = null;
196
+ }
197
+
198
+ private end(e: RunEventOf<'test:end'>): void {
199
+ this.running.delete(e.test.id);
200
+ const prev = this.tests.get(e.test.id);
201
+ const evidence = this.earlyEvidence.get(e.test.id);
202
+ this.earlyEvidence.delete(e.test.id);
203
+ const state: TestState = {
204
+ test: { ...prev?.test, ...e.test },
205
+ status: e.willRetry ? 'queued' : e.status,
206
+ durationMs: e.durationMs,
207
+ ...(e.error !== undefined ? { error: e.error } : {}),
208
+ ...(e.logs !== undefined ? { logs: e.logs } : {}),
209
+ ...(evidence !== undefined ? { evidence } : {}),
210
+ ...(e.worker !== undefined ? { worker: e.worker } : prev?.worker !== undefined ? { worker: prev.worker } : {}),
211
+ ...(prev?.attempt !== undefined ? { attempt: prev.attempt } : {}),
212
+ ...(prev?.startedAt !== undefined ? { startedAt: prev.startedAt } : {}),
213
+ };
214
+ this.tests.set(e.test.id, state);
215
+ if (e.willRetry) return;
216
+ this.done++;
217
+ this.counts[e.status]++;
218
+ }
219
+
220
+ private finish(success: boolean, interrupted: boolean): void {
221
+ if (this.phase === 'idle') this.startedAt = this.now();
222
+ for (const [id, r] of this.running) {
223
+ const t = this.tests.get(id);
224
+ if (t !== undefined) t.status = 'notRun';
225
+ else this.tests.set(id, { test: r.test, status: 'notRun' });
226
+ this.counts.notRun++;
227
+ }
228
+ this.running.clear();
229
+ this.phase = 'ended';
230
+ this.success = success && this.counts.failed === 0 && this.runErrors.length === 0 && this.fileErrors.size === 0;
231
+ this.interrupted = interrupted;
232
+ this.endedAt = this.now();
233
+ }
234
+ }