@smoothbricks/nx-plugin 0.4.28 → 0.4.30
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/README.md +277 -89
- package/dist/bin/smoo-nx-test-clocks.d.ts +3 -0
- package/dist/bin/smoo-nx-test-clocks.d.ts.map +1 -0
- package/dist/bin/smoo-nx-test-clocks.js +28 -0
- package/dist/bounded-test-policy.d.ts +8 -8
- package/dist/bounded-test-policy.d.ts.map +1 -1
- package/dist/bounded-test-policy.js +18 -30
- package/dist/cargo-closure-input.d.ts +23 -0
- package/dist/cargo-closure-input.d.ts.map +1 -1
- package/dist/cargo-closure-input.js +41 -9
- package/dist/cargo-source-hash.d.ts.map +1 -1
- package/dist/cargo-source-hash.js +42 -19
- package/dist/ensure-built-receipt.d.ts +40 -6
- package/dist/ensure-built-receipt.d.ts.map +1 -1
- package/dist/ensure-built-receipt.js +297 -159
- package/dist/ensure-built-witness.d.ts +65 -4
- package/dist/ensure-built-witness.d.ts.map +1 -1
- package/dist/ensure-built-witness.js +2237 -23
- package/dist/ensure-built.d.ts +99 -1
- package/dist/ensure-built.d.ts.map +1 -1
- package/dist/ensure-built.js +45 -56
- package/dist/executors/bounded-exec/cpu-pool.d.ts +22 -7
- package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/cpu-pool.js +51 -22
- package/dist/executors/bounded-exec/executor.d.ts +12 -3
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +174 -51
- package/dist/executors/bounded-exec/no-space.d.ts +8 -0
- package/dist/executors/bounded-exec/no-space.d.ts.map +1 -0
- package/dist/executors/bounded-exec/no-space.js +31 -0
- package/dist/executors/bounded-exec/ram-temp.d.ts +20 -11
- package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -1
- package/dist/executors/bounded-exec/ram-temp.js +42 -17
- package/dist/executors/bounded-exec/verdict.d.ts +34 -4
- package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
- package/dist/executors/bounded-exec/verdict.js +54 -3
- package/dist/generators/bun-test-tracing/generator.js +2 -2
- package/dist/graph-input-contract.d.ts +102 -0
- package/dist/graph-input-contract.d.ts.map +1 -0
- package/dist/graph-input-contract.js +637 -0
- package/dist/index.d.ts +12 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -3
- package/dist/managed-files/ci-workflow.d.ts.map +1 -1
- package/dist/managed-files/ci-workflow.js +5 -2
- package/dist/managed-files/publish-workflow.d.ts +11 -1
- package/dist/managed-files/publish-workflow.d.ts.map +1 -1
- package/dist/owned-installation.d.ts +14 -0
- package/dist/owned-installation.d.ts.map +1 -0
- package/dist/owned-installation.js +324 -0
- package/dist/producer-receipts.d.ts +19 -0
- package/dist/producer-receipts.d.ts.map +1 -0
- package/dist/producer-receipts.js +926 -0
- package/dist/test-backstop.d.ts +9 -0
- package/dist/test-backstop.d.ts.map +1 -0
- package/dist/test-backstop.js +10 -0
- package/dist/test-clock-policy.d.ts +30 -0
- package/dist/test-clock-policy.d.ts.map +1 -0
- package/dist/test-clock-policy.js +686 -0
- package/dist/testing.d.ts +8 -0
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +66 -1
- package/managed/raw/patches/nx@23.2.1.patch +328 -50
- package/managed/raw/tooling/direnv/developer-links.ts +148 -29
- package/managed/raw/tooling/direnv/devenv.smoo.nix +7 -7
- package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +14 -5
- package/managed/raw/tooling/direnv/linked-snapshots.ts +206 -40
- package/managed/raw/tooling/direnv/repo-path +15 -2
- package/managed/raw/tooling/direnv/setup-environment.ts +179 -115
- package/managed/templates/github/actions/cache-node-modules/action.yml +9 -0
- package/managed/templates/github/actions/setup-devenv/action.yml +63 -7
- package/nextest.toml +1 -1
- package/package.json +25 -9
- package/src/__tests__/cargo-closure-fixture.ts +113 -0
- package/src/__tests__/counted-cargo.ts +8 -25
- package/src/__tests__/directory-change.ts +27 -0
- package/src/__tests__/fixture-nx-env.ts +7 -0
- package/src/__tests__/owned-installation.ts +14 -0
- package/src/__tests__/past-tick.ts +12 -0
- package/src/bin/smoo-nx-bound-failures.test.ts +1 -1
- package/src/bin/smoo-nx-test-clocks.ts +29 -0
- package/src/bounded-test-policy.test.ts +36 -22
- package/src/bounded-test-policy.ts +18 -32
- package/src/bun-bootstrap.test.ts +1 -1
- package/src/cargo-closure-input.property.test.ts +50 -0
- package/src/cargo-closure-input.test.ts +73 -121
- package/src/cargo-closure-input.ts +47 -8
- package/src/cargo-closure-key.test.ts +239 -0
- package/src/cargo-resolve-cache.test.ts +168 -31
- package/src/cargo-source-hash.test.ts +78 -3
- package/src/cargo-source-hash.ts +48 -30
- package/src/cross-check-policy.test.ts +2 -2
- package/src/ensure-built-receipt.test.ts +111 -16
- package/src/ensure-built-receipt.ts +294 -149
- package/src/ensure-built-witness.test.ts +306 -13
- package/src/ensure-built-witness.ts +255 -24
- package/src/ensure-built.test.ts +228 -102
- package/src/ensure-built.ts +127 -66
- package/src/executors/bounded-exec/cpu-pool.test.ts +134 -32
- package/src/executors/bounded-exec/cpu-pool.ts +64 -20
- package/src/executors/bounded-exec/cpu-tokens.test.ts +2 -2
- package/src/executors/bounded-exec/disk-lease.test.ts +47 -13
- package/src/executors/bounded-exec/executor-host.test.ts +74 -52
- package/src/executors/bounded-exec/executor.test.ts +343 -97
- package/src/executors/bounded-exec/executor.ts +192 -56
- package/src/executors/bounded-exec/hang-diagnostics.test.ts +14 -8
- package/src/executors/bounded-exec/no-space.ts +40 -0
- package/src/executors/bounded-exec/progress.test.ts +1 -1
- package/src/executors/bounded-exec/ram-temp-host.test.ts +51 -21
- package/src/executors/bounded-exec/ram-temp.test.ts +92 -16
- package/src/executors/bounded-exec/ram-temp.ts +49 -20
- package/src/executors/bounded-exec/verdict.test.ts +127 -22
- package/src/executors/bounded-exec/verdict.ts +78 -3
- package/src/generators/bounded-test-targets/generator.test.ts +1 -3
- package/src/generators/bun-test-tracing/generator.test.ts +2 -2
- package/src/generators/bun-test-tracing/generator.ts +2 -2
- package/src/graph-input-contract.test.ts +379 -0
- package/src/graph-input-contract.ts +627 -0
- package/src/index.test.ts +3 -3
- package/src/index.ts +24 -3
- package/src/linked-snapshots.nx.test.ts +112 -30
- package/src/managed-files/ci-workflow.ts +5 -2
- package/src/managed-files/publish-workflow.ts +12 -1
- package/src/managed-files/repo-path.test.ts +44 -1
- package/src/managed-files/setup-devenv-free-disk.test.ts +95 -0
- package/src/nextest-code-bound.test.ts +23 -17
- package/src/nextest-extraction.test.ts +114 -4
- package/src/nextest-partitions.test.ts +7 -1
- package/src/nx-cache-restore-mtime.test.ts +2 -2
- package/src/nx-daemon-claim.test.ts +10 -8
- package/src/nx-daemon-idle-cpu.test.ts +0 -1
- package/src/nx-daemon-idle-policy.test.ts +61 -1
- package/src/nx-daemon-ignore-files.test.ts +2 -2
- package/src/nx-daemon-validity.test.ts +36 -22
- package/src/nx-dot-input-policy.test.ts +5 -5
- package/src/nx-files-archive-racy.test.ts +1 -1
- package/src/nx-incomplete-run-summary.test.ts +1 -1
- package/src/nx-plugin-load-errors.test.ts +2 -2
- package/src/nx-project-graph-errors.test.ts +70 -0
- package/src/nx-skipped-task-exit.test.ts +2 -2
- package/src/nx-store-resolution.test.ts +7 -25
- package/src/nx-task-output-lease.test.ts +3 -3
- package/src/nx-use-local.test.ts +7 -5
- package/src/owned-installation.ts +174 -0
- package/src/producer-receipts.test.ts +164 -0
- package/src/producer-receipts.ts +636 -0
- package/src/runtime-input.test.ts +1 -1
- package/src/serial-group-wiring.test.ts +4 -4
- package/src/task-results.test.ts +18 -16
- package/src/test-backstop.ts +11 -0
- package/src/test-clock-policy.test.ts +338 -0
- package/src/test-clock-policy.ts +708 -0
- package/src/test-timings.test.ts +2 -2
- package/src/testing.test.ts +5 -5
- package/src/testing.ts +67 -1
- package/src/typecheck-test-policy.test.ts +1 -1
- package/src/typescript-resolution.test.ts +76 -0
- package/test-timings.json +8 -0
|
@@ -3,8 +3,10 @@ import { spawnSync } from 'node:child_process';
|
|
|
3
3
|
import { mkdir, mkdtemp, readFile, rm, symlink, writeFile } from 'node:fs/promises';
|
|
4
4
|
import { tmpdir } from 'node:os';
|
|
5
5
|
import { dirname, join } from 'node:path';
|
|
6
|
+
import fc from 'fast-check';
|
|
6
7
|
|
|
7
8
|
import { onProgressClock } from '../../__tests__/progress-clock.js';
|
|
9
|
+
import { BOUNDED_TEST_IDLE_TIMEOUT_MS } from '../../bounded-test-policy.js';
|
|
8
10
|
import {
|
|
9
11
|
type BoundedExecContext,
|
|
10
12
|
createProcessTreeKiller,
|
|
@@ -14,6 +16,7 @@ import {
|
|
|
14
16
|
import type { BoundedExecBounds } from './schema.js';
|
|
15
17
|
import {
|
|
16
18
|
type BoundedExecVerdict,
|
|
19
|
+
describeVerdict,
|
|
17
20
|
failedTasksOfRun,
|
|
18
21
|
JUNIT_FILE,
|
|
19
22
|
judgeOperationalFailure,
|
|
@@ -87,15 +90,20 @@ async function verdictOf(
|
|
|
87
90
|
return record?.verdict;
|
|
88
91
|
}
|
|
89
92
|
|
|
90
|
-
// The fixtures run in child processes and must really
|
|
91
|
-
//
|
|
92
|
-
|
|
93
|
+
// The fixtures run in child processes and must really meet their runner's per-test bound: the verdict is about which
|
|
94
|
+
// real bound fired. The slow test never finishes, so nothing can beat that bound; the parent's own required ceiling is
|
|
95
|
+
// the leg's backstop, so it cannot end the run first however long `bun test` takes to start on a loaded host.
|
|
96
|
+
const SLOW_TEST = `import { test } from 'bun:test';\ntest('slow', () => new Promise(() => {}));\n`;
|
|
93
97
|
const FAILING_TEST = `import { expect, test } from 'bun:test';\ntest('wrong', () => { expect(1).toBe(2); });\n`;
|
|
94
98
|
|
|
95
99
|
describe('bounded-exec verdicts', () => {
|
|
96
100
|
it('records a bun run whose only failure is a per-test timeout as a bound', async () => {
|
|
97
101
|
expect(
|
|
98
|
-
await verdictOf(
|
|
102
|
+
await verdictOf(
|
|
103
|
+
'bun test --timeout=100 ./slow.test.ts',
|
|
104
|
+
{ timeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS },
|
|
105
|
+
{ 'slow.test.ts': SLOW_TEST },
|
|
106
|
+
),
|
|
99
107
|
).toEqual({
|
|
100
108
|
outcome: 'bound',
|
|
101
109
|
bound: 'test',
|
|
@@ -107,7 +115,7 @@ describe('bounded-exec verdicts', () => {
|
|
|
107
115
|
expect(
|
|
108
116
|
await verdictOf(
|
|
109
117
|
'.runtime/bun test --timeout=100 ./slow.test.ts',
|
|
110
|
-
{ timeoutMs:
|
|
118
|
+
{ timeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS },
|
|
111
119
|
{ 'slow.test.ts': SLOW_TEST },
|
|
112
120
|
{ '.runtime/bun': process.execPath },
|
|
113
121
|
),
|
|
@@ -118,19 +126,21 @@ describe('bounded-exec verdicts', () => {
|
|
|
118
126
|
expect(
|
|
119
127
|
await verdictOf(
|
|
120
128
|
'bun test --timeout=100 ./slow.test.ts ./failing.test.ts',
|
|
121
|
-
{ timeoutMs:
|
|
129
|
+
{ timeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS },
|
|
122
130
|
{ 'slow.test.ts': SLOW_TEST, 'failing.test.ts': FAILING_TEST },
|
|
123
131
|
),
|
|
124
132
|
).toEqual({ outcome: 'failed', exitCode: 1, tests: ['wrong'] });
|
|
125
133
|
});
|
|
126
134
|
|
|
127
135
|
it('records the total bound as a bound and the progress bound as a wedge', async () => {
|
|
128
|
-
|
|
136
|
+
// Each command holds on its stdin, which bounded-exec keeps open and never writes: it never exits, so only the
|
|
137
|
+
// bound under test can end it.
|
|
138
|
+
expect(await verdictOf('node -e "process.stdin.resume()"', { timeoutMs: 200 })).toMatchObject({
|
|
129
139
|
outcome: 'bound',
|
|
130
140
|
bound: 'total',
|
|
131
141
|
limitMs: 200,
|
|
132
142
|
});
|
|
133
|
-
expect(await verdictOf('node -e "
|
|
143
|
+
expect(await verdictOf('node -e "process.stdin.resume()"', { idleTimeoutMs: 100 })).toMatchObject({
|
|
134
144
|
outcome: 'wedged',
|
|
135
145
|
idleMs: 100,
|
|
136
146
|
tests: [],
|
|
@@ -174,17 +184,51 @@ describe('bounded-exec verdicts', () => {
|
|
|
174
184
|
elapsedMs: 900,
|
|
175
185
|
expiry: { kind: 'idle', limitMs: 400, tests: ['nt tests::hangs'] },
|
|
176
186
|
report,
|
|
187
|
+
noSpace: null,
|
|
177
188
|
}),
|
|
178
189
|
).toEqual({ outcome: 'wedged', idleMs: 400, elapsedMs: 900, tests: ['nt tests::hangs', 'nt tests::young'] });
|
|
179
190
|
});
|
|
180
191
|
|
|
192
|
+
it('records a failed run whose output said ENOSPC as out of space, ahead of the tests and the bound that followed', () => {
|
|
193
|
+
// From a downstream land gate: a 1 KB write into the task's RAM lease failed, and two tests failed on it.
|
|
194
|
+
const noSpace = {
|
|
195
|
+
line: 'ENOSPC: no space left on device, write',
|
|
196
|
+
volume: {
|
|
197
|
+
lease: '/Volumes/smoo-ram2-502/37738-AadRCN',
|
|
198
|
+
mountpoint: '/Volumes/smoo-ram2-502',
|
|
199
|
+
capacityBytes: 8 * 1024 ** 3,
|
|
200
|
+
freeBytes: 4096,
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
const report = { timedOut: [], cancelled: [], failed: ['lsp-differential hover'] };
|
|
204
|
+
const ran = { exitCode: 1, elapsedMs: 11_580, expiry: null, report, noSpace };
|
|
205
|
+
expect(judgeRun(ran)).toEqual({ outcome: 'no-space', exitCode: 1, tests: ['lsp-differential hover'], ...noSpace });
|
|
206
|
+
// A full disk that then hung the run is still the disk.
|
|
207
|
+
const idle = { kind: 'idle', limitMs: 400, tests: ['nt tests::writes'] } as const;
|
|
208
|
+
expect(judgeRun({ ...ran, exitCode: 143, expiry: idle, report: null })).toEqual({
|
|
209
|
+
outcome: 'no-space',
|
|
210
|
+
exitCode: 143,
|
|
211
|
+
tests: [],
|
|
212
|
+
...noSpace,
|
|
213
|
+
});
|
|
214
|
+
// A passing run that printed it, as a test of ENOSPC handling does, passed.
|
|
215
|
+
expect(judgeRun({ ...ran, exitCode: 0, report: null })).toEqual({ outcome: 'passed' });
|
|
216
|
+
expect(describeVerdict(judgeRun(ran))).toBe(
|
|
217
|
+
'ENOSPC (no space left on device): the command printed "ENOSPC: no space left on device, write"; its TMPDIR ' +
|
|
218
|
+
'/Volumes/smoo-ram2-502/37738-AadRCN is on the RAM temp volume /Volumes/smoo-ram2-502, which had 0.0 MiB free ' +
|
|
219
|
+
'of 8192.0 MiB when that line arrived; the tests that then failed: lsp-differential hover',
|
|
220
|
+
);
|
|
221
|
+
});
|
|
222
|
+
|
|
181
223
|
it('records a failing command with no report as a failure, and a passing one as passed', async () => {
|
|
182
|
-
|
|
224
|
+
// How an exit is classified, not how soon it comes: the required ceiling is the leg's backstop, so it cannot end a
|
|
225
|
+
// `node` still starting on a loaded host (a land gate measured 5243 ms for `node -e ""` against 5000 ms).
|
|
226
|
+
expect(await verdictOf('node -e "process.exit(3)"', { timeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS })).toEqual({
|
|
183
227
|
outcome: 'failed',
|
|
184
228
|
exitCode: 3,
|
|
185
229
|
tests: [],
|
|
186
230
|
});
|
|
187
|
-
expect(await verdictOf('node -e ""', { timeoutMs:
|
|
231
|
+
expect(await verdictOf('node -e ""', { timeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS })).toEqual({ outcome: 'passed' });
|
|
188
232
|
});
|
|
189
233
|
|
|
190
234
|
it("reads nextest's typed timeout from its JUnit report", () => {
|
|
@@ -231,7 +275,7 @@ ${abort('t::crash', '11 (SIGSEGV)')}
|
|
|
231
275
|
it('records a run its ceiling stopped as a bound when the only failures are the tests the stop aborted', () => {
|
|
232
276
|
const total = { kind: 'total', limitMs: 120_000 } as const;
|
|
233
277
|
const cut = { timedOut: [], cancelled: ['nt t::cut'], failed: [] };
|
|
234
|
-
expect(judgeRun({ exitCode: 143, elapsedMs: 120_850, expiry: total, report: cut })).toEqual({
|
|
278
|
+
expect(judgeRun({ exitCode: 143, elapsedMs: 120_850, expiry: total, report: cut, noSpace: null })).toEqual({
|
|
235
279
|
outcome: 'bound',
|
|
236
280
|
bound: 'total',
|
|
237
281
|
limitMs: 120_000,
|
|
@@ -239,9 +283,15 @@ ${abort('t::crash', '11 (SIGSEGV)')}
|
|
|
239
283
|
});
|
|
240
284
|
// An assertion that failed before the ceiling is still a failure, and an abort nobody asked for is one too.
|
|
241
285
|
expect(
|
|
242
|
-
judgeRun({
|
|
286
|
+
judgeRun({
|
|
287
|
+
exitCode: 143,
|
|
288
|
+
elapsedMs: 120_850,
|
|
289
|
+
expiry: total,
|
|
290
|
+
report: { ...cut, failed: ['nt t::assert'] },
|
|
291
|
+
noSpace: null,
|
|
292
|
+
}),
|
|
243
293
|
).toEqual({ outcome: 'failed', exitCode: 143, tests: ['nt t::assert'] });
|
|
244
|
-
expect(judgeRun({ exitCode: 143, elapsedMs: 850, expiry: null, report: cut })).toEqual({
|
|
294
|
+
expect(judgeRun({ exitCode: 143, elapsedMs: 850, expiry: null, report: cut, noSpace: null })).toEqual({
|
|
245
295
|
outcome: 'failed',
|
|
246
296
|
exitCode: 143,
|
|
247
297
|
tests: ['nt t::cut'],
|
|
@@ -252,7 +302,13 @@ ${abort('t::crash', '11 (SIGSEGV)')}
|
|
|
252
302
|
const cancelled = ['nt t::cut'];
|
|
253
303
|
// Exit 0 with an abort in the report: the abort is still not nothing.
|
|
254
304
|
expect(
|
|
255
|
-
judgeRun({
|
|
305
|
+
judgeRun({
|
|
306
|
+
exitCode: 0,
|
|
307
|
+
elapsedMs: 850,
|
|
308
|
+
expiry: null,
|
|
309
|
+
report: { timedOut: [], cancelled, failed: [] },
|
|
310
|
+
noSpace: null,
|
|
311
|
+
}),
|
|
256
312
|
).toEqual({
|
|
257
313
|
outcome: 'failed',
|
|
258
314
|
exitCode: 0,
|
|
@@ -265,6 +321,7 @@ ${abort('t::crash', '11 (SIGSEGV)')}
|
|
|
265
321
|
elapsedMs: 850,
|
|
266
322
|
expiry: null,
|
|
267
323
|
report: { timedOut: ['nt t::slow'], cancelled, failed: [] },
|
|
324
|
+
noSpace: null,
|
|
268
325
|
}),
|
|
269
326
|
).toEqual({ outcome: 'failed', exitCode: 100, tests: cancelled });
|
|
270
327
|
// With the total bound fired, the same report is the bound's own casualties.
|
|
@@ -274,6 +331,7 @@ ${abort('t::crash', '11 (SIGSEGV)')}
|
|
|
274
331
|
elapsedMs: 120_850,
|
|
275
332
|
expiry: { kind: 'total', limitMs: 120_000 },
|
|
276
333
|
report: { timedOut: ['nt t::slow'], cancelled, failed: [] },
|
|
334
|
+
noSpace: null,
|
|
277
335
|
}),
|
|
278
336
|
).toMatchObject({ outcome: 'bound', bound: 'total' });
|
|
279
337
|
});
|
|
@@ -306,13 +364,15 @@ process.on('SIGTERM', () => {
|
|
|
306
364
|
process.exit(143);
|
|
307
365
|
});
|
|
308
366
|
fs.writeFileSync('runner-ready.fifo', 'ready pid=' + process.pid + '\\n');
|
|
309
|
-
|
|
367
|
+
process.stdin.resume();
|
|
310
368
|
`;
|
|
311
369
|
let armed: Promise<void> | undefined;
|
|
312
370
|
let report = '';
|
|
313
371
|
const verdict = await verdictOf(
|
|
314
372
|
'exec node runner.js',
|
|
315
|
-
|
|
373
|
+
// The total bound is the subject; the grace after it is the leg's backstop, so the run ends by the runner's own
|
|
374
|
+
// exit on SIGTERM, never by a SIGKILL a loaded host's slow handler would have drawn.
|
|
375
|
+
{ timeoutMs: 300, killAfterMs: BOUNDED_TEST_IDLE_TIMEOUT_MS },
|
|
316
376
|
{ 'runner.js': runner },
|
|
317
377
|
{},
|
|
318
378
|
async (root) => {
|
|
@@ -358,8 +418,8 @@ setInterval(() => console.log('running'), 10);
|
|
|
358
418
|
const directory = context.record?.directory ?? '';
|
|
359
419
|
await mkdir(directory, { recursive: true });
|
|
360
420
|
const report = join(directory, JUNIT_FILE);
|
|
361
|
-
expect(await withJunitReport('bun test --timeout=
|
|
362
|
-
`bun test --reporter=junit --reporter-outfile='${report}' --timeout=
|
|
421
|
+
expect(await withJunitReport('bun test --timeout=0 src', directory)).toBe(
|
|
422
|
+
`bun test --reporter=junit --reporter-outfile='${report}' --timeout=0 src`,
|
|
363
423
|
);
|
|
364
424
|
const nextest = await withJunitReport('extracted="$(x)" && cargo --frozen nextest run -E all', directory);
|
|
365
425
|
expect(nextest).toBe(
|
|
@@ -377,15 +437,15 @@ setInterval(() => console.log('running'), 10);
|
|
|
377
437
|
const directory = context.record?.directory ?? '';
|
|
378
438
|
await mkdir(directory, { recursive: true });
|
|
379
439
|
const flags = `--reporter=junit --reporter-outfile='${join(directory, JUNIT_FILE)}'`;
|
|
380
|
-
expect(await withJunitReport('../bun-runtime/.runtime/bun test --timeout=
|
|
381
|
-
`../bun-runtime/.runtime/bun test ${flags} --timeout=
|
|
440
|
+
expect(await withJunitReport('../bun-runtime/.runtime/bun test --timeout=0 --shard=1/4', directory)).toBe(
|
|
441
|
+
`../bun-runtime/.runtime/bun test ${flags} --timeout=0 --shard=1/4`,
|
|
382
442
|
);
|
|
383
443
|
expect(
|
|
384
444
|
await withJunitReport(
|
|
385
|
-
'BUN_EXE=../bun-runtime/.runtime/bun ../bun-runtime/.runtime/bun test --timeout=
|
|
445
|
+
'BUN_EXE=../bun-runtime/.runtime/bun ../bun-runtime/.runtime/bun test --timeout=0 tests',
|
|
386
446
|
directory,
|
|
387
447
|
),
|
|
388
|
-
).toBe(`BUN_EXE=../bun-runtime/.runtime/bun ../bun-runtime/.runtime/bun test ${flags} --timeout=
|
|
448
|
+
).toBe(`BUN_EXE=../bun-runtime/.runtime/bun ../bun-runtime/.runtime/bun test ${flags} --timeout=0 tests`);
|
|
389
449
|
expect(await withJunitReport('cd pkg && $RUNTIME/bun test src', directory)).toBe(
|
|
390
450
|
`cd pkg && $RUNTIME/bun test ${flags} src`,
|
|
391
451
|
);
|
|
@@ -437,4 +497,49 @@ setInterval(() => console.log('running'), 10);
|
|
|
437
497
|
{ task: 'd:lint', bound: false, reason: 'no bounded-exec verdict' },
|
|
438
498
|
]);
|
|
439
499
|
});
|
|
500
|
+
|
|
501
|
+
it('judges a run that exits inside its total bound by its exit alone, however far the injected clock moved', async () => {
|
|
502
|
+
// The clock is faked: it moves once, when the command reports, by a generated amount short of the total bound, and
|
|
503
|
+
// then the command exits. Below the bound the verdict is a function of the exit, never of how long a loaded host
|
|
504
|
+
// took to get there (a land gate measured 5243 ms for `node -e ""` under a 5000 ms bound). The step is at least
|
|
505
|
+
// 1 ms: Bun 1.4.3's `advanceTimersByTime(0)` moves the fake clock 1 ms, and a run that never moves it is the case
|
|
506
|
+
// above. The command prints its report through `printf`, so the line naming the command never matches it.
|
|
507
|
+
const reported = 'bounded-exec-property-reported';
|
|
508
|
+
await fc.assert(
|
|
509
|
+
fc.asyncProperty(
|
|
510
|
+
fc.integer({ min: 2, max: 600_000 }).chain((timeoutMs) =>
|
|
511
|
+
fc.record({
|
|
512
|
+
timeoutMs: fc.constant(timeoutMs),
|
|
513
|
+
elapsedMs: fc.integer({ min: 1, max: timeoutMs - 1 }),
|
|
514
|
+
killAfterMs: fc.integer({ min: 0, max: timeoutMs }),
|
|
515
|
+
exitCode: fc.integer({ min: 0, max: 125 }),
|
|
516
|
+
}),
|
|
517
|
+
),
|
|
518
|
+
async ({ timeoutMs, elapsedMs, killAfterMs, exitCode }) => {
|
|
519
|
+
const { context } = await workspace();
|
|
520
|
+
const { movedMs } = await onProgressClock(
|
|
521
|
+
(chunk) => chunk.includes(reported),
|
|
522
|
+
elapsedMs,
|
|
523
|
+
() =>
|
|
524
|
+
runBoundedExec(
|
|
525
|
+
{
|
|
526
|
+
command: `printf '%s-%s\\n' bounded-exec property-reported; exit ${exitCode}`,
|
|
527
|
+
timeoutMs,
|
|
528
|
+
killAfterMs,
|
|
529
|
+
},
|
|
530
|
+
context,
|
|
531
|
+
createProcessTreeKiller(),
|
|
532
|
+
null,
|
|
533
|
+
null,
|
|
534
|
+
),
|
|
535
|
+
);
|
|
536
|
+
expect(movedMs).toBe(elapsedMs);
|
|
537
|
+
expect((await readRecord(context.record?.directory ?? ''))?.verdict).toEqual(
|
|
538
|
+
exitCode === 0 ? { outcome: 'passed' } : { outcome: 'failed', exitCode, tests: [] },
|
|
539
|
+
);
|
|
540
|
+
},
|
|
541
|
+
),
|
|
542
|
+
{ numRuns: 40 },
|
|
543
|
+
);
|
|
544
|
+
});
|
|
440
545
|
});
|
|
@@ -12,6 +12,9 @@ import { join } from 'node:path';
|
|
|
12
12
|
* tests, so this is a hang, not a slow host, and the fix is the opposite one, so it is never a `bound`. It names
|
|
13
13
|
* the tests still running: those the runner said were running and never said finished, and those its report says
|
|
14
14
|
* it aborted when the bound stopped it.
|
|
15
|
+
* - `no-space`: the run failed and its output said a write found no space (ENOSPC). Whatever its tests then reported,
|
|
16
|
+
* they failed on the disk, not on their own: the verdict names the line that said so and, when the task held one,
|
|
17
|
+
* its RAM temp volume as it stood when that line arrived.
|
|
15
18
|
* - `failed`: anything else that did not pass. That includes an assertion named in the report,
|
|
16
19
|
* or a non-zero exit with no report to say why.
|
|
17
20
|
*/
|
|
@@ -25,8 +28,23 @@ export type BoundedExecVerdict =
|
|
|
25
28
|
readonly elapsedMs: number;
|
|
26
29
|
readonly tests: readonly string[];
|
|
27
30
|
}
|
|
31
|
+
| ({ readonly outcome: 'no-space'; readonly exitCode: number; readonly tests: readonly string[] } & NoSpaceSighting)
|
|
28
32
|
| { readonly outcome: 'failed'; readonly exitCode: number; readonly tests: readonly string[] };
|
|
29
33
|
|
|
34
|
+
/** The task's RAM temp volume, read when a line saying ENOSPC arrived: the writer's own lease, and the space left. */
|
|
35
|
+
export interface TempVolumeSpace {
|
|
36
|
+
readonly lease: string;
|
|
37
|
+
readonly mountpoint: string;
|
|
38
|
+
readonly capacityBytes: number;
|
|
39
|
+
readonly freeBytes: number;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** The first output line that said a write found no space, and the task's RAM temp volume then; `null` without one. */
|
|
43
|
+
export interface NoSpaceSighting {
|
|
44
|
+
readonly line: string;
|
|
45
|
+
readonly volume: TempVolumeSpace | null;
|
|
46
|
+
}
|
|
47
|
+
|
|
30
48
|
/** One task's verdict, keyed by the Nx task and the hash it ran at. */
|
|
31
49
|
export interface BoundedExecRecord {
|
|
32
50
|
readonly task: string;
|
|
@@ -184,14 +202,23 @@ export interface RunEnd {
|
|
|
184
202
|
readonly expiry: ExpiredBound | null;
|
|
185
203
|
/** The run's report, or `null` when the command was asked for none or wrote none. */
|
|
186
204
|
readonly report: JunitFailures | null;
|
|
205
|
+
/** The first output line that said ENOSPC, or `null` when none did. */
|
|
206
|
+
readonly noSpace: NoSpaceSighting | null;
|
|
187
207
|
}
|
|
188
208
|
|
|
189
209
|
/**
|
|
190
|
-
* Judge a run. A
|
|
191
|
-
*
|
|
192
|
-
*
|
|
210
|
+
* Judge a run. A run that failed after its output said ENOSPC failed on the disk: that is read first, ahead of the
|
|
211
|
+
* tests it then failed, a bound it then hit or a hang the full disk caused; a passing run that printed it (a test of
|
|
212
|
+
* its own ENOSPC handling) passed. A test that failed on its own is a failure even when a bound fired too, and the
|
|
213
|
+
* no-progress bound is never load: the report's assertions and the idle bound are read next. A test the runner aborted
|
|
214
|
+
* because the total bound told its command to stop is not one that failed; one it aborted at the idle bound is a test
|
|
215
|
+
* still running.
|
|
193
216
|
*/
|
|
194
217
|
export function judgeRun(run: RunEnd): BoundedExecVerdict {
|
|
218
|
+
if (run.noSpace !== null && (run.exitCode !== 0 || run.expiry !== null)) {
|
|
219
|
+
const tests = run.report === null ? [] : [...run.report.failed, ...run.report.timedOut, ...run.report.cancelled];
|
|
220
|
+
return { outcome: 'no-space', exitCode: run.exitCode === 0 ? 1 : run.exitCode, tests, ...run.noSpace };
|
|
221
|
+
}
|
|
195
222
|
if (run.expiry?.kind === 'idle') {
|
|
196
223
|
const tests = [...new Set([...run.expiry.tests, ...(run.report?.cancelled ?? [])])];
|
|
197
224
|
return { outcome: 'wedged', idleMs: run.expiry.limitMs, elapsedMs: run.elapsedMs, tests };
|
|
@@ -352,6 +379,19 @@ function parseVerdict(value: unknown): BoundedExecVerdict {
|
|
|
352
379
|
return { outcome: 'wedged', idleMs: value.idleMs, elapsedMs: value.elapsedMs, tests: value.tests };
|
|
353
380
|
}
|
|
354
381
|
break;
|
|
382
|
+
case 'no-space': {
|
|
383
|
+
const volume = parseTempVolumeSpace(value.volume);
|
|
384
|
+
if (typeof value.exitCode === 'number' && isStrings(value.tests) && typeof value.line === 'string' && volume) {
|
|
385
|
+
return {
|
|
386
|
+
outcome: 'no-space',
|
|
387
|
+
exitCode: value.exitCode,
|
|
388
|
+
tests: value.tests,
|
|
389
|
+
line: value.line,
|
|
390
|
+
volume: volume.value,
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
break;
|
|
394
|
+
}
|
|
355
395
|
case 'failed':
|
|
356
396
|
if (typeof value.exitCode === 'number' && isStrings(value.tests)) {
|
|
357
397
|
return { outcome: 'failed', exitCode: value.exitCode, tests: value.tests };
|
|
@@ -362,6 +402,24 @@ function parseVerdict(value: unknown): BoundedExecVerdict {
|
|
|
362
402
|
throw new Error(`not a bounded-exec verdict: ${JSON.stringify(value)}`);
|
|
363
403
|
}
|
|
364
404
|
|
|
405
|
+
/** A recorded volume, wrapped so a well-formed `null` (no RAM volume) differs from a malformed one (`undefined`). */
|
|
406
|
+
function parseTempVolumeSpace(value: unknown): { value: TempVolumeSpace | null } | undefined {
|
|
407
|
+
if (value === null) {
|
|
408
|
+
return { value: null };
|
|
409
|
+
}
|
|
410
|
+
if (
|
|
411
|
+
isObject(value) &&
|
|
412
|
+
typeof value.lease === 'string' &&
|
|
413
|
+
typeof value.mountpoint === 'string' &&
|
|
414
|
+
typeof value.capacityBytes === 'number' &&
|
|
415
|
+
typeof value.freeBytes === 'number'
|
|
416
|
+
) {
|
|
417
|
+
const { lease, mountpoint, capacityBytes, freeBytes } = value;
|
|
418
|
+
return { value: { lease, mountpoint, capacityBytes, freeBytes } };
|
|
419
|
+
}
|
|
420
|
+
return undefined;
|
|
421
|
+
}
|
|
422
|
+
|
|
365
423
|
function isObject(value: unknown): value is Record<string, unknown> {
|
|
366
424
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
367
425
|
}
|
|
@@ -425,9 +483,26 @@ export function describeVerdict(verdict: BoundedExecVerdict): string {
|
|
|
425
483
|
? `still running: ${verdict.tests.join(', ')}`
|
|
426
484
|
: 'the runner named no test still running'
|
|
427
485
|
}`;
|
|
486
|
+
case 'no-space':
|
|
487
|
+
return `${describeNoSpace(verdict)}${verdict.tests.length > 0 ? `; the tests that then failed: ${verdict.tests.join(', ')}` : ''}`;
|
|
428
488
|
case 'failed':
|
|
429
489
|
return verdict.tests.length > 0
|
|
430
490
|
? `failed: ${verdict.tests.join(', ')}`
|
|
431
491
|
: `exited ${verdict.exitCode} with no report naming a timeout`;
|
|
432
492
|
}
|
|
433
493
|
}
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* What a run's output said about a write that found no space, and where the run's temp files lived then. The free
|
|
497
|
+
* space is read when the line arrives, not after the command exits: by then a writer that failed has usually removed
|
|
498
|
+
* its half-written files and the volume no longer looks full.
|
|
499
|
+
*/
|
|
500
|
+
export function describeNoSpace(sighting: NoSpaceSighting): string {
|
|
501
|
+
const said = `ENOSPC (no space left on device): the command printed ${JSON.stringify(sighting.line)}`;
|
|
502
|
+
const volume = sighting.volume;
|
|
503
|
+
if (volume === null) {
|
|
504
|
+
return `${said}; it held no RAM temp volume, so the full disk is the one that line's writer wrote to`;
|
|
505
|
+
}
|
|
506
|
+
const mib = (bytes: number) => (bytes / (1024 * 1024)).toFixed(1);
|
|
507
|
+
return `${said}; its TMPDIR ${volume.lease} is on the RAM temp volume ${volume.mountpoint}, which had ${mib(volume.freeBytes)} MiB free of ${mib(volume.capacityBytes)} MiB when that line arrived`;
|
|
508
|
+
}
|
|
@@ -6,11 +6,9 @@ import {
|
|
|
6
6
|
BOUNDED_TEST_EXECUTOR,
|
|
7
7
|
BOUNDED_TEST_IDLE_TIMEOUT_MS,
|
|
8
8
|
BOUNDED_TEST_KILL_AFTER_MS,
|
|
9
|
-
|
|
9
|
+
BUN_TEST_TIMEOUT_FLAG as TIMEOUT_FLAG,
|
|
10
10
|
} from '../../bounded-test-policy.js';
|
|
11
11
|
|
|
12
|
-
const TIMEOUT_FLAG = `--timeout=${BOUNDED_TEST_PER_TEST_TIMEOUT_MS}`;
|
|
13
|
-
|
|
14
12
|
import generator from './generator.js';
|
|
15
13
|
|
|
16
14
|
describe('bounded-test-targets generator', () => {
|
|
@@ -5,7 +5,7 @@ import { createTreeWithEmptyWorkspace } from 'nx/src/devkit-testing-exports.js';
|
|
|
5
5
|
import {
|
|
6
6
|
BOUNDED_TEST_IDLE_TIMEOUT_MS,
|
|
7
7
|
BOUNDED_TEST_KILL_AFTER_MS,
|
|
8
|
-
|
|
8
|
+
BUN_TEST_TIMEOUT_FLAG,
|
|
9
9
|
} from '../../bounded-test-policy.js';
|
|
10
10
|
import generator from './generator.js';
|
|
11
11
|
|
|
@@ -77,7 +77,7 @@ describe('bun-test-tracing generator', () => {
|
|
|
77
77
|
executor: '@smoothbricks/nx-plugin:bounded-exec',
|
|
78
78
|
dependsOn: ['typecheck-tests', '^build'],
|
|
79
79
|
options: {
|
|
80
|
-
command: `bun test
|
|
80
|
+
command: `bun test ${BUN_TEST_TIMEOUT_FLAG}`,
|
|
81
81
|
cwd: '{projectRoot}',
|
|
82
82
|
idleTimeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS,
|
|
83
83
|
killAfterMs: BOUNDED_TEST_KILL_AFTER_MS,
|
|
@@ -141,8 +141,8 @@ function writeBunfig(tree: Tree, projectRoot: string): void {
|
|
|
141
141
|
// Bun silently ignores `[test] timeout` in bunfig.toml — only the `--timeout`
|
|
142
142
|
// CLI flag and `setDefaultTimeout()` actually take effect. Strip any stale
|
|
143
143
|
// `timeout = N` lines so the file isn't lying about what's enforced; the real
|
|
144
|
-
// per-test timeout is
|
|
145
|
-
//
|
|
144
|
+
// per-test timeout is the leg's `--timeout`, which the bounded-test policy
|
|
145
|
+
// derives from bounded-exec's progress bound (see BUN_TEST_TIMEOUT_FLAG).
|
|
146
146
|
const current = stripBunTestTimeoutLine(tree.read(bunfigPath, 'utf-8') ?? '');
|
|
147
147
|
|
|
148
148
|
// Already has the package specifier preloads
|