@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.
Files changed (158) hide show
  1. package/README.md +277 -89
  2. package/dist/bin/smoo-nx-test-clocks.d.ts +3 -0
  3. package/dist/bin/smoo-nx-test-clocks.d.ts.map +1 -0
  4. package/dist/bin/smoo-nx-test-clocks.js +28 -0
  5. package/dist/bounded-test-policy.d.ts +8 -8
  6. package/dist/bounded-test-policy.d.ts.map +1 -1
  7. package/dist/bounded-test-policy.js +18 -30
  8. package/dist/cargo-closure-input.d.ts +23 -0
  9. package/dist/cargo-closure-input.d.ts.map +1 -1
  10. package/dist/cargo-closure-input.js +41 -9
  11. package/dist/cargo-source-hash.d.ts.map +1 -1
  12. package/dist/cargo-source-hash.js +42 -19
  13. package/dist/ensure-built-receipt.d.ts +40 -6
  14. package/dist/ensure-built-receipt.d.ts.map +1 -1
  15. package/dist/ensure-built-receipt.js +297 -159
  16. package/dist/ensure-built-witness.d.ts +65 -4
  17. package/dist/ensure-built-witness.d.ts.map +1 -1
  18. package/dist/ensure-built-witness.js +2237 -23
  19. package/dist/ensure-built.d.ts +99 -1
  20. package/dist/ensure-built.d.ts.map +1 -1
  21. package/dist/ensure-built.js +45 -56
  22. package/dist/executors/bounded-exec/cpu-pool.d.ts +22 -7
  23. package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
  24. package/dist/executors/bounded-exec/cpu-pool.js +51 -22
  25. package/dist/executors/bounded-exec/executor.d.ts +12 -3
  26. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  27. package/dist/executors/bounded-exec/executor.js +174 -51
  28. package/dist/executors/bounded-exec/no-space.d.ts +8 -0
  29. package/dist/executors/bounded-exec/no-space.d.ts.map +1 -0
  30. package/dist/executors/bounded-exec/no-space.js +31 -0
  31. package/dist/executors/bounded-exec/ram-temp.d.ts +20 -11
  32. package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -1
  33. package/dist/executors/bounded-exec/ram-temp.js +42 -17
  34. package/dist/executors/bounded-exec/verdict.d.ts +34 -4
  35. package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
  36. package/dist/executors/bounded-exec/verdict.js +54 -3
  37. package/dist/generators/bun-test-tracing/generator.js +2 -2
  38. package/dist/graph-input-contract.d.ts +102 -0
  39. package/dist/graph-input-contract.d.ts.map +1 -0
  40. package/dist/graph-input-contract.js +637 -0
  41. package/dist/index.d.ts +12 -5
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +17 -3
  44. package/dist/managed-files/ci-workflow.d.ts.map +1 -1
  45. package/dist/managed-files/ci-workflow.js +5 -2
  46. package/dist/managed-files/publish-workflow.d.ts +11 -1
  47. package/dist/managed-files/publish-workflow.d.ts.map +1 -1
  48. package/dist/owned-installation.d.ts +14 -0
  49. package/dist/owned-installation.d.ts.map +1 -0
  50. package/dist/owned-installation.js +324 -0
  51. package/dist/producer-receipts.d.ts +19 -0
  52. package/dist/producer-receipts.d.ts.map +1 -0
  53. package/dist/producer-receipts.js +926 -0
  54. package/dist/test-backstop.d.ts +9 -0
  55. package/dist/test-backstop.d.ts.map +1 -0
  56. package/dist/test-backstop.js +10 -0
  57. package/dist/test-clock-policy.d.ts +30 -0
  58. package/dist/test-clock-policy.d.ts.map +1 -0
  59. package/dist/test-clock-policy.js +686 -0
  60. package/dist/testing.d.ts +8 -0
  61. package/dist/testing.d.ts.map +1 -1
  62. package/dist/testing.js +66 -1
  63. package/managed/raw/patches/nx@23.2.1.patch +328 -50
  64. package/managed/raw/tooling/direnv/developer-links.ts +148 -29
  65. package/managed/raw/tooling/direnv/devenv.smoo.nix +7 -7
  66. package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +14 -5
  67. package/managed/raw/tooling/direnv/linked-snapshots.ts +206 -40
  68. package/managed/raw/tooling/direnv/repo-path +15 -2
  69. package/managed/raw/tooling/direnv/setup-environment.ts +179 -115
  70. package/managed/templates/github/actions/cache-node-modules/action.yml +9 -0
  71. package/managed/templates/github/actions/setup-devenv/action.yml +63 -7
  72. package/nextest.toml +1 -1
  73. package/package.json +25 -9
  74. package/src/__tests__/cargo-closure-fixture.ts +113 -0
  75. package/src/__tests__/counted-cargo.ts +8 -25
  76. package/src/__tests__/directory-change.ts +27 -0
  77. package/src/__tests__/fixture-nx-env.ts +7 -0
  78. package/src/__tests__/owned-installation.ts +14 -0
  79. package/src/__tests__/past-tick.ts +12 -0
  80. package/src/bin/smoo-nx-bound-failures.test.ts +1 -1
  81. package/src/bin/smoo-nx-test-clocks.ts +29 -0
  82. package/src/bounded-test-policy.test.ts +36 -22
  83. package/src/bounded-test-policy.ts +18 -32
  84. package/src/bun-bootstrap.test.ts +1 -1
  85. package/src/cargo-closure-input.property.test.ts +50 -0
  86. package/src/cargo-closure-input.test.ts +73 -121
  87. package/src/cargo-closure-input.ts +47 -8
  88. package/src/cargo-closure-key.test.ts +239 -0
  89. package/src/cargo-resolve-cache.test.ts +168 -31
  90. package/src/cargo-source-hash.test.ts +78 -3
  91. package/src/cargo-source-hash.ts +48 -30
  92. package/src/cross-check-policy.test.ts +2 -2
  93. package/src/ensure-built-receipt.test.ts +111 -16
  94. package/src/ensure-built-receipt.ts +294 -149
  95. package/src/ensure-built-witness.test.ts +306 -13
  96. package/src/ensure-built-witness.ts +255 -24
  97. package/src/ensure-built.test.ts +228 -102
  98. package/src/ensure-built.ts +127 -66
  99. package/src/executors/bounded-exec/cpu-pool.test.ts +134 -32
  100. package/src/executors/bounded-exec/cpu-pool.ts +64 -20
  101. package/src/executors/bounded-exec/cpu-tokens.test.ts +2 -2
  102. package/src/executors/bounded-exec/disk-lease.test.ts +47 -13
  103. package/src/executors/bounded-exec/executor-host.test.ts +74 -52
  104. package/src/executors/bounded-exec/executor.test.ts +343 -97
  105. package/src/executors/bounded-exec/executor.ts +192 -56
  106. package/src/executors/bounded-exec/hang-diagnostics.test.ts +14 -8
  107. package/src/executors/bounded-exec/no-space.ts +40 -0
  108. package/src/executors/bounded-exec/progress.test.ts +1 -1
  109. package/src/executors/bounded-exec/ram-temp-host.test.ts +51 -21
  110. package/src/executors/bounded-exec/ram-temp.test.ts +92 -16
  111. package/src/executors/bounded-exec/ram-temp.ts +49 -20
  112. package/src/executors/bounded-exec/verdict.test.ts +127 -22
  113. package/src/executors/bounded-exec/verdict.ts +78 -3
  114. package/src/generators/bounded-test-targets/generator.test.ts +1 -3
  115. package/src/generators/bun-test-tracing/generator.test.ts +2 -2
  116. package/src/generators/bun-test-tracing/generator.ts +2 -2
  117. package/src/graph-input-contract.test.ts +379 -0
  118. package/src/graph-input-contract.ts +627 -0
  119. package/src/index.test.ts +3 -3
  120. package/src/index.ts +24 -3
  121. package/src/linked-snapshots.nx.test.ts +112 -30
  122. package/src/managed-files/ci-workflow.ts +5 -2
  123. package/src/managed-files/publish-workflow.ts +12 -1
  124. package/src/managed-files/repo-path.test.ts +44 -1
  125. package/src/managed-files/setup-devenv-free-disk.test.ts +95 -0
  126. package/src/nextest-code-bound.test.ts +23 -17
  127. package/src/nextest-extraction.test.ts +114 -4
  128. package/src/nextest-partitions.test.ts +7 -1
  129. package/src/nx-cache-restore-mtime.test.ts +2 -2
  130. package/src/nx-daemon-claim.test.ts +10 -8
  131. package/src/nx-daemon-idle-cpu.test.ts +0 -1
  132. package/src/nx-daemon-idle-policy.test.ts +61 -1
  133. package/src/nx-daemon-ignore-files.test.ts +2 -2
  134. package/src/nx-daemon-validity.test.ts +36 -22
  135. package/src/nx-dot-input-policy.test.ts +5 -5
  136. package/src/nx-files-archive-racy.test.ts +1 -1
  137. package/src/nx-incomplete-run-summary.test.ts +1 -1
  138. package/src/nx-plugin-load-errors.test.ts +2 -2
  139. package/src/nx-project-graph-errors.test.ts +70 -0
  140. package/src/nx-skipped-task-exit.test.ts +2 -2
  141. package/src/nx-store-resolution.test.ts +7 -25
  142. package/src/nx-task-output-lease.test.ts +3 -3
  143. package/src/nx-use-local.test.ts +7 -5
  144. package/src/owned-installation.ts +174 -0
  145. package/src/producer-receipts.test.ts +164 -0
  146. package/src/producer-receipts.ts +636 -0
  147. package/src/runtime-input.test.ts +1 -1
  148. package/src/serial-group-wiring.test.ts +4 -4
  149. package/src/task-results.test.ts +18 -16
  150. package/src/test-backstop.ts +11 -0
  151. package/src/test-clock-policy.test.ts +338 -0
  152. package/src/test-clock-policy.ts +708 -0
  153. package/src/test-timings.test.ts +2 -2
  154. package/src/testing.test.ts +5 -5
  155. package/src/testing.ts +67 -1
  156. package/src/typecheck-test-policy.test.ts +1 -1
  157. package/src/typescript-resolution.test.ts +76 -0
  158. 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 outlive their runner's bound: the verdict
91
- // is about which real bound fired, so no fake clock can stand in for it.
92
- const SLOW_TEST = `import { test } from 'bun:test';\ntest('slow', async () => { await new Promise((r) => setTimeout(r, 5000)); });\n`;
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('bun test --timeout=100 ./slow.test.ts', { timeoutMs: 60_000 }, { 'slow.test.ts': SLOW_TEST }),
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: 60_000 },
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: 60_000 },
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
- expect(await verdictOf('node -e "setInterval(() => console.log(1), 10)"', { timeoutMs: 200 })).toMatchObject({
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 "setTimeout(() => {}, 30000)"', { idleTimeoutMs: 100 })).toMatchObject({
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
- expect(await verdictOf('node -e "process.exit(3)"', { timeoutMs: 5_000 })).toEqual({
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: 5_000 })).toEqual({ outcome: 'passed' });
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({ exitCode: 143, elapsedMs: 120_850, expiry: total, report: { ...cut, failed: ['nt t::assert'] } }),
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({ exitCode: 0, elapsedMs: 850, expiry: null, report: { timedOut: [], cancelled, failed: [] } }),
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
- setInterval(() => console.log('running'), 10);
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
- { timeoutMs: 300, killAfterMs: 5_000 },
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=30000 src', directory)).toBe(
362
- `bun test --reporter=junit --reporter-outfile='${report}' --timeout=30000 src`,
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=30000 --shard=1/4', directory)).toBe(
381
- `../bun-runtime/.runtime/bun test ${flags} --timeout=30000 --shard=1/4`,
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=30000 tests',
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=30000 tests`);
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 test that failed on its own is a failure even when a bound fired too, and the no-progress bound is
191
- * never load: the report's assertions and the idle bound are read first. A test the runner aborted because the total
192
- * bound told its command to stop is not one that failed; one it aborted at the idle bound is a test still running.
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
- BOUNDED_TEST_PER_TEST_TIMEOUT_MS,
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
- BOUNDED_TEST_PER_TEST_TIMEOUT_MS,
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 --timeout=${BOUNDED_TEST_PER_TEST_TIMEOUT_MS}`,
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 wired into `bun test --timeout=N` by the bounded-test
145
- // policy (see BOUNDED_TEST_PER_TEST_TIMEOUT_MS).
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