@smoothbricks/nx-plugin 0.4.26 → 0.4.28

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 (343) hide show
  1. package/README.md +994 -117
  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 +15 -73
  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 +3 -2
  21. package/dist/cargo-closure-input.d.ts.map +1 -1
  22. package/dist/cargo-closure-input.js +16 -15
  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 +43 -6
  27. package/dist/cargo-source-hash.d.ts.map +1 -1
  28. package/dist/cargo-source-hash.js +309 -73
  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 +101 -5
  33. package/dist/cargo-workspace.d.ts.map +1 -1
  34. package/dist/cargo-workspace.js +291 -10
  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 +207 -12
  48. package/dist/ensure-built.d.ts.map +1 -1
  49. package/dist/ensure-built.js +576 -202
  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 +370 -138
  102. package/dist/managed-files/ci-workflow.d.ts +13 -0
  103. package/dist/managed-files/ci-workflow.d.ts.map +1 -1
  104. package/dist/managed-files/ci-workflow.js +44 -13
  105. package/dist/managed-files/files.d.ts +7 -1
  106. package/dist/managed-files/files.d.ts.map +1 -1
  107. package/dist/managed-files/files.js +62 -8
  108. package/dist/managed-files/json-edit.d.ts +21 -0
  109. package/dist/managed-files/json-edit.d.ts.map +1 -0
  110. package/dist/managed-files/json-edit.js +295 -0
  111. package/dist/managed-files/managed-format.d.ts +33 -1
  112. package/dist/managed-files/managed-format.d.ts.map +1 -1
  113. package/dist/managed-files/managed-format.js +82 -2
  114. package/dist/managed-files/pr-preview-cleanup-workflow.d.ts +7 -0
  115. package/dist/managed-files/pr-preview-cleanup-workflow.d.ts.map +1 -1
  116. package/dist/managed-files/pr-preview-cleanup-workflow.js +68 -4
  117. package/dist/managed-files/publish-workflow.d.ts.map +1 -1
  118. package/dist/managed-files/publish-workflow.js +231 -48
  119. package/dist/managed-files/tree.d.ts +5 -0
  120. package/dist/managed-files/tree.d.ts.map +1 -1
  121. package/dist/managed-files/tree.js +5 -3
  122. package/dist/manifest-hash.d.ts.map +1 -1
  123. package/dist/manifest-hash.js +2 -5
  124. package/dist/nextest-code-bound.d.ts +62 -0
  125. package/dist/nextest-code-bound.d.ts.map +1 -0
  126. package/dist/nextest-code-bound.js +154 -0
  127. package/dist/nextest-extraction.d.ts +24 -8
  128. package/dist/nextest-extraction.d.ts.map +1 -1
  129. package/dist/nextest-extraction.js +42 -7
  130. package/dist/package-target-policy.d.ts.map +1 -1
  131. package/dist/package-target-policy.js +3 -5
  132. package/dist/release-config-policy.d.ts.map +1 -1
  133. package/dist/release-config-policy.js +3 -5
  134. package/dist/runtime-input.d.ts +14 -0
  135. package/dist/runtime-input.d.ts.map +1 -0
  136. package/dist/runtime-input.js +15 -0
  137. package/dist/rust-tokens.d.ts +11 -0
  138. package/dist/rust-tokens.d.ts.map +1 -0
  139. package/dist/rust-tokens.js +81 -0
  140. package/dist/task-results.d.ts +6 -0
  141. package/dist/task-results.d.ts.map +1 -0
  142. package/dist/task-results.js +61 -0
  143. package/dist/test-program.d.ts +54 -0
  144. package/dist/test-program.d.ts.map +1 -0
  145. package/dist/test-program.js +292 -0
  146. package/dist/test-timings.d.ts +71 -0
  147. package/dist/test-timings.d.ts.map +1 -0
  148. package/dist/test-timings.js +393 -0
  149. package/dist/test-walk-policy.d.ts +103 -0
  150. package/dist/test-walk-policy.d.ts.map +1 -0
  151. package/dist/test-walk-policy.js +657 -0
  152. package/dist/testing.d.ts +177 -0
  153. package/dist/testing.d.ts.map +1 -0
  154. package/dist/testing.js +824 -0
  155. package/dist/type-guards.d.ts +3 -0
  156. package/dist/type-guards.d.ts.map +1 -0
  157. package/dist/type-guards.js +4 -0
  158. package/dist/typecheck-test-policy.d.ts +8 -5
  159. package/dist/typecheck-test-policy.d.ts.map +1 -1
  160. package/dist/typecheck-test-policy.js +113 -100
  161. package/dist/workspace-config-policy.d.ts +8 -0
  162. package/dist/workspace-config-policy.d.ts.map +1 -1
  163. package/dist/workspace-config-policy.js +175 -63
  164. package/dist/workspace-index.d.ts +12 -0
  165. package/dist/workspace-index.d.ts.map +1 -0
  166. package/dist/workspace-index.js +17 -0
  167. package/dist/workspace-manifest.d.ts +37 -0
  168. package/dist/workspace-manifest.d.ts.map +1 -1
  169. package/executors.json +5 -0
  170. package/loader.js +13 -11
  171. package/managed/raw/envrc +33 -67
  172. package/managed/raw/git-format-staged.yml +30 -35
  173. package/managed/raw/patches/nx@23.2.1.patch +3484 -0
  174. package/managed/raw/tooling/direnv/apple-developer.sh +83 -0
  175. package/managed/raw/tooling/direnv/developer-links.ts +569 -11
  176. package/managed/raw/tooling/direnv/devenv.smoo.nix +314 -93
  177. package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +20 -11
  178. package/managed/raw/tooling/direnv/linked-snapshots.ts +845 -0
  179. package/managed/raw/tooling/direnv/nx-socket-dir.sh +82 -0
  180. package/managed/raw/tooling/direnv/repo-path +14 -2
  181. package/managed/raw/tooling/direnv/setup-environment.ts +1146 -159
  182. package/managed/raw/tooling/direnv/toolchain-stamp.ts +45 -3
  183. package/managed/raw/tooling/direnv/ttsc-env.sh +39 -0
  184. package/managed/raw/tooling/git-hooks/commit-msg.sh +5 -6
  185. package/managed/raw/tooling/git-hooks/pre-commit.sh +7 -6
  186. package/managed/raw/tooling/git-hooks/pre-push.sh +20 -15
  187. package/managed/templates/github/actions/cache-nix-devenv/action.yml +6 -6
  188. package/managed/templates/github/actions/cache-node-modules/action.yml +6 -4
  189. package/managed/templates/github/actions/cache-nx/action.yml +1 -1
  190. package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +1 -1
  191. package/managed/templates/github/actions/forgejo-artifact.cjs +99 -0
  192. package/managed/templates/github/actions/forgejo-download-artifact/action.yml +49 -0
  193. package/managed/templates/github/actions/forgejo-download-artifact/index.cjs +7 -0
  194. package/managed/templates/github/actions/forgejo-upload-artifact/action.yml +65 -0
  195. package/managed/templates/github/actions/forgejo-upload-artifact/index.cjs +7 -0
  196. package/managed/templates/github/actions/setup-devenv/action.yml +21 -3
  197. package/managed/templates/github/workflows/managed-files.yml +1 -2
  198. package/nextest.toml +8 -41
  199. package/package.json +74 -12
  200. package/runtime-input.sh +81 -0
  201. package/src/__tests__/counted-cargo.ts +33 -14
  202. package/src/__tests__/fixture-nx-env.ts +111 -46
  203. package/src/__tests__/progress-clock.ts +43 -0
  204. package/src/__tests__/runtime-input.ts +23 -0
  205. package/src/bin/smoo-nx-bound-failures.test.ts +127 -0
  206. package/src/bin/smoo-nx-bound-failures.ts +33 -0
  207. package/src/bin/smoo-nx-cargo-hash.ts +28 -3
  208. package/src/bin/smoo-nx-exec.ts +16 -74
  209. package/src/bin/smoo-nx-failures.ts +4 -0
  210. package/src/bin/smoo-nx-nextest-extract.ts +3 -2
  211. package/src/bin/smoo-nx-test-walks.ts +42 -0
  212. package/src/bounded-test-policy.test.ts +268 -21
  213. package/src/bounded-test-policy.ts +114 -42
  214. package/src/build-state-output-policy.test.ts +115 -0
  215. package/src/build-state-output-policy.ts +90 -0
  216. package/src/bun-bootstrap.test.ts +57 -3
  217. package/src/bun-file-packages.test.ts +47 -0
  218. package/src/cargo-closure-input.test.ts +138 -66
  219. package/src/cargo-closure-input.ts +17 -15
  220. package/src/cargo-dev-profile.ts +137 -0
  221. package/src/cargo-resolve-cache.test.ts +70 -1
  222. package/src/cargo-source-hash.test.ts +193 -97
  223. package/src/cargo-source-hash.ts +345 -68
  224. package/src/cargo-toolchain-policy.ts +6 -0
  225. package/src/cargo-workspace.test.ts +320 -0
  226. package/src/cargo-workspace.ts +336 -10
  227. package/src/cross-check-policy.test.ts +59 -1
  228. package/src/cross-check-policy.ts +25 -6
  229. package/src/disk-command-policy.test.ts +61 -0
  230. package/src/disk-command-policy.ts +107 -0
  231. package/src/ensure-built-receipt.test.ts +184 -0
  232. package/src/ensure-built-receipt.ts +263 -0
  233. package/src/ensure-built-witness.test.ts +344 -0
  234. package/src/ensure-built-witness.ts +252 -0
  235. package/src/ensure-built.test.ts +1036 -578
  236. package/src/ensure-built.ts +820 -224
  237. package/src/eslint-file-set.ts +9 -0
  238. package/src/executors/bounded-exec/cpu-pool.test.ts +454 -0
  239. package/src/executors/bounded-exec/cpu-pool.ts +417 -0
  240. package/src/executors/bounded-exec/cpu-tokens.test.ts +269 -0
  241. package/src/executors/bounded-exec/cpu-tokens.ts +177 -0
  242. package/src/executors/bounded-exec/disk-lease.test.ts +185 -0
  243. package/src/executors/bounded-exec/disk-lease.ts +139 -0
  244. package/src/executors/bounded-exec/executor-host.test.ts +778 -0
  245. package/src/executors/bounded-exec/executor.test.ts +1116 -63
  246. package/src/executors/bounded-exec/executor.ts +565 -67
  247. package/src/executors/bounded-exec/gateway-lease.ts +176 -0
  248. package/src/executors/bounded-exec/hang-diagnostics.test.ts +285 -0
  249. package/src/executors/bounded-exec/hang-diagnostics.ts +283 -0
  250. package/src/executors/bounded-exec/progress.test.ts +79 -0
  251. package/src/executors/bounded-exec/progress.ts +118 -0
  252. package/src/executors/bounded-exec/ram-temp-fixtures.ts +12 -0
  253. package/src/executors/bounded-exec/ram-temp-held.test.ts +264 -0
  254. package/src/executors/bounded-exec/ram-temp-held.ts +242 -0
  255. package/src/executors/bounded-exec/ram-temp-host.test.ts +605 -0
  256. package/src/executors/bounded-exec/ram-temp.test.ts +674 -0
  257. package/src/executors/bounded-exec/ram-temp.ts +1918 -0
  258. package/src/executors/bounded-exec/schema.json +11 -5
  259. package/src/executors/bounded-exec/schema.ts +27 -11
  260. package/src/executors/bounded-exec/verdict.test.ts +440 -0
  261. package/src/executors/bounded-exec/verdict.ts +433 -0
  262. package/src/executors/shard-timings/executor.ts +36 -0
  263. package/src/executors/shard-timings/schema.json +21 -0
  264. package/src/executors/shard-timings/schema.ts +4 -0
  265. package/src/failure-summary.ts +119 -0
  266. package/src/generators/bounded-test-targets/generator.test.ts +4 -4
  267. package/src/generators/bun-test-tracing/generator.test.ts +2 -2
  268. package/src/generators/create-package/generator.test.ts +6 -0
  269. package/src/generators/create-package/generator.ts +6 -2
  270. package/src/host-controller-wiring.test.ts +31 -0
  271. package/src/index.test.ts +909 -295
  272. package/src/index.ts +441 -143
  273. package/src/linked-snapshots.nx.test.ts +172 -0
  274. package/src/managed-files/ci-workflow.ts +54 -13
  275. package/src/managed-files/files.ts +65 -9
  276. package/src/managed-files/forgejo-artifact.test.ts +395 -0
  277. package/src/managed-files/generator.test.ts +60 -1
  278. package/src/managed-files/json-edit.test.ts +216 -0
  279. package/src/managed-files/json-edit.ts +290 -0
  280. package/src/managed-files/managed-format-json.test.ts +308 -0
  281. package/src/managed-files/managed-format.ts +90 -2
  282. package/src/managed-files/pr-preview-cleanup-workflow.ts +69 -3
  283. package/src/managed-files/publish-workflow.ts +285 -67
  284. package/src/managed-files/repo-path.test.ts +129 -0
  285. package/src/managed-files/trace-db-artifact.test.ts +7 -0
  286. package/src/managed-files/tree.ts +11 -3
  287. package/src/manifest-hash.ts +2 -6
  288. package/src/nextest-code-bound.test.ts +155 -0
  289. package/src/nextest-code-bound.ts +195 -0
  290. package/src/nextest-extraction.test.ts +37 -5
  291. package/src/nextest-extraction.ts +51 -9
  292. package/src/nextest-partitions.test.ts +427 -82
  293. package/src/nx-cache-bound.test.ts +5 -10
  294. package/src/nx-cache-restore-mtime.test.ts +170 -0
  295. package/src/nx-daemon-claim.test.ts +277 -0
  296. package/src/nx-daemon-idle-cpu.test.ts +81 -0
  297. package/src/nx-daemon-idle-policy.test.ts +51 -0
  298. package/src/nx-daemon-ignore-files.test.ts +210 -0
  299. package/src/nx-daemon-root-normalization.test.ts +105 -0
  300. package/src/nx-daemon-validity.test.ts +925 -0
  301. package/src/nx-dot-input-policy.test.ts +353 -0
  302. package/src/nx-failure-life-cycles.test.ts +207 -0
  303. package/src/nx-files-archive-racy.test.ts +97 -0
  304. package/src/nx-foreign-workspace-env.test.ts +329 -0
  305. package/src/nx-incomplete-run-summary.test.ts +70 -0
  306. package/src/nx-plugin-load-errors.test.ts +120 -0
  307. package/src/nx-project-resolution-cache.test.ts +176 -0
  308. package/src/nx-raw-inputs.test.ts +166 -0
  309. package/src/nx-resident-graph-workers.test.ts +7 -16
  310. package/src/nx-run-information.test.ts +118 -0
  311. package/src/nx-skipped-task-exit.test.ts +180 -0
  312. package/src/nx-state-location.test.ts +63 -0
  313. package/src/nx-store-resolution.test.ts +26 -25
  314. package/src/nx-task-graph-cycles.test.ts +148 -0
  315. package/src/nx-task-output-lease.test.ts +414 -0
  316. package/src/nx-use-local.test.ts +103 -0
  317. package/src/package-target-policy.ts +3 -6
  318. package/src/release-config-policy.ts +3 -6
  319. package/src/runtime-input.test.ts +215 -0
  320. package/src/runtime-input.ts +17 -0
  321. package/src/rust-tokens.ts +78 -0
  322. package/src/serial-group-wiring.test.ts +326 -0
  323. package/src/task-history-namespace.test.ts +87 -89
  324. package/src/task-results.test.ts +226 -0
  325. package/src/task-results.ts +75 -0
  326. package/src/test-program.test.ts +303 -0
  327. package/src/test-program.ts +341 -0
  328. package/src/test-timings.test.ts +240 -0
  329. package/src/test-timings.ts +311 -0
  330. package/src/test-walk-policy.test.ts +585 -0
  331. package/src/test-walk-policy.ts +731 -0
  332. package/src/testing.test.ts +509 -0
  333. package/src/testing.ts +922 -0
  334. package/src/type-guards.ts +4 -0
  335. package/src/typecheck-test-policy.test.ts +496 -11
  336. package/src/typecheck-test-policy.ts +137 -103
  337. package/src/workspace-config-policy.test.ts +212 -13
  338. package/src/workspace-config-policy.ts +101 -73
  339. package/src/workspace-index.ts +18 -0
  340. package/src/workspace-manifest.ts +41 -0
  341. package/test-timings.json +85 -30
  342. package/managed/raw/tooling/direnv/inherited-devenv.ts +0 -665
  343. package/managed/raw/tooling/direnv/shared-caches.sh +0 -53
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smoothbricks/nx-plugin",
3
- "version": "0.4.26",
3
+ "version": "0.4.28",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "main": "./loader.js",
@@ -18,11 +18,31 @@
18
18
  "require": "./dist/version-actions.cjs",
19
19
  "default": "./dist/version-actions.cjs"
20
20
  },
21
+ "./eslint-file-set": {
22
+ "types": "./dist/eslint-file-set.d.ts",
23
+ "import": "./dist/eslint-file-set.js",
24
+ "default": "./dist/eslint-file-set.js"
25
+ },
26
+ "./failure-summary": {
27
+ "types": "./dist/failure-summary.d.ts",
28
+ "import": "./dist/failure-summary.js",
29
+ "default": "./dist/failure-summary.js"
30
+ },
21
31
  "./bounded-test-policy": {
22
32
  "types": "./dist/bounded-test-policy.d.ts",
23
33
  "import": "./dist/bounded-test-policy.js",
24
34
  "default": "./dist/bounded-test-policy.js"
25
35
  },
36
+ "./build-state-output-policy": {
37
+ "types": "./dist/build-state-output-policy.d.ts",
38
+ "import": "./dist/build-state-output-policy.js",
39
+ "default": "./dist/build-state-output-policy.js"
40
+ },
41
+ "./test-walk-policy": {
42
+ "types": "./dist/test-walk-policy.d.ts",
43
+ "import": "./dist/test-walk-policy.js",
44
+ "default": "./dist/test-walk-policy.js"
45
+ },
26
46
  "./workspace-config-policy": {
27
47
  "types": "./dist/workspace-config-policy.d.ts",
28
48
  "import": "./dist/workspace-config-policy.js",
@@ -43,11 +63,21 @@
43
63
  "import": "./dist/typecheck-test-policy.js",
44
64
  "default": "./dist/typecheck-test-policy.js"
45
65
  },
66
+ "./test-timings": {
67
+ "types": "./dist/test-timings.d.ts",
68
+ "import": "./dist/test-timings.js",
69
+ "default": "./dist/test-timings.js"
70
+ },
46
71
  "./ensure-built": {
47
72
  "types": "./dist/ensure-built.d.ts",
48
73
  "import": "./dist/ensure-built.js",
49
74
  "default": "./dist/ensure-built.js"
50
75
  },
76
+ "./testing": {
77
+ "types": "./dist/testing.d.ts",
78
+ "import": "./dist/testing.js",
79
+ "default": "./dist/testing.js"
80
+ },
51
81
  "./cross-check-policy": {
52
82
  "types": "./dist/cross-check-policy.d.ts",
53
83
  "import": "./dist/cross-check-policy.js",
@@ -58,6 +88,11 @@
58
88
  "import": "./dist/cargo-toolchain-policy.js",
59
89
  "default": "./dist/cargo-toolchain-policy.js"
60
90
  },
91
+ "./cargo-dev-profile": {
92
+ "types": "./dist/cargo-dev-profile.d.ts",
93
+ "import": "./dist/cargo-dev-profile.js",
94
+ "default": "./dist/cargo-dev-profile.js"
95
+ },
61
96
  "./workspace-manifest": {
62
97
  "types": "./dist/workspace-manifest.d.ts",
63
98
  "import": "./dist/workspace-manifest.js",
@@ -142,7 +177,10 @@
142
177
  "bin": {
143
178
  "smoo-nx-exec": "./dist/bin/smoo-nx-exec.js",
144
179
  "smoo-nx-cargo-hash": "./dist/bin/smoo-nx-cargo-hash.js",
145
- "smoo-nx-nextest-extract": "./dist/bin/smoo-nx-nextest-extract.js"
180
+ "smoo-nx-nextest-extract": "./dist/bin/smoo-nx-nextest-extract.js",
181
+ "smoo-nx-bound-failures": "./dist/bin/smoo-nx-bound-failures.js",
182
+ "smoo-nx-failures": "./dist/bin/smoo-nx-failures.js",
183
+ "smoo-nx-test-walks": "./dist/bin/smoo-nx-test-walks.js"
146
184
  },
147
185
  "generators": "./generators.json",
148
186
  "executors": "./executors.json",
@@ -158,42 +196,63 @@
158
196
  "test-shard1",
159
197
  "test-shard2",
160
198
  "test-shard3",
161
- "test-shard4"
199
+ "test-shard4",
200
+ "test-host"
162
201
  ]
163
202
  },
164
203
  "test-shard1": {
165
204
  "executor": "@smoothbricks/nx-plugin:bounded-exec",
166
205
  "options": {
167
- "command": "bun test --timeout=30000 --timings=test-timings.json --shard=1/4",
206
+ "command": "bun test --timeout=30000 --timings=test-timings.json --shard=1/4 --path-ignore-patterns='**/*-host.test.ts'",
168
207
  "cwd": "{projectRoot}",
169
- "timeoutMs": 120000,
208
+ "idleTimeoutMs": 180000,
170
209
  "killAfterMs": 10000
171
210
  }
172
211
  },
173
212
  "test-shard2": {
174
213
  "executor": "@smoothbricks/nx-plugin:bounded-exec",
175
214
  "options": {
176
- "command": "bun test --timeout=30000 --timings=test-timings.json --shard=2/4",
215
+ "command": "bun test --timeout=30000 --timings=test-timings.json --shard=2/4 --path-ignore-patterns='**/*-host.test.ts'",
177
216
  "cwd": "{projectRoot}",
178
- "timeoutMs": 120000,
217
+ "idleTimeoutMs": 180000,
179
218
  "killAfterMs": 10000
180
219
  }
181
220
  },
182
221
  "test-shard3": {
183
222
  "executor": "@smoothbricks/nx-plugin:bounded-exec",
184
223
  "options": {
185
- "command": "bun test --timeout=30000 --timings=test-timings.json --shard=3/4",
224
+ "command": "bun test --timeout=30000 --timings=test-timings.json --shard=3/4 --path-ignore-patterns='**/*-host.test.ts'",
186
225
  "cwd": "{projectRoot}",
187
- "timeoutMs": 120000,
226
+ "idleTimeoutMs": 180000,
188
227
  "killAfterMs": 10000
189
228
  }
190
229
  },
191
230
  "test-shard4": {
192
231
  "executor": "@smoothbricks/nx-plugin:bounded-exec",
193
232
  "options": {
194
- "command": "bun test --timeout=30000 --timings=test-timings.json --shard=4/4",
233
+ "command": "bun test --timeout=30000 --timings=test-timings.json --shard=4/4 --path-ignore-patterns='**/*-host.test.ts'",
234
+ "cwd": "{projectRoot}",
235
+ "idleTimeoutMs": 180000,
236
+ "killAfterMs": 10000
237
+ }
238
+ },
239
+ "test-host": {
240
+ "executor": "@smoothbricks/nx-plugin:bounded-exec",
241
+ "dependsOn": [
242
+ {
243
+ "projects": [
244
+ "cowshed"
245
+ ],
246
+ "target": "build"
247
+ }
248
+ ],
249
+ "options": {
250
+ "command": "bun test --timeout=30000 ./src/executors/bounded-exec/ram-temp-host.test.ts ./src/executors/bounded-exec/executor-host.test.ts",
195
251
  "cwd": "{projectRoot}",
196
- "timeoutMs": 120000,
252
+ "env": {
253
+ "COWSHED_EXECUTABLE": "{workspaceRoot}/packages/cowshed/bin/cowshed"
254
+ },
255
+ "idleTimeoutMs": 180000,
197
256
  "killAfterMs": 10000
198
257
  }
199
258
  }
@@ -207,6 +266,7 @@
207
266
  "dist",
208
267
  "src",
209
268
  "nextest.toml",
269
+ "runtime-input.sh",
210
270
  "test-timings.json",
211
271
  "README.md",
212
272
  "loader.js",
@@ -225,11 +285,13 @@
225
285
  "directory": "packages/nx-plugin"
226
286
  },
227
287
  "dependencies": {
228
- "@nx/js": "latest",
288
+ "@nx/js": "23.2.1",
289
+ "jsonc-parser": "^3.3.1",
229
290
  "nx": "latest",
230
291
  "prettier": "^3.9.8",
231
292
  "smol-toml": "^1.6.1",
232
293
  "tslib": "^2.8.1",
294
+ "typescript": "^6.0.3",
233
295
  "typia": "14.0.6",
234
296
  "yaml": "^2.9.0"
235
297
  },
@@ -0,0 +1,81 @@
1
+ #!/bin/sh
2
+ # Runs one Nx `runtime` input:
3
+ #
4
+ # sh node_modules/@smoothbricks/nx-plugin/runtime-input.sh <command> [argument...]
5
+ #
6
+ # The input's value is the command's stdout. A command that fails stops Nx with
7
+ # an error; its failure never becomes a key.
8
+ #
9
+ # WHY the 0xFF byte. Nx 23.2.1 (`packages/nx/src/native/tasks/hashers/
10
+ # hash_runtime.rs`) runs a runtime input under `sh -c`, hashes its trimmed
11
+ # stdout followed by its trimmed stderr, and never looks at the exit status. A
12
+ # failed input is therefore a valid key: its error text, the same string for
13
+ # every history, toolchain or file it failed to read, so a result cached under
14
+ # one is replayed for all of them. Nx refuses exactly one outcome: a stream
15
+ # that is not UTF-8. `std::str::from_utf8` fails, the hash fails, and `nx run`
16
+ # exits 1 with `invalid utf-8 sequence of 1 bytes from index N`. So a failed
17
+ # command ends this script's stdout with 0xFF, a byte no UTF-8 text contains.
18
+ # runtime-input.test.ts plants a failure through real Nx and goes red the day
19
+ # Nx hashes these bytes instead of refusing them; if Nx starts honouring the
20
+ # exit status, the byte is redundant and can go.
21
+ #
22
+ # Nx drops runtime stderr, so it is not a reliable diagnostic channel. Failures
23
+ # retain private argv, byte-exact stderr, status and a readable report below
24
+ # $PWD/.runtime-input-failures/, outside Nx and temporary state. Read them with
25
+ # `cat .runtime-input-failures/*/report` after a decoder error. Stderr and a
26
+ # controlling /dev/tty also name the failure where those channels are visible.
27
+ #
28
+ # The command's stderr is not part of the value; it surfaces only on failure.
29
+ # Diagnostics name temp paths, process ids and the boundary the input ran in
30
+ # (an Nx daemon inside a sandbox runs inputs with the sandbox's view of the
31
+ # client's environment), none of which is the input.
32
+ set -u
33
+ if [ "$#" -eq 0 ]; then
34
+ echo 'usage: runtime-input.sh <command> [argument...]' >&2
35
+ printf '\377'
36
+ exit 64
37
+ fi
38
+ if diagnostic=$(mktemp "${TMPDIR:-/tmp}/nx-runtime-input.XXXXXXXXXX"); then
39
+ :
40
+ else
41
+ printf 'runtime input could not capture stderr: %s\n' "$*" >&2
42
+ printf '\377'
43
+ exit 73
44
+ fi
45
+ if "$@" 2>"$diagnostic"; then
46
+ rm -f "$diagnostic"
47
+ exit 0
48
+ else
49
+ status=$?
50
+ fi
51
+ cat "$diagnostic" >&2
52
+ if record=$(umask 077; mkdir -p "$PWD/.runtime-input-failures" &&
53
+ mktemp -d "$PWD/.runtime-input-failures/failure.XXXXXXXXXX"); then
54
+ if printf '%s\000' "$@" >"$record/argv" &&
55
+ printf '%s\n' "$status" >"$record/exit-status" &&
56
+ mv "$diagnostic" "$record/stderr" && {
57
+ printf 'runtime input exited %s: %s\n' "$status" "$*"
58
+ printf 'working directory: %s\n' "$PWD"
59
+ index=0
60
+ for argument
61
+ do
62
+ printf 'argv[%s]: <%s>\n' "$index" "$argument"
63
+ index=$((index + 1))
64
+ done
65
+ printf 'original stderr:\n'
66
+ cat "$record/stderr"
67
+ } >"$record/report"; then
68
+ printf '\nruntime input exited %s: %s; evidence: %s/report\n' "$status" "$*" "$record" >&2
69
+ # A detached daemon may have no terminal. Preserve that error too, rather
70
+ # than sending it into Nx's discarded stderr or swallowing it.
71
+ (exec 4>/dev/tty && cat "$record/report" >&4) 2>"$record/terminal-error"
72
+ else
73
+ printf '\nruntime input exited %s: %s; evidence incomplete: %s; stderr capture: %s\n' \
74
+ "$status" "$*" "$record" "$diagnostic" >&2
75
+ fi
76
+ else
77
+ printf '\nruntime input exited %s: %s; could not retain evidence; stderr capture: %s\n' \
78
+ "$status" "$*" "$diagnostic" >&2
79
+ fi
80
+ printf '\377'
81
+ exit "$status"
@@ -11,6 +11,7 @@ import { type QueryableSpan, querySpan } from '@smoothbricks/lmao/testing';
11
11
  import { useTestSpan } from '@smoothbricks/lmao/testing/bun';
12
12
  import { AggregateCreateNodesError } from 'nx/src/project-graph/error-types.js';
13
13
  import { CargoMetadataError } from '../cargo-source-hash.js';
14
+ import { bindListener } from '../testing.js';
14
15
  import { BROKER_HOST, encodeOrder, type ProcessReport, parseReport, readLines } from './counted-cargo-process.js';
15
16
 
16
17
  /** What one fixture's `cargo metadata` children have done so far, in the order they did it. */
@@ -286,16 +287,29 @@ const quote = (value: string): string => `'${value.replaceAll("'", `'"'"'`)}'`;
286
287
 
287
288
  const PROGRAM = fileURLToPath(new URL('./counted-cargo-process.ts', import.meta.url));
288
289
 
289
- function listen(server: Server): Promise<number> {
290
- return new Promise((resolve, reject) => {
291
- server.once('error', reject);
292
- server.listen(0, BROKER_HOST, () => {
293
- server.off('error', reject);
294
- const address = server.address();
295
- if (address === null || typeof address === 'string') reject(new Error(`the broker has no port: ${address}`));
296
- else resolve(address.port);
297
- });
290
+ interface Listening {
291
+ readonly server: Server;
292
+ readonly port: number;
293
+ }
294
+
295
+ /**
296
+ * `server` listening on the broker's host at `port` (0: the kernel's choice), with the port it holds; rejects with
297
+ * the bind's own error.
298
+ */
299
+ function listen(server: Server, port: number): Promise<Listening> {
300
+ const { promise, resolve, reject } = Promise.withResolvers<Listening>();
301
+ server.once('error', reject);
302
+ server.listen(port, BROKER_HOST, () => {
303
+ server.off('error', reject);
304
+ const address = server.address();
305
+ if (address === null || typeof address === 'string') {
306
+ server.close();
307
+ reject(new Error(`the broker has no port: ${address}`));
308
+ } else {
309
+ resolve({ server, port: address.port });
310
+ }
298
311
  });
312
+ return promise;
299
313
  }
300
314
 
301
315
  /**
@@ -313,7 +327,8 @@ async function shim(
313
327
  /** How long the fixture's waits may take: longer over the real Cargo. */
314
328
  guardMs: number,
315
329
  ): Promise<{ cargo: CountedCargo; answer(text: string): void }> {
316
- const real = Bun.which('cargo');
330
+ const path = process.env.PATH ?? '';
331
+ const real = Bun.which('cargo', { PATH: path });
317
332
  if (real === null) throw new Error('cargo is not on PATH');
318
333
  const directory = join(root, 'counted-cargo');
319
334
  const bin = join(directory, 'bin');
@@ -426,7 +441,7 @@ async function shim(
426
441
  return `child ${self.pid} reported ${report.kind} while ${self.phase}`;
427
442
  };
428
443
 
429
- const server = createServer((socket) => {
444
+ const accept = (socket: Socket): void => {
430
445
  connections.add(socket);
431
446
  let self: Registered | null = null;
432
447
  const unterminated = readLines(socket, (line) => {
@@ -455,12 +470,14 @@ async function shim(
455
470
  }
456
471
  changed();
457
472
  });
458
- });
473
+ };
474
+ // The children connect back to this listener, so it binds in the workspace's port block when it has
475
+ // one: a port-0 listener binds there too, and then no sandboxed child can connect to it.
476
+ const { server, port } = await bindListener((candidate) => listen(createServer(accept), candidate));
459
477
  server.on('close', () => {
460
478
  listening = false;
461
479
  changed();
462
480
  });
463
- const port = await listen(server);
464
481
  // Only the processes it serves keep the test process alive, never the listener itself.
465
482
  server.unref();
466
483
 
@@ -554,6 +571,8 @@ async function shim(
554
571
  join(bin, 'cargo'),
555
572
  [
556
573
  '#!/bin/sh',
574
+ // Delegate with the caller's original search path: a launcher must not resolve this shim again.
575
+ `export PATH=${quote(path)}`,
557
576
  `real=${quote(real)}`,
558
577
  `if [ "$1" != metadata ]; then ${forward}; fi`,
559
578
  `exec ${quote(process.execPath)} ${quote(PROGRAM)} metadata ${port} "$real" ${quote(directory)} "$@"`,
@@ -574,7 +593,7 @@ async function shim(
574
593
  const cargo: CountedCargo = {
575
594
  bin,
576
595
  environment: {
577
- PATH: `${bin}${delimiter}${process.env.PATH ?? ''}`,
596
+ PATH: `${bin}${delimiter}${path}`,
578
597
  NX_WORKSPACE_DATA_DIRECTORY: join(root, '.nx/workspace-data'),
579
598
  },
580
599
  beforeRead: latch('read'),
@@ -1,10 +1,18 @@
1
+ import { onTestFinished } from 'bun:test';
1
2
  import { spawn } from 'node:child_process';
2
- import { existsSync, watch } from 'node:fs';
3
- import { dirname, join } from 'node:path';
3
+ import { mkdir, rm } from 'node:fs/promises';
4
+ import { tmpdir } from 'node:os';
5
+ import { join } from 'node:path';
6
+ import {
7
+ fixtureSocketDirectory,
8
+ ownedFixtureRoot,
9
+ publishFixtureSocketDirectory,
10
+ retireFixtureSocketDirectory,
11
+ stopNxDaemon,
12
+ } from '../testing.js';
4
13
  import { guardEvent } from './counted-cargo.js';
5
14
 
6
15
  const repositoryRoot = join(import.meta.dir, '../../../..');
7
- const DAEMON_STOP_TIMEOUT_MS = 10_000;
8
16
 
9
17
  /**
10
18
  * The environment of an `nx` a test runs against a fixture workspace.
@@ -13,16 +21,29 @@ const DAEMON_STOP_TIMEOUT_MS = 10_000;
13
21
  * `nx run nx-plugin:test`, the test process is itself an Nx task, and what the
14
22
  * outer Nx exported to it (NX_SKIP_NX_CACHE under `--skip-nx-cache`, the
15
23
  * NX_TASK_* identity, output capture) would reconfigure the fixture's Nx: a
16
- * skipped cache turns every second run into a miss. NX_DAEMON goes with them,
17
- * so an inherited `false` never reaches the fixture: its Nx runs under the
18
- * daemon Nx would pick on its own, owned by the fixture root and released by
19
- * `stopFixtureNxDaemon` before the root is deleted.
24
+ * skipped cache turns every second run into a miss.
25
+ *
26
+ * NX_DAEMON is then `false`: a daemonless Nx leaves nothing running once it
27
+ * exits, and only a test whose subject is the daemon overrides it with
28
+ * `true`, inside {@link withNxFixture}, which stops that daemon. NX_USE_LOCAL
29
+ * is `true`, as in this repository's shell: otherwise a fixture daemon asked
30
+ * for Nx Console's status pulls `nx@latest` from the registry in an `npm`
31
+ * child working in the fixture root.
20
32
  *
21
33
  * FORCE_COLOR, which an outer Nx also exports, is kept set, next to the
22
34
  * NO_COLOR a shell may export. The fixture's runtime inputs inherit both, and
23
35
  * must hash the same under them.
36
+ *
37
+ * NX_SOCKET_DIR is `socketDirectory`, the fixture's own published
38
+ * {@link fixtureSocketDirectory} ({@link withNxFixture} passes it), never the
39
+ * inherited one, which a Cowshed job shares with every other Nx of its
40
+ * checkout. Nx's default socket root is the literal `/tmp/.nx`, which a
41
+ * sandbox does not admit, and it hashes the daemon's pid into the name, so two
42
+ * daemons of one workspace bind two paths. With the directory named, they bind
43
+ * one: a test whose subject is two daemons on two socket paths names a second
44
+ * directory for the second. Building the environment publishes nothing.
24
45
  */
25
- export function fixtureNxEnv(workspace: string): Record<string, string> {
46
+ export function fixtureNxEnv(workspace: string, socketDirectory: string): Record<string, string> {
26
47
  const env: Record<string, string> = {};
27
48
  for (const [key, value] of Object.entries(process.env)) {
28
49
  if (value !== undefined && !key.startsWith('NX_')) env[key] = value;
@@ -31,41 +52,96 @@ export function fixtureNxEnv(workspace: string): Record<string, string> {
31
52
  ...env,
32
53
  FORCE_COLOR: 'true',
33
54
  NO_COLOR: '1',
55
+ NX_DAEMON: 'false',
56
+ NX_USE_LOCAL: 'true',
34
57
  NX_WORKSPACE_ROOT_PATH: workspace,
35
58
  NX_ISOLATE_PLUGINS: 'false',
59
+ NX_SOCKET_DIR: socketDirectory,
36
60
  NX_WORKSPACE_DATA_DIRECTORY: join(workspace, '.nx/workspace-data'),
37
61
  NX_CACHE_DIRECTORY: join(workspace, '.nx/cache'),
38
62
  };
39
63
  }
40
64
 
41
65
  /**
42
- * Stop the Nx daemon a fixture's own `nx` runs started, through Nx's supported
43
- * `nx daemon --stop`, before the fixture root is deleted. The daemon is told
44
- * the same root and data directory that started it (`fixtureNxEnv`), so it
45
- * can only be this fixture's: no other workspace's daemon is reached, and
46
- * nothing is reset. Nx records a started daemon in `d/server-process.json`
47
- * under the workspace-data directory, so a root without that record never had
48
- * one; the record goes when the daemon has shut down, and one that outlives
49
- * the stop is reported, not buried by the delete that follows.
66
+ * A fixture root of this package's suite in the temp directory, owned by this
67
+ * test process: the next run's first fixture reclaims it, and whatever still
68
+ * works in it, if this process is killed before the root is retired.
50
69
  */
51
- export async function stopFixtureNxDaemon(workspace: string): Promise<void> {
52
- const record = join(workspace, '.nx/workspace-data/d/server-process.json');
53
- if (!existsSync(record)) return;
54
- // Subscribe before sending the stop request: an unlink is an event, not a delay to guess.
55
- const subscription = watch(dirname(record));
56
- const retirement = new Promise<Error | null>((resolve) => {
57
- subscription.on('change', () => {
58
- if (!existsSync(record)) resolve(null);
59
- });
60
- subscription.once('error', resolve);
61
- if (!existsSync(record)) resolve(null);
62
- });
63
- let stdout = '';
64
- let stderr = '';
70
+ export function nxFixtureRoot(prefix: string): Promise<string> {
71
+ return ownedFixtureRoot(tmpdir(), 'nx-plugin', prefix);
72
+ }
73
+
74
+ /** A fixture root, the Nx workspace in it whose daemon the fixture owns, and that workspace's published socket directory. */
75
+ export interface NxFixture {
76
+ readonly root: string;
77
+ readonly workspace: string;
78
+ readonly socketDirectory: string;
79
+ }
80
+
81
+ /**
82
+ * Run `body` in a fresh fixture root whose Nx workspace is `workspace`
83
+ * (relative to the root, made if it is not the root), with the workspace's
84
+ * socket alias published, then retire it: stop the workspace's daemon, unlink
85
+ * the alias and delete the root, however `body` ends. Bun ends a timed-out test
86
+ * without cancelling its body, so the fixture also retires when the test
87
+ * finishes.
88
+ */
89
+ export async function withNxFixture<T>(
90
+ prefix: string,
91
+ body: (fixture: NxFixture) => Promise<T>,
92
+ workspace = '.',
93
+ ): Promise<T> {
94
+ const root = await nxFixtureRoot(prefix);
95
+ const owned = { root, workspace: join(root, workspace) };
96
+ let retirement: Promise<void> | undefined;
97
+ const retire = () => {
98
+ retirement ??= retireNxFixture(owned);
99
+ return retirement;
100
+ };
101
+ onTestFinished(retire);
102
+ let result: T;
65
103
  try {
104
+ await mkdir(owned.workspace, { recursive: true });
105
+ result = await body({ ...owned, socketDirectory: await publishFixtureSocketDirectory(owned.workspace) });
106
+ } catch (error) {
107
+ try {
108
+ await retire();
109
+ } catch (retireError) {
110
+ throw new AggregateError([error, retireError], `fixture ${root} failed, and so did its retirement`);
111
+ }
112
+ throw error;
113
+ }
114
+ await retire();
115
+ return result;
116
+ }
117
+
118
+ /**
119
+ * Stop the fixture workspace's daemon, unlink its owned short socket alias,
120
+ * then delete the root. A daemon that outlives its stop fails the retirement
121
+ * and keeps all three, so its working directory still names a fixture the next
122
+ * run reclaims, alias included. Nothing is published here: the stop names the
123
+ * directory publication returned, by the same pure naming.
124
+ */
125
+ async function retireNxFixture({ root, workspace }: Omit<NxFixture, 'socketDirectory'>): Promise<void> {
126
+ await stopFixtureNxDaemon(workspace, fixtureNxEnv(workspace, fixtureSocketDirectory(workspace)));
127
+ await retireFixtureSocketDirectory(workspace);
128
+ await rm(root, { recursive: true, force: true });
129
+ }
130
+
131
+ /**
132
+ * Stop the Nx daemon a fixture's own `nx` runs started, through Nx's supported
133
+ * `nx daemon --stop`, and wait until it and every process it ran have exited.
134
+ * The daemon is told the same root, data and socket directory that started it
135
+ * (`env`, the one a test started it under), so it can only be this fixture's:
136
+ * no other workspace's daemon is reached, and nothing is reset.
137
+ */
138
+ export function stopFixtureNxDaemon(workspace: string, env: Record<string, string>): Promise<void> {
139
+ return stopNxDaemon(workspace, async () => {
140
+ let stdout = '';
141
+ let stderr = '';
66
142
  const child = spawn('bun', [join(repositoryRoot, 'node_modules/.bin/nx'), 'daemon', '--stop'], {
67
143
  cwd: workspace,
68
- env: fixtureNxEnv(workspace),
144
+ env: { ...env, NX_DAEMON: 'true' },
69
145
  detached: process.platform !== 'win32',
70
146
  stdio: ['ignore', 'pipe', 'pipe'],
71
147
  });
@@ -79,12 +155,11 @@ export async function stopFixtureNxDaemon(workspace: string): Promise<void> {
79
155
  child.once('error', (error) => {
80
156
  spawnFailure = error;
81
157
  });
82
- const ended = new Promise<number | null>((resolve) => {
83
- child.once('close', (code) => resolve(code));
84
- });
158
+ const { promise: ended, resolve } = Promise.withResolvers<number | null>();
159
+ child.once('close', resolve);
85
160
  const describe = () =>
86
161
  `fixture ${workspace}; stop pid ${child.pid ?? 'not started'}, exit ${child.exitCode ?? 'pending'}, ` +
87
- `signal ${child.signalCode ?? 'none'}; daemon record ${existsSync(record) ? 'present' : 'removed'}\n${stdout}${stderr}`;
162
+ `signal ${child.signalCode ?? 'none'}\n${stdout}${stderr}`;
88
163
  let exitCode: number | null;
89
164
  try {
90
165
  exitCode = await guardEvent(ended, 'nx daemon --stop to exit', describe);
@@ -107,15 +182,5 @@ export async function stopFixtureNxDaemon(workspace: string): Promise<void> {
107
182
  if (spawnFailure !== null || exitCode !== 0) {
108
183
  throw new Error(`nx daemon --stop failed with exit code ${exitCode}\n${describe()}`, { cause: spawnFailure });
109
184
  }
110
- const error = await guardEvent(
111
- retirement,
112
- 'Nx daemon record to retire',
113
- describe,
114
- undefined,
115
- DAEMON_STOP_TIMEOUT_MS,
116
- );
117
- if (error !== null) throw error;
118
- } finally {
119
- subscription.close();
120
- }
185
+ });
121
186
  }
@@ -0,0 +1,43 @@
1
+ import { jest } from 'bun:test';
2
+
3
+ /**
4
+ * Runs `run` with the timers faked, so a no-progress bound (`idleTimeoutMs`) expires only when the clock moves, and
5
+ * moves it `stepMs` each time this process writes a chunk of the command's output that `moves` accepts.
6
+ *
7
+ * A real-time window races the command's own start: under load `node` can take longer to print its first line than a
8
+ * test's 400 ms window lasts, and the bound then ends a run that has said nothing yet. Here the window can end only
9
+ * after the command has said what the test is about. bounded-exec re-arms the bound on a finished test before it
10
+ * passes that output on, so a step taken on a chunk measures from that chunk's progress, as a real gap would. The
11
+ * step is taken after the write returns: a bound that fires writes its own message, which must not move the clock.
12
+ *
13
+ * What the run writes to this process's stdout and stderr is read here and not printed; bounded-exec's result keeps
14
+ * it. Returns that result and how far the clock moved.
15
+ */
16
+ export async function onProgressClock<T>(
17
+ moves: (chunk: string) => boolean,
18
+ stepMs: number,
19
+ run: () => Promise<T>,
20
+ ): Promise<{ result: T; movedMs: number }> {
21
+ const stdout = process.stdout.write;
22
+ const stderr = process.stderr.write;
23
+ let movedMs = 0;
24
+ const watch = (chunk: string | Uint8Array): boolean => {
25
+ if (moves(typeof chunk === 'string' ? chunk : Buffer.from(chunk).toString('utf8'))) {
26
+ queueMicrotask(() => {
27
+ movedMs += stepMs;
28
+ jest.advanceTimersByTime(stepMs);
29
+ });
30
+ }
31
+ return true;
32
+ };
33
+ jest.useFakeTimers();
34
+ process.stdout.write = watch;
35
+ process.stderr.write = watch;
36
+ try {
37
+ return { result: await run(), movedMs };
38
+ } finally {
39
+ process.stdout.write = stdout;
40
+ process.stderr.write = stderr;
41
+ jest.useRealTimers();
42
+ }
43
+ }
@@ -0,0 +1,23 @@
1
+ import { expect } from 'bun:test';
2
+
3
+ /**
4
+ * What Nx hashes for a `runtime` input: the command's stdout, from `sh -c` in
5
+ * the workspace root. `process.env` is passed because `Bun.spawn`'s default
6
+ * environment is the one this process started with, and a fixture's
7
+ * `CARGO_HOME` lives in `process.env` (see `useFixtureCargoHome`).
8
+ */
9
+ export async function runtimeInputValue(command: string, workspaceRoot: string): Promise<string> {
10
+ const child = Bun.spawn(['sh', '-c', command], {
11
+ cwd: workspaceRoot,
12
+ env: process.env,
13
+ stdout: 'pipe',
14
+ stderr: 'pipe',
15
+ });
16
+ const [exitCode, stdout, stderr] = await Promise.all([
17
+ child.exited,
18
+ new Response(child.stdout).text(),
19
+ new Response(child.stderr).text(),
20
+ ]);
21
+ expect({ command, exitCode, stderr }).toMatchObject({ command, exitCode: 0 });
22
+ return stdout;
23
+ }