@smoothbricks/nx-plugin 0.4.25 → 0.4.27

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 (348) hide show
  1. package/README.md +1078 -98
  2. package/dist/bin/smoo-nx-bound-failures.d.ts +3 -0
  3. package/dist/bin/smoo-nx-bound-failures.d.ts.map +1 -0
  4. package/dist/bin/smoo-nx-bound-failures.js +31 -0
  5. package/dist/bin/smoo-nx-cargo-hash.js +28 -3
  6. package/dist/bin/smoo-nx-exec.js +16 -85
  7. package/dist/bin/smoo-nx-failures.d.ts +3 -0
  8. package/dist/bin/smoo-nx-failures.d.ts.map +1 -0
  9. package/dist/bin/smoo-nx-failures.js +3 -0
  10. package/dist/bin/smoo-nx-nextest-extract.js +3 -2
  11. package/dist/bin/smoo-nx-test-walks.d.ts +3 -0
  12. package/dist/bin/smoo-nx-test-walks.d.ts.map +1 -0
  13. package/dist/bin/smoo-nx-test-walks.js +34 -0
  14. package/dist/bounded-test-policy.d.ts +7 -1
  15. package/dist/bounded-test-policy.d.ts.map +1 -1
  16. package/dist/bounded-test-policy.js +101 -40
  17. package/dist/build-state-output-policy.d.ts +25 -0
  18. package/dist/build-state-output-policy.d.ts.map +1 -0
  19. package/dist/build-state-output-policy.js +64 -0
  20. package/dist/cargo-closure-input.d.ts +16 -17
  21. package/dist/cargo-closure-input.d.ts.map +1 -1
  22. package/dist/cargo-closure-input.js +37 -44
  23. package/dist/cargo-dev-profile.d.ts +37 -0
  24. package/dist/cargo-dev-profile.d.ts.map +1 -0
  25. package/dist/cargo-dev-profile.js +108 -0
  26. package/dist/cargo-source-hash.d.ts +50 -8
  27. package/dist/cargo-source-hash.d.ts.map +1 -1
  28. package/dist/cargo-source-hash.js +691 -71
  29. package/dist/cargo-toolchain-policy.d.ts +4 -0
  30. package/dist/cargo-toolchain-policy.d.ts.map +1 -1
  31. package/dist/cargo-toolchain-policy.js +5 -0
  32. package/dist/cargo-workspace.d.ts +108 -12
  33. package/dist/cargo-workspace.d.ts.map +1 -1
  34. package/dist/cargo-workspace.js +299 -18
  35. package/dist/cross-check-policy.d.ts +21 -3
  36. package/dist/cross-check-policy.d.ts.map +1 -1
  37. package/dist/cross-check-policy.js +24 -6
  38. package/dist/disk-command-policy.d.ts +7 -0
  39. package/dist/disk-command-policy.d.ts.map +1 -0
  40. package/dist/disk-command-policy.js +98 -0
  41. package/dist/ensure-built-receipt.d.ts +25 -0
  42. package/dist/ensure-built-receipt.d.ts.map +1 -0
  43. package/dist/ensure-built-receipt.js +261 -0
  44. package/dist/ensure-built-witness.d.ts +57 -0
  45. package/dist/ensure-built-witness.d.ts.map +1 -0
  46. package/dist/ensure-built-witness.js +412 -0
  47. package/dist/ensure-built.d.ts +213 -12
  48. package/dist/ensure-built.d.ts.map +1 -1
  49. package/dist/ensure-built.js +624 -177
  50. package/dist/eslint-file-set.d.ts +7 -0
  51. package/dist/eslint-file-set.d.ts.map +1 -0
  52. package/dist/eslint-file-set.js +12 -0
  53. package/dist/executors/bounded-exec/cpu-pool.d.ts +63 -0
  54. package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -0
  55. package/dist/executors/bounded-exec/cpu-pool.js +379 -0
  56. package/dist/executors/bounded-exec/cpu-tokens.d.ts +82 -0
  57. package/dist/executors/bounded-exec/cpu-tokens.d.ts.map +1 -0
  58. package/dist/executors/bounded-exec/cpu-tokens.js +114 -0
  59. package/dist/executors/bounded-exec/disk-lease.d.ts +61 -0
  60. package/dist/executors/bounded-exec/disk-lease.d.ts.map +1 -0
  61. package/dist/executors/bounded-exec/disk-lease.js +91 -0
  62. package/dist/executors/bounded-exec/executor.d.ts +45 -2
  63. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  64. package/dist/executors/bounded-exec/executor.js +447 -52
  65. package/dist/executors/bounded-exec/gateway-lease.d.ts +52 -0
  66. package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -0
  67. package/dist/executors/bounded-exec/gateway-lease.js +143 -0
  68. package/dist/executors/bounded-exec/hang-diagnostics.d.ts +35 -0
  69. package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -0
  70. package/dist/executors/bounded-exec/hang-diagnostics.js +231 -0
  71. package/dist/executors/bounded-exec/progress.d.ts +35 -0
  72. package/dist/executors/bounded-exec/progress.d.ts.map +1 -0
  73. package/dist/executors/bounded-exec/progress.js +79 -0
  74. package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts +3 -0
  75. package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts.map +1 -0
  76. package/dist/executors/bounded-exec/ram-temp-fixtures.js +12 -0
  77. package/dist/executors/bounded-exec/ram-temp-held.d.ts +91 -0
  78. package/dist/executors/bounded-exec/ram-temp-held.d.ts.map +1 -0
  79. package/dist/executors/bounded-exec/ram-temp-held.js +152 -0
  80. package/dist/executors/bounded-exec/ram-temp.d.ts +223 -0
  81. package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -0
  82. package/dist/executors/bounded-exec/ram-temp.js +1528 -0
  83. package/dist/executors/bounded-exec/schema.d.ts +29 -11
  84. package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
  85. package/dist/executors/bounded-exec/verdict.d.ts +162 -0
  86. package/dist/executors/bounded-exec/verdict.d.ts.map +1 -0
  87. package/dist/executors/bounded-exec/verdict.js +318 -0
  88. package/dist/executors/shard-timings/executor.d.ts +14 -0
  89. package/dist/executors/shard-timings/executor.d.ts.map +1 -0
  90. package/dist/executors/shard-timings/executor.js +25 -0
  91. package/dist/executors/shard-timings/schema.d.ts +4 -0
  92. package/dist/executors/shard-timings/schema.d.ts.map +1 -0
  93. package/dist/executors/shard-timings/schema.js +1 -0
  94. package/dist/failure-summary.d.ts +5 -0
  95. package/dist/failure-summary.d.ts.map +1 -0
  96. package/dist/failure-summary.js +118 -0
  97. package/dist/generators/create-package/generator.d.ts.map +1 -1
  98. package/dist/generators/create-package/generator.js +6 -2
  99. package/dist/index.d.ts +14 -2
  100. package/dist/index.d.ts.map +1 -1
  101. package/dist/index.js +435 -230
  102. package/dist/managed-assets.d.ts +6 -0
  103. package/dist/managed-assets.d.ts.map +1 -1
  104. package/dist/managed-files/ci-workflow.d.ts +13 -0
  105. package/dist/managed-files/ci-workflow.d.ts.map +1 -1
  106. package/dist/managed-files/ci-workflow.js +44 -13
  107. package/dist/managed-files/files.d.ts +7 -1
  108. package/dist/managed-files/files.d.ts.map +1 -1
  109. package/dist/managed-files/files.js +62 -8
  110. package/dist/managed-files/json-edit.d.ts +21 -0
  111. package/dist/managed-files/json-edit.d.ts.map +1 -0
  112. package/dist/managed-files/json-edit.js +295 -0
  113. package/dist/managed-files/managed-format.d.ts +33 -1
  114. package/dist/managed-files/managed-format.d.ts.map +1 -1
  115. package/dist/managed-files/managed-format.js +82 -2
  116. package/dist/managed-files/pr-preview-cleanup-workflow.d.ts +7 -0
  117. package/dist/managed-files/pr-preview-cleanup-workflow.d.ts.map +1 -1
  118. package/dist/managed-files/pr-preview-cleanup-workflow.js +68 -4
  119. package/dist/managed-files/publish-workflow.d.ts.map +1 -1
  120. package/dist/managed-files/publish-workflow.js +231 -48
  121. package/dist/managed-files/tree.d.ts +5 -0
  122. package/dist/managed-files/tree.d.ts.map +1 -1
  123. package/dist/managed-files/tree.js +5 -3
  124. package/dist/manifest-hash.js +3 -2
  125. package/dist/nextest-code-bound.d.ts +62 -0
  126. package/dist/nextest-code-bound.d.ts.map +1 -0
  127. package/dist/nextest-code-bound.js +154 -0
  128. package/dist/nextest-extraction.d.ts +24 -8
  129. package/dist/nextest-extraction.d.ts.map +1 -1
  130. package/dist/nextest-extraction.js +42 -7
  131. package/dist/package-target-policy.d.ts.map +1 -1
  132. package/dist/package-target-policy.js +3 -5
  133. package/dist/release-config-policy.d.ts.map +1 -1
  134. package/dist/release-config-policy.js +3 -5
  135. package/dist/runtime-input.d.ts +14 -0
  136. package/dist/runtime-input.d.ts.map +1 -0
  137. package/dist/runtime-input.js +15 -0
  138. package/dist/rust-tokens.d.ts +11 -0
  139. package/dist/rust-tokens.d.ts.map +1 -0
  140. package/dist/rust-tokens.js +81 -0
  141. package/dist/task-results.d.ts +6 -0
  142. package/dist/task-results.d.ts.map +1 -0
  143. package/dist/task-results.js +61 -0
  144. package/dist/test-program.d.ts +54 -0
  145. package/dist/test-program.d.ts.map +1 -0
  146. package/dist/test-program.js +292 -0
  147. package/dist/test-timings.d.ts +71 -0
  148. package/dist/test-timings.d.ts.map +1 -0
  149. package/dist/test-timings.js +393 -0
  150. package/dist/test-walk-policy.d.ts +103 -0
  151. package/dist/test-walk-policy.d.ts.map +1 -0
  152. package/dist/test-walk-policy.js +657 -0
  153. package/dist/testing.d.ts +177 -0
  154. package/dist/testing.d.ts.map +1 -0
  155. package/dist/testing.js +824 -0
  156. package/dist/type-guards.d.ts +3 -0
  157. package/dist/type-guards.d.ts.map +1 -0
  158. package/dist/type-guards.js +4 -0
  159. package/dist/typecheck-test-policy.d.ts +8 -5
  160. package/dist/typecheck-test-policy.d.ts.map +1 -1
  161. package/dist/typecheck-test-policy.js +113 -100
  162. package/dist/workspace-config-policy.d.ts +8 -0
  163. package/dist/workspace-config-policy.d.ts.map +1 -1
  164. package/dist/workspace-config-policy.js +175 -63
  165. package/dist/workspace-index.d.ts +12 -0
  166. package/dist/workspace-index.d.ts.map +1 -0
  167. package/dist/workspace-index.js +17 -0
  168. package/dist/workspace-manifest.d.ts +37 -1
  169. package/dist/workspace-manifest.d.ts.map +1 -1
  170. package/executors.json +5 -0
  171. package/loader.js +13 -11
  172. package/managed/raw/envrc +33 -62
  173. package/managed/raw/git-format-staged.yml +30 -35
  174. package/managed/raw/patches/nx@23.2.1.patch +3484 -0
  175. package/managed/raw/tooling/direnv/apple-developer.sh +83 -0
  176. package/managed/raw/tooling/direnv/developer-links.ts +607 -17
  177. package/managed/raw/tooling/direnv/devenv.smoo.nix +314 -92
  178. package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +20 -11
  179. package/managed/raw/tooling/direnv/linked-snapshots.ts +845 -0
  180. package/managed/raw/tooling/direnv/nx-socket-dir.sh +82 -0
  181. package/managed/raw/tooling/direnv/repo-path +14 -2
  182. package/managed/raw/tooling/direnv/setup-environment.ts +1009 -118
  183. package/managed/raw/tooling/direnv/toolchain-stamp.ts +45 -3
  184. package/managed/raw/tooling/direnv/ttsc-env.sh +39 -0
  185. package/managed/raw/tooling/git-hooks/commit-msg.sh +5 -6
  186. package/managed/raw/tooling/git-hooks/pre-commit.sh +7 -6
  187. package/managed/raw/tooling/git-hooks/pre-push.sh +20 -15
  188. package/managed/templates/github/actions/cache-nix-devenv/action.yml +6 -6
  189. package/managed/templates/github/actions/cache-node-modules/action.yml +6 -4
  190. package/managed/templates/github/actions/cache-nx/action.yml +1 -1
  191. package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +1 -1
  192. package/managed/templates/github/actions/forgejo-artifact.cjs +99 -0
  193. package/managed/templates/github/actions/forgejo-download-artifact/action.yml +49 -0
  194. package/managed/templates/github/actions/forgejo-download-artifact/index.cjs +7 -0
  195. package/managed/templates/github/actions/forgejo-upload-artifact/action.yml +65 -0
  196. package/managed/templates/github/actions/forgejo-upload-artifact/index.cjs +7 -0
  197. package/managed/templates/github/actions/setup-devenv/action.yml +21 -3
  198. package/managed/templates/github/workflows/managed-files.yml +1 -2
  199. package/nextest.toml +8 -75
  200. package/package.json +75 -13
  201. package/runtime-input.sh +81 -0
  202. package/src/__tests__/counted-cargo-process.ts +286 -0
  203. package/src/__tests__/counted-cargo.ts +730 -0
  204. package/src/__tests__/fixture-cargo-home.ts +36 -0
  205. package/src/__tests__/fixture-nx-env.ts +157 -2
  206. package/src/__tests__/progress-clock.ts +43 -0
  207. package/src/__tests__/runtime-input.ts +23 -0
  208. package/src/bin/smoo-nx-bound-failures.test.ts +127 -0
  209. package/src/bin/smoo-nx-bound-failures.ts +33 -0
  210. package/src/bin/smoo-nx-cargo-hash.ts +28 -3
  211. package/src/bin/smoo-nx-exec.ts +17 -86
  212. package/src/bin/smoo-nx-failures.ts +4 -0
  213. package/src/bin/smoo-nx-nextest-extract.ts +3 -2
  214. package/src/bin/smoo-nx-test-walks.ts +42 -0
  215. package/src/bounded-test-policy.test.ts +268 -22
  216. package/src/bounded-test-policy.ts +114 -42
  217. package/src/build-state-output-policy.test.ts +115 -0
  218. package/src/build-state-output-policy.ts +90 -0
  219. package/src/bun-bootstrap.test.ts +57 -3
  220. package/src/bun-file-packages.test.ts +47 -0
  221. package/src/cargo-closure-input.test.ts +432 -62
  222. package/src/cargo-closure-input.ts +51 -57
  223. package/src/cargo-dev-profile.ts +137 -0
  224. package/src/cargo-resolve-cache.test.ts +1044 -0
  225. package/src/cargo-source-hash.test.ts +203 -93
  226. package/src/cargo-source-hash.ts +762 -75
  227. package/src/cargo-toolchain-policy.ts +6 -0
  228. package/src/cargo-workspace.test.ts +320 -0
  229. package/src/cargo-workspace.ts +344 -18
  230. package/src/cross-check-policy.test.ts +59 -1
  231. package/src/cross-check-policy.ts +25 -6
  232. package/src/disk-command-policy.test.ts +61 -0
  233. package/src/disk-command-policy.ts +107 -0
  234. package/src/ensure-built-receipt.test.ts +184 -0
  235. package/src/ensure-built-receipt.ts +263 -0
  236. package/src/ensure-built-witness.test.ts +344 -0
  237. package/src/ensure-built-witness.ts +252 -0
  238. package/src/ensure-built.test.ts +1043 -483
  239. package/src/ensure-built.ts +870 -197
  240. package/src/eslint-file-set.ts +9 -0
  241. package/src/executors/bounded-exec/cpu-pool.test.ts +454 -0
  242. package/src/executors/bounded-exec/cpu-pool.ts +417 -0
  243. package/src/executors/bounded-exec/cpu-tokens.test.ts +269 -0
  244. package/src/executors/bounded-exec/cpu-tokens.ts +177 -0
  245. package/src/executors/bounded-exec/disk-lease.test.ts +185 -0
  246. package/src/executors/bounded-exec/disk-lease.ts +139 -0
  247. package/src/executors/bounded-exec/executor-host.test.ts +778 -0
  248. package/src/executors/bounded-exec/executor.test.ts +1116 -63
  249. package/src/executors/bounded-exec/executor.ts +565 -67
  250. package/src/executors/bounded-exec/gateway-lease.ts +176 -0
  251. package/src/executors/bounded-exec/hang-diagnostics.test.ts +285 -0
  252. package/src/executors/bounded-exec/hang-diagnostics.ts +283 -0
  253. package/src/executors/bounded-exec/progress.test.ts +79 -0
  254. package/src/executors/bounded-exec/progress.ts +118 -0
  255. package/src/executors/bounded-exec/ram-temp-fixtures.ts +12 -0
  256. package/src/executors/bounded-exec/ram-temp-held.test.ts +264 -0
  257. package/src/executors/bounded-exec/ram-temp-held.ts +242 -0
  258. package/src/executors/bounded-exec/ram-temp-host.test.ts +605 -0
  259. package/src/executors/bounded-exec/ram-temp.test.ts +674 -0
  260. package/src/executors/bounded-exec/ram-temp.ts +1918 -0
  261. package/src/executors/bounded-exec/schema.json +11 -5
  262. package/src/executors/bounded-exec/schema.ts +27 -11
  263. package/src/executors/bounded-exec/verdict.test.ts +440 -0
  264. package/src/executors/bounded-exec/verdict.ts +433 -0
  265. package/src/executors/shard-timings/executor.ts +36 -0
  266. package/src/executors/shard-timings/schema.json +21 -0
  267. package/src/executors/shard-timings/schema.ts +4 -0
  268. package/src/failure-summary.ts +119 -0
  269. package/src/generators/bounded-test-targets/generator.test.ts +4 -4
  270. package/src/generators/bun-test-tracing/generator.test.ts +2 -2
  271. package/src/generators/create-package/generator.test.ts +6 -0
  272. package/src/generators/create-package/generator.ts +6 -2
  273. package/src/host-controller-wiring.test.ts +31 -0
  274. package/src/index.test.ts +1070 -360
  275. package/src/index.ts +524 -255
  276. package/src/linked-snapshots.nx.test.ts +172 -0
  277. package/src/managed-assets.ts +12 -0
  278. package/src/managed-files/ci-workflow.ts +54 -13
  279. package/src/managed-files/files.ts +65 -9
  280. package/src/managed-files/forgejo-artifact.test.ts +395 -0
  281. package/src/managed-files/generator.test.ts +60 -1
  282. package/src/managed-files/json-edit.test.ts +216 -0
  283. package/src/managed-files/json-edit.ts +290 -0
  284. package/src/managed-files/managed-format-json.test.ts +308 -0
  285. package/src/managed-files/managed-format.ts +90 -2
  286. package/src/managed-files/pr-preview-cleanup-workflow.ts +69 -3
  287. package/src/managed-files/publish-workflow.ts +285 -67
  288. package/src/managed-files/repo-path.test.ts +129 -0
  289. package/src/managed-files/trace-db-artifact.test.ts +7 -0
  290. package/src/managed-files/tree.ts +11 -3
  291. package/src/manifest-hash.ts +3 -2
  292. package/src/nextest-code-bound.test.ts +155 -0
  293. package/src/nextest-code-bound.ts +195 -0
  294. package/src/nextest-extraction.test.ts +37 -5
  295. package/src/nextest-extraction.ts +51 -9
  296. package/src/nextest-partitions.test.ts +495 -0
  297. package/src/nx-cache-bound.test.ts +109 -0
  298. package/src/nx-cache-restore-mtime.test.ts +170 -0
  299. package/src/nx-daemon-claim.test.ts +277 -0
  300. package/src/nx-daemon-idle-cpu.test.ts +81 -0
  301. package/src/nx-daemon-idle-policy.test.ts +51 -0
  302. package/src/nx-daemon-ignore-files.test.ts +210 -0
  303. package/src/nx-daemon-root-normalization.test.ts +105 -0
  304. package/src/nx-daemon-validity.test.ts +925 -0
  305. package/src/nx-dot-input-policy.test.ts +353 -0
  306. package/src/nx-failure-life-cycles.test.ts +207 -0
  307. package/src/nx-files-archive-racy.test.ts +97 -0
  308. package/src/nx-foreign-workspace-env.test.ts +329 -0
  309. package/src/nx-incomplete-run-summary.test.ts +70 -0
  310. package/src/nx-plugin-load-errors.test.ts +120 -0
  311. package/src/nx-project-resolution-cache.test.ts +176 -0
  312. package/src/nx-raw-inputs.test.ts +166 -0
  313. package/src/nx-resident-graph-workers.test.ts +112 -0
  314. package/src/nx-run-information.test.ts +118 -0
  315. package/src/nx-skipped-task-exit.test.ts +180 -0
  316. package/src/nx-state-location.test.ts +63 -0
  317. package/src/nx-store-resolution.test.ts +99 -0
  318. package/src/nx-task-graph-cycles.test.ts +148 -0
  319. package/src/nx-task-output-lease.test.ts +414 -0
  320. package/src/nx-use-local.test.ts +103 -0
  321. package/src/package-target-policy.ts +3 -6
  322. package/src/release-config-policy.ts +3 -6
  323. package/src/runtime-input.test.ts +215 -0
  324. package/src/runtime-input.ts +17 -0
  325. package/src/rust-tokens.ts +78 -0
  326. package/src/serial-group-wiring.test.ts +326 -0
  327. package/src/task-history-namespace.test.ts +181 -0
  328. package/src/task-results.test.ts +226 -0
  329. package/src/task-results.ts +75 -0
  330. package/src/test-program.test.ts +303 -0
  331. package/src/test-program.ts +341 -0
  332. package/src/test-timings.test.ts +240 -0
  333. package/src/test-timings.ts +311 -0
  334. package/src/test-walk-policy.test.ts +585 -0
  335. package/src/test-walk-policy.ts +731 -0
  336. package/src/testing.test.ts +509 -0
  337. package/src/testing.ts +922 -0
  338. package/src/type-guards.ts +4 -0
  339. package/src/typecheck-test-policy.test.ts +496 -11
  340. package/src/typecheck-test-policy.ts +137 -103
  341. package/src/workspace-config-policy.test.ts +212 -13
  342. package/src/workspace-config-policy.ts +101 -73
  343. package/src/workspace-index.ts +18 -0
  344. package/src/workspace-manifest.ts +41 -1
  345. package/test-timings.json +85 -28
  346. package/managed/raw/tooling/direnv/inherited-devenv.ts +0 -615
  347. package/managed/raw/tooling/direnv/shared-caches.sh +0 -53
  348. package/src/__tests__/in-process-nx-index.ts +0 -9
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "version": 2,
3
3
  "title": "Bounded Exec",
4
- "description": "Run one shell command under an absolute ceiling and a no-progress bound, with process-tree cleanup.",
4
+ "description": "Run one shell command under a no-progress bound or an absolute ceiling, with process-tree cleanup.",
5
5
  "type": "object",
6
6
  "cli": "nx",
7
7
  "outputCapture": "pipe",
8
8
  "additionalProperties": true,
9
- "required": ["command", "timeoutMs"],
9
+ "required": ["command"],
10
+ "anyOf": [{ "required": ["timeoutMs"] }, { "required": ["idleTimeoutMs"] }],
10
11
  "properties": {
11
12
  "command": {
12
13
  "type": "string",
@@ -26,18 +27,23 @@
26
27
  "timeoutMs": {
27
28
  "type": "number",
28
29
  "minimum": 1,
29
- "description": "Absolute wall-clock ceiling in milliseconds. A backstop against an unbounded run, not a performance budget."
30
+ "description": "Absolute wall-clock ceiling in milliseconds, for a command that reports no tests. A backstop against an unbounded run, not a performance budget. A test target names idleTimeoutMs instead."
30
31
  },
31
32
  "idleTimeoutMs": {
32
33
  "type": "number",
33
34
  "minimum": 1,
34
- "description": "Kill the process tree after this many milliseconds with no stdout or stderr. Detects a wedged process independently of machine speed and load. Omit for no progress bound."
35
+ "description": "Kill the process tree when no test has finished for this many milliseconds: a nextest status line with its run counter, a bun result line or dot. Output that reports no finished test (a SLOW warning, a heartbeat) is not progress. A command that reports no tests makes progress only by exiting. Omit for no progress bound."
35
36
  },
36
37
  "killAfterMs": {
37
38
  "type": "number",
38
39
  "minimum": 0,
39
40
  "default": 10000,
40
- "description": "Milliseconds to wait after graceful termination before force-killing the process tree."
41
+ "description": "Most milliseconds a timed-out or CPU-grant-revoked command gets after graceful termination before its process group is force-killed. The grace ends early when the command exits; whatever it leaves in its process group is force-killed then."
42
+ },
43
+ "parallelism": {
44
+ "type": "integer",
45
+ "minimum": 1,
46
+ "description": "Requested threads or processes before inherited runner ceilings: positive NEXTEST_TEST_THREADS and CARGO_BUILD_JOBS cap their respective runners, and configured counts may only lower an inherited ceiling. Omit to let the command decide (nextest and cargo one per core, `bun test --parallel=N` N, anything else one). Runner concurrency is min(bounded request, granted tokens); the actual held grant reaches the command as BOUNDED_EXEC_CPU_TOKENS, with its sub-pool in BOUNDED_EXEC_CPU_POOL."
41
47
  },
42
48
  "forwardAllArgs": {
43
49
  "type": "boolean",
@@ -1,22 +1,38 @@
1
- export interface BoundedExecOptions {
1
+ /**
2
+ * A command and the bounds that end it. At least one bound is required: a run with neither would block Nx forever.
3
+ * A test target names only `idleTimeoutMs` (`bounded-test-policy.ts`); `timeoutMs` is for commands that report no
4
+ * tests, whose only progress is exiting.
5
+ */
6
+ export type BoundedExecOptions = BoundedExecCommand & BoundedExecBounds;
7
+
8
+ export type BoundedExecBounds =
9
+ | { timeoutMs: number; idleTimeoutMs?: number }
10
+ | { timeoutMs?: undefined; idleTimeoutMs: number };
11
+
12
+ export interface BoundedExecCommand {
2
13
  command: string;
3
14
  cwd?: string;
4
15
  env?: Record<string, string>;
5
- timeoutMs: number;
16
+ /** Absolute wall-clock ceiling: a backstop against an unbounded run, not a performance budget. */
17
+ timeoutMs?: number;
6
18
  /**
7
- * Kill the process tree when it has produced no stdout or stderr for this
8
- * long. Absent means no progress bound.
19
+ * Kill the process tree when no test has finished for this long (`progress.ts`). Absent means no progress bound.
9
20
  *
10
- * This is the bound that catches a hang. A wedged process — a flock deadlock
11
- * between two cargo writers, a transformer waiting on a lock nobody will
12
- * release, a runner that ignores its own per-test timeout — emits nothing at
13
- * all, so silence is the signal. Unlike `timeoutMs` it does not scale with
14
- * machine speed or load: a machine ten times slower still prints progress,
15
- * just further apart, and each gap is bounded by the slowest single unit of
16
- * work rather than by the total.
21
+ * This is the bound that catches a hang. A hung test never finishes, whatever its runner keeps printing about it,
22
+ * and the tests still running when it fires are named in the verdict. Unlike `timeoutMs` it does not scale with
23
+ * the size of the suite or the load on the machine: a machine ten times slower still finishes tests, just further
24
+ * apart, and each gap is bounded by the slowest single test rather than by the total. A command that reports no
25
+ * tests makes progress only by exiting.
17
26
  */
18
27
  idleTimeoutMs?: number;
19
28
  killAfterMs?: number;
29
+ /**
30
+ * The most threads or processes the command runs at once, which is how many CPU tokens it asks
31
+ * its live parent pool or the cowshed host budget for. Absent, the runner in the command decides:
32
+ * nextest and cargo one per core, `bun test --parallel=N` N, anything else one. The actual grant
33
+ * reaches the command as `BOUNDED_EXEC_CPU_TOKENS`, with its sub-pool in `BOUNDED_EXEC_CPU_POOL`.
34
+ */
35
+ parallelism?: number;
20
36
  forwardAllArgs?: boolean;
21
37
  args?: string | string[];
22
38
  __unparsed__?: string[];
@@ -0,0 +1,440 @@
1
+ import { afterEach, describe, expect, it } from 'bun:test';
2
+ import { spawnSync } from 'node:child_process';
3
+ import { mkdir, mkdtemp, readFile, rm, symlink, writeFile } from 'node:fs/promises';
4
+ import { tmpdir } from 'node:os';
5
+ import { dirname, join } from 'node:path';
6
+
7
+ import { onProgressClock } from '../../__tests__/progress-clock.js';
8
+ import {
9
+ type BoundedExecContext,
10
+ createProcessTreeKiller,
11
+ type ProcessTreeKiller,
12
+ runBoundedExec,
13
+ } from './executor.js';
14
+ import type { BoundedExecBounds } from './schema.js';
15
+ import {
16
+ type BoundedExecVerdict,
17
+ failedTasksOfRun,
18
+ JUNIT_FILE,
19
+ judgeOperationalFailure,
20
+ judgeRun,
21
+ junitFailures,
22
+ readRecord,
23
+ taskDirectory,
24
+ withJunitReport,
25
+ writeRecord,
26
+ } from './verdict.js';
27
+
28
+ const roots: string[] = [];
29
+ const ownedProcessGroups = new Set<number>();
30
+ const originalStdoutWrite = process.stdout.write;
31
+ const originalStderrWrite = process.stderr.write;
32
+
33
+ afterEach(async () => {
34
+ process.stdout.write = originalStdoutWrite;
35
+ process.stderr.write = originalStderrWrite;
36
+ for (const pid of ownedProcessGroups) {
37
+ try {
38
+ process.kill(-pid, 'SIGKILL');
39
+ } catch (cause) {
40
+ if (!(cause instanceof Error && 'code' in cause && cause.code === 'ESRCH')) {
41
+ throw new Error(`cleanup owned abort-report process group pgid=${pid} failed`, { cause });
42
+ }
43
+ } finally {
44
+ ownedProcessGroups.delete(pid);
45
+ }
46
+ }
47
+ await Promise.all(roots.splice(0).map((root) => rm(root, { recursive: true, force: true })));
48
+ });
49
+
50
+ async function workspace(): Promise<{ root: string; data: string; context: BoundedExecContext }> {
51
+ const root = await mkdtemp(join(tmpdir(), 'smoothbricks-bounded-verdict-'));
52
+ roots.push(root);
53
+ const data = join(root, '.nx', 'workspace-data');
54
+ return {
55
+ root,
56
+ data,
57
+ context: { root, record: { task: { id: 'app:test', hash: '42' }, directory: taskDirectory(data, 'app:test') } },
58
+ };
59
+ }
60
+
61
+ /**
62
+ * Run `command` as task app:test and answer the verdict bounded-exec recorded for it. `links` name
63
+ * files of the workspace that link to the given targets.
64
+ */
65
+ async function verdictOf(
66
+ command: string,
67
+ bounds: BoundedExecBounds & { killAfterMs?: number },
68
+ files: Record<string, string> = {},
69
+ links: Record<string, string> = {},
70
+ prepareKiller?: (root: string) => Promise<ProcessTreeKiller>,
71
+ ): Promise<BoundedExecVerdict | undefined> {
72
+ const { root, context } = await workspace();
73
+ for (const [name, contents] of Object.entries(files)) {
74
+ await writeFile(join(root, name), contents);
75
+ }
76
+ for (const [name, target] of Object.entries(links)) {
77
+ await mkdir(dirname(join(root, name)), { recursive: true });
78
+ await symlink(target, join(root, name));
79
+ }
80
+ process.stdout.write = () => true;
81
+ process.stderr.write = () => true;
82
+ const killer = (await prepareKiller?.(root)) ?? createProcessTreeKiller();
83
+ await runBoundedExec({ command, killAfterMs: 0, ...bounds }, context, killer, null, null);
84
+ const record = await readRecord(context.record?.directory ?? '');
85
+ expect(record?.task).toBe('app:test');
86
+ expect(record?.hash).toBe('42');
87
+ return record?.verdict;
88
+ }
89
+
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
+ const FAILING_TEST = `import { expect, test } from 'bun:test';\ntest('wrong', () => { expect(1).toBe(2); });\n`;
94
+
95
+ describe('bounded-exec verdicts', () => {
96
+ it('records a bun run whose only failure is a per-test timeout as a bound', async () => {
97
+ expect(
98
+ await verdictOf('bun test --timeout=100 ./slow.test.ts', { timeoutMs: 60_000 }, { 'slow.test.ts': SLOW_TEST }),
99
+ ).toEqual({
100
+ outcome: 'bound',
101
+ bound: 'test',
102
+ tests: ['slow'],
103
+ });
104
+ });
105
+
106
+ it('records a path-pinned bun run whose only failure is a per-test timeout as a bound', async () => {
107
+ expect(
108
+ await verdictOf(
109
+ '.runtime/bun test --timeout=100 ./slow.test.ts',
110
+ { timeoutMs: 60_000 },
111
+ { 'slow.test.ts': SLOW_TEST },
112
+ { '.runtime/bun': process.execPath },
113
+ ),
114
+ ).toEqual({ outcome: 'bound', bound: 'test', tests: ['slow'] });
115
+ });
116
+
117
+ it('records an assertion as a failure even beside a timeout', async () => {
118
+ expect(
119
+ await verdictOf(
120
+ 'bun test --timeout=100 ./slow.test.ts ./failing.test.ts',
121
+ { timeoutMs: 60_000 },
122
+ { 'slow.test.ts': SLOW_TEST, 'failing.test.ts': FAILING_TEST },
123
+ ),
124
+ ).toEqual({ outcome: 'failed', exitCode: 1, tests: ['wrong'] });
125
+ });
126
+
127
+ 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({
129
+ outcome: 'bound',
130
+ bound: 'total',
131
+ limitMs: 200,
132
+ });
133
+ expect(await verdictOf('node -e "setTimeout(() => {}, 30000)"', { idleTimeoutMs: 100 })).toMatchObject({
134
+ outcome: 'wedged',
135
+ idleMs: 100,
136
+ tests: [],
137
+ });
138
+ });
139
+
140
+ it('records a runner that warns of a slow test but finishes none as a wedge naming that test', async () => {
141
+ // nextest's own lines: one test passes, the other only ever says SLOW. A bound on silence would never fire.
142
+ const runner = [
143
+ "console.error(' PASS [ 0.010s] (1/2) fake tests::quick');",
144
+ "setInterval(() => console.error(' SLOW [> 0.050s] (───) fake tests::hangs'), 50);",
145
+ '',
146
+ ].join('\n');
147
+ const { root, context } = await workspace();
148
+ await writeFile(join(root, 'runner.js'), runner);
149
+ // The window ends only once the runner has said SLOW, however long node takes to start.
150
+ await onProgressClock(
151
+ (chunk) => chunk.includes('SLOW [>'),
152
+ 400,
153
+ () =>
154
+ runBoundedExec(
155
+ { command: 'node runner.js', idleTimeoutMs: 400, killAfterMs: 0 },
156
+ context,
157
+ createProcessTreeKiller(),
158
+ null,
159
+ null,
160
+ ),
161
+ );
162
+ expect((await readRecord(context.record?.directory ?? ''))?.verdict).toMatchObject({
163
+ outcome: 'wedged',
164
+ idleMs: 400,
165
+ tests: ['fake tests::hangs'],
166
+ });
167
+ });
168
+
169
+ it('names the tests nextest aborted at the progress bound beside those it said were running, once each', () => {
170
+ const report = { timedOut: [], cancelled: ['nt tests::hangs', 'nt tests::young'], failed: [] };
171
+ expect(
172
+ judgeRun({
173
+ exitCode: 100,
174
+ elapsedMs: 900,
175
+ expiry: { kind: 'idle', limitMs: 400, tests: ['nt tests::hangs'] },
176
+ report,
177
+ }),
178
+ ).toEqual({ outcome: 'wedged', idleMs: 400, elapsedMs: 900, tests: ['nt tests::hangs', 'nt tests::young'] });
179
+ });
180
+
181
+ 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({
183
+ outcome: 'failed',
184
+ exitCode: 3,
185
+ tests: [],
186
+ });
187
+ expect(await verdictOf('node -e ""', { timeoutMs: 5_000 })).toEqual({ outcome: 'passed' });
188
+ });
189
+
190
+ it("reads nextest's typed timeout from its JUnit report", () => {
191
+ // A cargo-nextest 0.9.143 report: one test terminated at its slow-timeout, one assertion.
192
+ const report = `<?xml version="1.0" encoding="UTF-8"?>
193
+ <testsuites name="nextest-run" tests="3" failures="2">
194
+ <testsuite name="nt" tests="3" failures="2">
195
+ <testcase name="t::ok" classname="nt" time="0.095"/>
196
+ <testcase name="t::assert" classname="nt" time="0.095">
197
+ <failure message="thread &apos;t::assert&apos; panicked at src/lib.rs:4:27" type="test failure with exit code 101">assertion failed</failure>
198
+ <system-out>
199
+ test t::assert ... FAILED
200
+ </system-out>
201
+ </testcase>
202
+ <testcase name="t::slow" classname="nt" time="1.003">
203
+ <failure type="test timeout"/>
204
+ <system-out>
205
+ running 1 test
206
+ </system-out>
207
+ </testcase>
208
+ </testsuite>
209
+ </testsuites>`;
210
+ expect(junitFailures(report)).toEqual({ timedOut: ['nt t::slow'], cancelled: [], failed: ['nt t::assert'] });
211
+ });
212
+
213
+ it("reads nextest's abort of a test its command was told to stop as neither a failure nor a timeout", () => {
214
+ // cargo-nextest 0.9.143, SIGTERM delivered to the run: the tests still running are reported as `test abort`.
215
+ // A test that dies of any other signal (here SIGSEGV) is a crash of the test itself.
216
+ const abort = (name: string, signal: string) =>
217
+ `<testcase name="${name}" classname="nt" time="0.85"><failure message="process aborted with signal ${signal}" type="test abort">process aborted with signal ${signal}</failure><system-out>\nrunning 1 test\n</system-out></testcase>`;
218
+ const report = `<testsuites name="nextest-run" tests="4" failures="3"><testsuite name="nt" tests="4" failures="3">
219
+ <testcase name="t::ok" classname="nt" time="0.1"/>
220
+ ${abort('t::cut', '15 (SIGTERM)')}
221
+ ${abort('t::killed', '9 (SIGKILL)')}
222
+ ${abort('t::crash', '11 (SIGSEGV)')}
223
+ </testsuite></testsuites>`;
224
+ expect(junitFailures(report)).toEqual({
225
+ timedOut: [],
226
+ cancelled: ['nt t::cut', 'nt t::killed'],
227
+ failed: ['nt t::crash'],
228
+ });
229
+ });
230
+
231
+ it('records a run its ceiling stopped as a bound when the only failures are the tests the stop aborted', () => {
232
+ const total = { kind: 'total', limitMs: 120_000 } as const;
233
+ const cut = { timedOut: [], cancelled: ['nt t::cut'], failed: [] };
234
+ expect(judgeRun({ exitCode: 143, elapsedMs: 120_850, expiry: total, report: cut })).toEqual({
235
+ outcome: 'bound',
236
+ bound: 'total',
237
+ limitMs: 120_000,
238
+ elapsedMs: 120_850,
239
+ });
240
+ // An assertion that failed before the ceiling is still a failure, and an abort nobody asked for is one too.
241
+ expect(
242
+ judgeRun({ exitCode: 143, elapsedMs: 120_850, expiry: total, report: { ...cut, failed: ['nt t::assert'] } }),
243
+ ).toEqual({ outcome: 'failed', exitCode: 143, tests: ['nt t::assert'] });
244
+ expect(judgeRun({ exitCode: 143, elapsedMs: 850, expiry: null, report: cut })).toEqual({
245
+ outcome: 'failed',
246
+ exitCode: 143,
247
+ tests: ['nt t::cut'],
248
+ });
249
+ });
250
+
251
+ it('records a test aborted with no total bound to explain it as a failure, whatever the exit or the other tests say', () => {
252
+ const cancelled = ['nt t::cut'];
253
+ // Exit 0 with an abort in the report: the abort is still not nothing.
254
+ expect(
255
+ judgeRun({ exitCode: 0, elapsedMs: 850, expiry: null, report: { timedOut: [], cancelled, failed: [] } }),
256
+ ).toEqual({
257
+ outcome: 'failed',
258
+ exitCode: 0,
259
+ tests: cancelled,
260
+ });
261
+ // A per-test timeout beside an abort nobody asked for is not a per-test bound: the abort failed the run.
262
+ expect(
263
+ judgeRun({
264
+ exitCode: 100,
265
+ elapsedMs: 850,
266
+ expiry: null,
267
+ report: { timedOut: ['nt t::slow'], cancelled, failed: [] },
268
+ }),
269
+ ).toEqual({ outcome: 'failed', exitCode: 100, tests: cancelled });
270
+ // With the total bound fired, the same report is the bound's own casualties.
271
+ expect(
272
+ judgeRun({
273
+ exitCode: 143,
274
+ elapsedMs: 120_850,
275
+ expiry: { kind: 'total', limitMs: 120_000 },
276
+ report: { timedOut: ['nt t::slow'], cancelled, failed: [] },
277
+ }),
278
+ ).toMatchObject({ outcome: 'bound', bound: 'total' });
279
+ });
280
+
281
+ it('keeps CPU operational failures ordinary even beside test timeouts or a successful command exit', () => {
282
+ expect(
283
+ judgeOperationalFailure(0, {
284
+ failed: ['nt t::assert'],
285
+ timedOut: ['nt t::slow'],
286
+ cancelled: ['nt t::cut'],
287
+ }),
288
+ ).toEqual({
289
+ outcome: 'failed',
290
+ exitCode: 1,
291
+ tests: ['nt t::assert', 'nt t::slow', 'nt t::cut'],
292
+ });
293
+ expect(judgeOperationalFailure(143, { failed: [], timedOut: ['nt t::slow'], cancelled: [] })).toEqual({
294
+ outcome: 'failed',
295
+ exitCode: 143,
296
+ tests: ['nt t::slow'],
297
+ });
298
+ expect(judgeOperationalFailure(0, null)).toEqual({ outcome: 'failed', exitCode: 1, tests: [] });
299
+ });
300
+
301
+ it('records a runner that reports its own abort at the total ceiling as a bound, end to end', async () => {
302
+ // A stand-in for nextest: on SIGTERM it writes the JUnit report with the test it was running aborted, exits 143.
303
+ const runner = `const fs = require('node:fs');
304
+ process.on('SIGTERM', () => {
305
+ fs.writeFileSync(process.env.BOUNDED_EXEC_JUNIT, '<testsuites name="nextest-run" tests="2" failures="1"><testsuite name="nt" tests="2" failures="1"><testcase name="t::ok" classname="nt"/><testcase name="t::cut" classname="nt"><failure message="process aborted with signal 15 (SIGTERM)" type="test abort">process aborted with signal 15 (SIGTERM)</failure></testcase></testsuite></testsuites>');
306
+ process.exit(143);
307
+ });
308
+ fs.writeFileSync('runner-ready.fifo', 'ready pid=' + process.pid + '\\n');
309
+ setInterval(() => console.log('running'), 10);
310
+ `;
311
+ let armed: Promise<void> | undefined;
312
+ let report = '';
313
+ const verdict = await verdictOf(
314
+ 'exec node runner.js',
315
+ { timeoutMs: 300, killAfterMs: 5_000 },
316
+ { 'runner.js': runner },
317
+ {},
318
+ async (root) => {
319
+ const ready = join(root, 'runner-ready.fifo');
320
+ report = join(taskDirectory(join(root, '.nx', 'workspace-data'), 'app:test'), JUNIT_FILE);
321
+ expect(spawnSync('mkfifo', [ready]).status).toBe(0);
322
+ const real = createProcessTreeKiller();
323
+ return {
324
+ async kill(pid, signal) {
325
+ ownedProcessGroups.add(pid);
326
+ armed ??= readFile(ready, 'utf8').then((text) => {
327
+ // Bare `ps` through PATH: NixOS has no /bin/ps, and a failed spawn leaves stdout null.
328
+ const observed = spawnSync('ps', ['-o', 'pid=,pgid=,stat=', '-p', String(pid)], {
329
+ encoding: 'utf8',
330
+ });
331
+ const observedStdout = observed.stdout ?? '';
332
+ const detail = `abort-report handler pid=${pid} signal=${signal} ready=${JSON.stringify(text)} state=${observedStdout.trim()} status=${observed.status} stderr=${observed.stderr} error=${observed.error}`;
333
+ expect(text, detail).toBe(`ready pid=${pid}\n`);
334
+ expect(observed.status, detail).toBe(0);
335
+ const [seenPid, pgid, state] = observedStdout.trim().split(/\s+/);
336
+ expect(Number(seenPid), detail).toBe(pid);
337
+ expect(Number(pgid), detail).toBe(pid);
338
+ expect(state !== undefined && !state.startsWith('Z'), detail).toBe(true);
339
+ });
340
+ await armed;
341
+ await real.kill(pid, signal);
342
+ },
343
+ };
344
+ },
345
+ );
346
+ expect(armed, 'abort-report handler readiness must precede the total-bound signal').toBeDefined();
347
+ await armed;
348
+ expect(verdict).toMatchObject({ outcome: 'bound', bound: 'total', limitMs: 300 });
349
+ expect(junitFailures(await readFile(report, 'utf8')), `runner abort report ${report} must name nt t::cut`).toEqual({
350
+ timedOut: [],
351
+ cancelled: ['nt t::cut'],
352
+ failed: [],
353
+ });
354
+ });
355
+
356
+ it('asks the one runner in a command for a report, and leaves two runners alone', async () => {
357
+ const { context } = await workspace();
358
+ const directory = context.record?.directory ?? '';
359
+ await mkdir(directory, { recursive: true });
360
+ 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`,
363
+ );
364
+ const nextest = await withJunitReport('extracted="$(x)" && cargo --frozen nextest run -E all', directory);
365
+ expect(nextest).toBe(
366
+ `extracted="$(x)" && cargo --frozen nextest run --tool-config-file 'smoo-report:${join(directory, 'nextest-report.toml')}' -E all`,
367
+ );
368
+ expect(await readFile(join(directory, 'nextest-report.toml'), 'utf8')).toBe(
369
+ `[profile.default.junit]\npath = ${JSON.stringify(report)}\n`,
370
+ );
371
+ expect(await withJunitReport('bun test a && bun test b', directory)).toBe('bun test a && bun test b');
372
+ expect(await withJunitReport('bun scripts/test-shard.ts 1', directory)).toBe('bun scripts/test-shard.ts 1');
373
+ });
374
+
375
+ it('finds bun by its basename, keeps the binary the target chose, and leaves lookalikes alone', async () => {
376
+ const { context } = await workspace();
377
+ const directory = context.record?.directory ?? '';
378
+ await mkdir(directory, { recursive: true });
379
+ 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`,
382
+ );
383
+ expect(
384
+ await withJunitReport(
385
+ 'BUN_EXE=../bun-runtime/.runtime/bun ../bun-runtime/.runtime/bun test --timeout=30000 tests',
386
+ directory,
387
+ ),
388
+ ).toBe(`BUN_EXE=../bun-runtime/.runtime/bun ../bun-runtime/.runtime/bun test ${flags} --timeout=30000 tests`);
389
+ expect(await withJunitReport('cd pkg && $RUNTIME/bun test src', directory)).toBe(
390
+ `cd pkg && $RUNTIME/bun test ${flags} src`,
391
+ );
392
+ expect(await withJunitReport('../x/.runtime/bun test a && $HOME/.bun/bin/bun test b', directory)).toBe(
393
+ '../x/.runtime/bun test a && $HOME/.bun/bin/bun test b',
394
+ );
395
+ // The basename must be exactly `bun`, and an assignment is not a command word.
396
+ expect(await withJunitReport('../x/debug-bun test src', directory)).toBe('../x/debug-bun test src');
397
+ expect(await withJunitReport('../x/bun-test test src', directory)).toBe('../x/bun-test test src');
398
+ expect(await withJunitReport('BUN_EXE=../x/bun test', directory)).toBe('BUN_EXE=../x/bun test');
399
+ });
400
+
401
+ it('calls a failed run bound only when every failed task has a bound verdict for its hash', async () => {
402
+ const { data } = await workspace();
403
+ const record = async (task: string, hash: string, verdict: BoundedExecVerdict) => {
404
+ const directory = taskDirectory(data, task);
405
+ await mkdir(directory, { recursive: true });
406
+ await writeRecord(directory, { task, hash, verdict });
407
+ };
408
+ await record('a:test-1', '1', { outcome: 'bound', bound: 'total', limitMs: 120_000, elapsedMs: 120_004 });
409
+ await record('b:cargo-test', '2', { outcome: 'bound', bound: 'test', tests: ['b t::slow'] });
410
+ await record('c:test', 'old', { outcome: 'bound', bound: 'test', tests: ['c slow'] });
411
+ const run = (tasks: { taskId: string; hash: string; status: number }[]) => ({ run: {}, tasks });
412
+
413
+ const bound = await failedTasksOfRun(
414
+ run([
415
+ { taskId: 'a:test-1', hash: '1', status: 1 },
416
+ { taskId: 'b:cargo-test', hash: '2', status: 1 },
417
+ { taskId: 'c:lint', hash: '3', status: 0 },
418
+ ]),
419
+ data,
420
+ );
421
+ expect(bound.map((task) => [task.task, task.bound])).toEqual([
422
+ ['a:test-1', true],
423
+ ['b:cargo-test', true],
424
+ ]);
425
+
426
+ const mixed = await failedTasksOfRun(
427
+ run([
428
+ { taskId: 'a:test-1', hash: '1', status: 1 },
429
+ { taskId: 'c:test', hash: 'new', status: 1 },
430
+ { taskId: 'd:lint', hash: '4', status: 1 },
431
+ ]),
432
+ data,
433
+ );
434
+ expect(mixed).toEqual([
435
+ expect.objectContaining({ task: 'a:test-1', bound: true }),
436
+ { task: 'c:test', bound: false, reason: "its verdict is from hash old, not this run's new" },
437
+ { task: 'd:lint', bound: false, reason: 'no bounded-exec verdict' },
438
+ ]);
439
+ });
440
+ });