@smoothbricks/nx-plugin 0.5.7 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (432) hide show
  1. package/README.md +1086 -360
  2. package/dist/.build-inputs.json +138 -0
  3. package/dist/bin/smoo-nx-cargo-toolchain.d.ts +3 -0
  4. package/dist/bin/smoo-nx-cargo-toolchain.d.ts.map +1 -0
  5. package/dist/bin/smoo-nx-cargo-toolchain.js +8 -0
  6. package/dist/bin/smoo-nx-forbidden-spellings.d.ts +3 -0
  7. package/dist/bin/smoo-nx-forbidden-spellings.d.ts.map +1 -0
  8. package/dist/bin/smoo-nx-forbidden-spellings.js +32 -0
  9. package/dist/bin/smoo-nx-nextest-timings.d.ts +3 -0
  10. package/dist/bin/smoo-nx-nextest-timings.d.ts.map +1 -0
  11. package/dist/bin/smoo-nx-nextest-timings.js +28 -0
  12. package/dist/bounded-test-policy.d.ts +1 -1
  13. package/dist/bounded-test-policy.d.ts.map +1 -1
  14. package/dist/bounded-test-policy.js +14 -15
  15. package/dist/build-state-output-policy.d.ts +95 -1
  16. package/dist/build-state-output-policy.d.ts.map +1 -1
  17. package/dist/build-state-output-policy.js +368 -30
  18. package/dist/bun-lock-scope.d.ts +44 -0
  19. package/dist/bun-lock-scope.d.ts.map +1 -0
  20. package/dist/bun-lock-scope.js +97 -0
  21. package/dist/cargo-build-script-env.d.ts +49 -0
  22. package/dist/cargo-build-script-env.d.ts.map +1 -0
  23. package/dist/cargo-build-script-env.js +324 -0
  24. package/dist/cargo-closure-input.d.ts +31 -4
  25. package/dist/cargo-closure-input.d.ts.map +1 -1
  26. package/dist/cargo-closure-input.js +66 -6
  27. package/dist/cargo-retention-hook.d.ts +17 -0
  28. package/dist/cargo-retention-hook.d.ts.map +1 -0
  29. package/dist/cargo-retention-hook.js +85 -0
  30. package/dist/cargo-source-hash.d.ts +25 -7
  31. package/dist/cargo-source-hash.d.ts.map +1 -1
  32. package/dist/cargo-source-hash.js +108 -43
  33. package/dist/cargo-toolchain-paths.d.ts +40 -0
  34. package/dist/cargo-toolchain-paths.d.ts.map +1 -0
  35. package/dist/cargo-toolchain-paths.js +84 -0
  36. package/dist/cargo-toolchain-policy.d.ts +25 -8
  37. package/dist/cargo-toolchain-policy.d.ts.map +1 -1
  38. package/dist/cargo-toolchain-policy.js +39 -5
  39. package/dist/cargo-workspace.d.ts +10 -4
  40. package/dist/cargo-workspace.d.ts.map +1 -1
  41. package/dist/cargo-workspace.js +65 -95
  42. package/dist/cross-check-policy.d.ts +9 -9
  43. package/dist/cross-check-policy.d.ts.map +1 -1
  44. package/dist/cross-check-policy.js +11 -11
  45. package/dist/disk-command-policy.d.ts.map +1 -1
  46. package/dist/disk-command-policy.js +1 -0
  47. package/dist/ensure-built-receipt.d.ts +13 -5
  48. package/dist/ensure-built-receipt.d.ts.map +1 -1
  49. package/dist/ensure-built-receipt.js +126 -47
  50. package/dist/ensure-built-witness.d.ts +27 -8
  51. package/dist/ensure-built-witness.d.ts.map +1 -1
  52. package/dist/ensure-built-witness.js +45 -15
  53. package/dist/ensure-built.d.ts.map +1 -1
  54. package/dist/ensure-built.js +9 -1
  55. package/dist/eslint-config-closure.d.ts +7 -0
  56. package/dist/eslint-config-closure.d.ts.map +1 -0
  57. package/dist/eslint-config-closure.js +346 -0
  58. package/dist/executors/bounded-exec/bounds.d.ts +56 -0
  59. package/dist/executors/bounded-exec/bounds.d.ts.map +1 -0
  60. package/dist/executors/bounded-exec/bounds.js +43 -0
  61. package/dist/executors/bounded-exec/cpu-pool.d.ts +33 -36
  62. package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
  63. package/dist/executors/bounded-exec/cpu-pool.js +54 -119
  64. package/dist/executors/bounded-exec/executor.d.ts +19 -12
  65. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  66. package/dist/executors/bounded-exec/executor.js +371 -239
  67. package/dist/executors/bounded-exec/gateway-lease.d.ts +22 -19
  68. package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -1
  69. package/dist/executors/bounded-exec/gateway-lease.js +81 -28
  70. package/dist/executors/bounded-exec/hang-diagnostics.d.ts +18 -1
  71. package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
  72. package/dist/executors/bounded-exec/hang-diagnostics.js +148 -30
  73. package/dist/executors/bounded-exec/lease-wait.d.ts +43 -0
  74. package/dist/executors/bounded-exec/lease-wait.d.ts.map +1 -0
  75. package/dist/executors/bounded-exec/lease-wait.js +68 -0
  76. package/dist/executors/bounded-exec/lock-wait.d.ts +51 -0
  77. package/dist/executors/bounded-exec/lock-wait.d.ts.map +1 -0
  78. package/dist/executors/bounded-exec/lock-wait.js +108 -0
  79. package/dist/executors/bounded-exec/owned-subtree.d.ts +84 -0
  80. package/dist/executors/bounded-exec/owned-subtree.d.ts.map +1 -0
  81. package/dist/executors/bounded-exec/owned-subtree.js +178 -0
  82. package/dist/executors/bounded-exec/progress.d.ts +4 -1
  83. package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
  84. package/dist/executors/bounded-exec/progress.js +5 -2
  85. package/dist/executors/bounded-exec/ram-attach.d.ts +19 -0
  86. package/dist/executors/bounded-exec/ram-attach.d.ts.map +1 -0
  87. package/dist/executors/bounded-exec/ram-attach.js +207 -0
  88. package/dist/executors/bounded-exec/ram-detach.d.ts +25 -0
  89. package/dist/executors/bounded-exec/ram-detach.d.ts.map +1 -0
  90. package/dist/executors/bounded-exec/ram-detach.js +207 -0
  91. package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts +76 -0
  92. package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts.map +1 -1
  93. package/dist/executors/bounded-exec/ram-temp-fixtures.js +296 -0
  94. package/dist/executors/bounded-exec/ram-temp.d.ts +388 -88
  95. package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -1
  96. package/dist/executors/bounded-exec/ram-temp.js +1213 -399
  97. package/dist/executors/bounded-exec/run-cpu-pool.d.ts +4 -4
  98. package/dist/executors/bounded-exec/run-cpu-pool.d.ts.map +1 -1
  99. package/dist/executors/bounded-exec/run-cpu-pool.js +20 -30
  100. package/dist/executors/bounded-exec/runner-hook.js +14 -5
  101. package/dist/executors/bounded-exec/runner-lifecycle.d.ts +14 -1
  102. package/dist/executors/bounded-exec/runner-lifecycle.d.ts.map +1 -1
  103. package/dist/executors/bounded-exec/runner-lifecycle.js +27 -6
  104. package/dist/executors/bounded-exec/{cpu-tokens.d.ts → runner-sizing.d.ts} +14 -42
  105. package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -0
  106. package/dist/executors/bounded-exec/{cpu-tokens.js → runner-sizing.js} +5 -35
  107. package/dist/executors/bounded-exec/runtime-pin.d.ts +73 -0
  108. package/dist/executors/bounded-exec/runtime-pin.d.ts.map +1 -0
  109. package/dist/executors/bounded-exec/runtime-pin.js +167 -0
  110. package/dist/executors/bounded-exec/schema.d.ts +18 -1
  111. package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
  112. package/dist/executors/bounded-exec/verdict.d.ts +40 -11
  113. package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
  114. package/dist/executors/bounded-exec/verdict.js +88 -19
  115. package/dist/executors/cargo-zigbuild/executor.d.ts +21 -0
  116. package/dist/executors/cargo-zigbuild/executor.d.ts.map +1 -1
  117. package/dist/executors/cargo-zigbuild/executor.js +67 -12
  118. package/dist/executors/clean-outputs/executor.js +1 -0
  119. package/dist/executors/scriptc-native/executor.d.ts +79 -0
  120. package/dist/executors/scriptc-native/executor.d.ts.map +1 -0
  121. package/dist/executors/scriptc-native/executor.js +367 -0
  122. package/dist/executors/scriptc-native/ffi-paths.d.ts +9 -0
  123. package/dist/executors/scriptc-native/ffi-paths.d.ts.map +1 -0
  124. package/dist/executors/scriptc-native/ffi-paths.js +25 -0
  125. package/dist/executors/scriptc-native/schema.d.ts +34 -0
  126. package/dist/executors/scriptc-native/schema.d.ts.map +1 -0
  127. package/dist/executors/scriptc-native/schema.js +1 -0
  128. package/dist/executors/typescript-emit/executor.d.ts +3 -1
  129. package/dist/executors/typescript-emit/executor.d.ts.map +1 -1
  130. package/dist/executors/typescript-emit/executor.js +164 -33
  131. package/dist/forbidden-spelling-policy.d.ts +56 -0
  132. package/dist/forbidden-spelling-policy.d.ts.map +1 -0
  133. package/dist/forbidden-spelling-policy.js +176 -0
  134. package/dist/generators/create-package/generator.d.ts.map +1 -1
  135. package/dist/generators/create-package/generator.js +3 -4
  136. package/dist/graph-input-contract.d.ts +14 -0
  137. package/dist/graph-input-contract.d.ts.map +1 -1
  138. package/dist/graph-input-contract.js +67 -2
  139. package/dist/index.d.ts +23 -6
  140. package/dist/index.d.ts.map +1 -1
  141. package/dist/index.js +672 -214
  142. package/dist/managed-assets.d.ts +2 -0
  143. package/dist/managed-assets.d.ts.map +1 -1
  144. package/dist/managed-files/files.d.ts +3 -3
  145. package/dist/managed-files/files.d.ts.map +1 -1
  146. package/dist/managed-files/files.js +28 -3
  147. package/dist/managed-files/managed-format.d.ts.map +1 -1
  148. package/dist/managed-files/managed-format.js +1 -0
  149. package/dist/nextest-code-bound.js +1 -0
  150. package/dist/nextest-timings.d.ts +35 -0
  151. package/dist/nextest-timings.d.ts.map +1 -0
  152. package/dist/nextest-timings.js +168 -0
  153. package/dist/owned-installation.d.ts +6 -5
  154. package/dist/owned-installation.d.ts.map +1 -1
  155. package/dist/owned-installation.js +150 -26
  156. package/dist/package-target-policy.d.ts.map +1 -1
  157. package/dist/package-target-policy.js +2 -3
  158. package/dist/process-children.d.ts +7 -0
  159. package/dist/process-children.d.ts.map +1 -0
  160. package/dist/process-children.darwin.d.ts +7 -0
  161. package/dist/process-children.darwin.d.ts.map +1 -0
  162. package/dist/process-children.darwin.js +13 -0
  163. package/dist/process-children.js +14 -0
  164. package/dist/process-children.linux.d.ts +8 -0
  165. package/dist/process-children.linux.d.ts.map +1 -0
  166. package/dist/process-children.linux.js +25 -0
  167. package/dist/process-group.d.ts +108 -0
  168. package/dist/process-group.d.ts.map +1 -0
  169. package/dist/process-group.js +171 -0
  170. package/dist/process-listing.d.ts +7 -0
  171. package/dist/process-listing.d.ts.map +1 -0
  172. package/dist/process-listing.js +51 -0
  173. package/dist/producer-receipts.d.ts +8 -2
  174. package/dist/producer-receipts.d.ts.map +1 -1
  175. package/dist/producer-receipts.js +75 -48
  176. package/dist/task-graph-policy.d.ts +21 -0
  177. package/dist/task-graph-policy.d.ts.map +1 -0
  178. package/dist/task-graph-policy.js +91 -0
  179. package/dist/test-timings.js +4 -4
  180. package/dist/test-walk-policy.d.ts +14 -5
  181. package/dist/test-walk-policy.d.ts.map +1 -1
  182. package/dist/test-walk-policy.js +8 -2
  183. package/dist/testing.d.ts +73 -28
  184. package/dist/testing.d.ts.map +1 -1
  185. package/dist/testing.js +217 -223
  186. package/dist/tool-bins.d.ts +33 -0
  187. package/dist/tool-bins.d.ts.map +1 -0
  188. package/dist/tool-bins.js +72 -0
  189. package/dist/typecheck-test-policy.d.ts.map +1 -1
  190. package/dist/typecheck-test-policy.js +3 -4
  191. package/dist/wait-why-policy.d.ts +28 -0
  192. package/dist/wait-why-policy.d.ts.map +1 -0
  193. package/dist/wait-why-policy.js +223 -0
  194. package/dist/workspace-config-policy.d.ts +14 -8
  195. package/dist/workspace-config-policy.d.ts.map +1 -1
  196. package/dist/workspace-config-policy.js +60 -16
  197. package/dist/workspace-manifest.d.ts +41 -6
  198. package/dist/workspace-manifest.d.ts.map +1 -1
  199. package/dist/workspace-manifest.js +57 -0
  200. package/executors.json +16 -1
  201. package/loader.js +2 -0
  202. package/managed/raw/envrc +11 -0
  203. package/managed/raw/patches/nx@23.2.1.patch +2840 -199
  204. package/managed/raw/patches/ttsc@0.34.1.patch +119 -0
  205. package/managed/raw/tooling/direnv/cargo-fetch-bound.ts +245 -0
  206. package/managed/raw/tooling/direnv/cargo-fetch-run.ts +299 -0
  207. package/managed/raw/tooling/direnv/compiler-variables.sh +42 -0
  208. package/managed/raw/tooling/direnv/developer-links.ts +464 -25
  209. package/managed/raw/tooling/direnv/devenv.smoo.nix +78 -38
  210. package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +14 -12
  211. package/managed/raw/tooling/direnv/installed-bun-links.ts +308 -0
  212. package/managed/raw/tooling/direnv/linked-snapshots.ts +62 -3
  213. package/managed/raw/tooling/direnv/nx-socket-dir.sh +56 -17
  214. package/managed/raw/tooling/direnv/repo-path +68 -6
  215. package/managed/raw/tooling/direnv/secret-references.ts +13 -4
  216. package/managed/raw/tooling/direnv/setup-environment.ts +128 -537
  217. package/managed/raw/tooling/direnv/toolchain-stamp.ts +4 -2
  218. package/managed/raw/tooling/direnv/ttsc-env.sh +9 -0
  219. package/managed/raw/tooling/direnv/uv-relocation.ts +227 -0
  220. package/managed/raw/tooling/git-hooks/commit-msg.sh +2 -1
  221. package/managed/raw/tooling/git-hooks/pre-commit.sh +2 -1
  222. package/managed/raw/tooling/git-hooks/pre-push.sh +2 -1
  223. package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +85 -7
  224. package/managed/templates/github/actions/save-nix-devenv/action.yml +12 -2
  225. package/managed/templates/github/actions/setup-devenv/action.yml +2 -0
  226. package/package.json +77 -13
  227. package/src/bin/smoo-nx-cargo-toolchain.ts +11 -0
  228. package/src/bin/smoo-nx-forbidden-spellings.ts +33 -0
  229. package/src/bin/smoo-nx-nextest-timings.ts +31 -0
  230. package/src/bounded-test-policy.ts +12 -14
  231. package/src/build-state-output-policy.ts +458 -34
  232. package/src/bun-lock-scope.ts +108 -0
  233. package/src/cargo-build-script-env.ts +265 -0
  234. package/src/cargo-closure-input.ts +74 -7
  235. package/src/cargo-retention-hook.ts +94 -0
  236. package/src/cargo-source-hash.ts +138 -41
  237. package/src/cargo-toolchain-paths.ts +95 -0
  238. package/src/cargo-toolchain-policy.ts +49 -5
  239. package/src/cargo-workspace.ts +72 -123
  240. package/src/cross-check-policy.ts +12 -10
  241. package/src/disk-command-policy.ts +1 -0
  242. package/src/ensure-built-receipt.ts +132 -39
  243. package/src/ensure-built-witness.ts +62 -10
  244. package/src/ensure-built.ts +11 -1
  245. package/src/eslint-config-closure.ts +357 -0
  246. package/src/executors/bounded-exec/bounds.ts +76 -0
  247. package/src/executors/bounded-exec/cpu-pool.ts +51 -117
  248. package/src/executors/bounded-exec/executor.ts +423 -259
  249. package/src/executors/bounded-exec/gateway-lease.ts +82 -33
  250. package/src/executors/bounded-exec/hang-diagnostics.ts +173 -31
  251. package/src/executors/bounded-exec/lease-wait.ts +89 -0
  252. package/src/executors/bounded-exec/lock-wait.ts +141 -0
  253. package/src/executors/bounded-exec/owned-subtree.ts +235 -0
  254. package/src/executors/bounded-exec/progress.ts +9 -3
  255. package/src/executors/bounded-exec/ram-attach.ts +238 -0
  256. package/src/executors/bounded-exec/ram-detach.ts +226 -0
  257. package/src/executors/bounded-exec/ram-temp-fixtures.ts +358 -0
  258. package/src/executors/bounded-exec/ram-temp-registry.txt +440 -0
  259. package/src/executors/bounded-exec/ram-temp.ts +1497 -460
  260. package/src/executors/bounded-exec/run-cpu-pool.ts +22 -30
  261. package/src/executors/bounded-exec/runner-hook.ts +14 -6
  262. package/src/executors/bounded-exec/runner-lifecycle.ts +31 -8
  263. package/src/executors/bounded-exec/{cpu-tokens.ts → runner-sizing.ts} +13 -59
  264. package/src/executors/bounded-exec/runtime-pin.ts +232 -0
  265. package/src/executors/bounded-exec/schema.json +11 -2
  266. package/src/executors/bounded-exec/schema.ts +19 -1
  267. package/src/executors/bounded-exec/verdict.ts +137 -34
  268. package/src/executors/cargo-zigbuild/executor.ts +82 -8
  269. package/src/executors/clean-outputs/executor.ts +1 -0
  270. package/src/executors/scriptc-native/executor.ts +394 -0
  271. package/src/executors/scriptc-native/ffi-paths.ts +29 -0
  272. package/src/executors/scriptc-native/schema.json +60 -0
  273. package/src/executors/scriptc-native/schema.ts +34 -0
  274. package/src/executors/typescript-emit/executor.ts +205 -38
  275. package/src/forbidden-spelling-policy.ts +226 -0
  276. package/src/generators/create-package/generator.ts +7 -7
  277. package/src/graph-input-contract.ts +61 -2
  278. package/src/index.ts +788 -224
  279. package/src/managed-assets.ts +3 -0
  280. package/src/managed-files/files.ts +28 -3
  281. package/src/managed-files/managed-format.ts +1 -0
  282. package/src/nextest-code-bound.ts +1 -0
  283. package/src/nextest-timings.ts +106 -0
  284. package/src/owned-installation.ts +150 -23
  285. package/src/package-target-policy.ts +2 -3
  286. package/src/process-children.darwin.ts +14 -0
  287. package/src/process-children.linux.ts +33 -0
  288. package/src/process-children.ts +22 -0
  289. package/src/process-group.ts +209 -0
  290. package/src/process-listing.ts +54 -0
  291. package/src/producer-receipts.ts +68 -45
  292. package/src/task-graph-policy.ts +98 -0
  293. package/src/test-walk-policy.ts +23 -8
  294. package/src/testing.ts +240 -232
  295. package/src/tool-bins.ts +108 -0
  296. package/src/typecheck-test-policy.ts +2 -3
  297. package/src/wait-why-policy.ts +226 -0
  298. package/src/workspace-config-policy.ts +63 -15
  299. package/src/workspace-manifest.ts +89 -6
  300. package/test-timings.json +122 -98
  301. package/dist/bin/smoo-nx-failures.d.ts +0 -3
  302. package/dist/bin/smoo-nx-failures.d.ts.map +0 -1
  303. package/dist/bin/smoo-nx-failures.js +0 -3
  304. package/dist/bin/smoo-nx-nextest-extract.d.ts +0 -3
  305. package/dist/bin/smoo-nx-nextest-extract.d.ts.map +0 -1
  306. package/dist/bin/smoo-nx-nextest-extract.js +0 -42
  307. package/dist/executors/bounded-exec/cpu-tokens.d.ts.map +0 -1
  308. package/dist/failure-summary.d.ts +0 -5
  309. package/dist/failure-summary.d.ts.map +0 -1
  310. package/dist/failure-summary.js +0 -118
  311. package/dist/nextest-extraction.d.ts +0 -117
  312. package/dist/nextest-extraction.d.ts.map +0 -1
  313. package/dist/nextest-extraction.js +0 -303
  314. package/managed/raw/patches/ttsc@0.30.4.patch +0 -2255
  315. package/src/__tests__/cargo-closure-filesets.ts +0 -94
  316. package/src/__tests__/cargo-closure-fixture.ts +0 -113
  317. package/src/__tests__/counted-cargo-process.ts +0 -286
  318. package/src/__tests__/counted-cargo.ts +0 -713
  319. package/src/__tests__/directory-change.ts +0 -27
  320. package/src/__tests__/fixture-cargo-home.ts +0 -36
  321. package/src/__tests__/fixture-nx-env.ts +0 -193
  322. package/src/__tests__/owned-installation.ts +0 -13
  323. package/src/__tests__/past-tick.ts +0 -12
  324. package/src/__tests__/progress-clock.ts +0 -43
  325. package/src/__tests__/runtime-input.ts +0 -23
  326. package/src/bin/smoo-nx-bound-failures.test.ts +0 -127
  327. package/src/bin/smoo-nx-failures.ts +0 -4
  328. package/src/bin/smoo-nx-nextest-extract.ts +0 -44
  329. package/src/bounded-test-policy.test.ts +0 -1029
  330. package/src/build-state-output-policy.test.ts +0 -115
  331. package/src/bun-bootstrap.test.ts +0 -102
  332. package/src/bun-file-packages.test.ts +0 -47
  333. package/src/cargo-closure-filesets.test.ts +0 -63
  334. package/src/cargo-closure-input.property.test.ts +0 -50
  335. package/src/cargo-closure-input.test.ts +0 -506
  336. package/src/cargo-closure-key.test.ts +0 -240
  337. package/src/cargo-resolve-cache.test.ts +0 -1181
  338. package/src/cargo-source-hash.test.ts +0 -707
  339. package/src/cargo-workspace.test.ts +0 -615
  340. package/src/cross-check-policy.test.ts +0 -316
  341. package/src/disk-command-policy.test.ts +0 -61
  342. package/src/ensure-built-receipt.test.ts +0 -279
  343. package/src/ensure-built-witness.test.ts +0 -688
  344. package/src/ensure-built.test.ts +0 -1462
  345. package/src/executors/all-verdicts/executor.test.ts +0 -135
  346. package/src/executors/bounded-exec/cargo-progress-host.test.ts +0 -332
  347. package/src/executors/bounded-exec/cpu-pool.test.ts +0 -684
  348. package/src/executors/bounded-exec/cpu-tokens.test.ts +0 -519
  349. package/src/executors/bounded-exec/disk-lease.test.ts +0 -219
  350. package/src/executors/bounded-exec/executor-host.test.ts +0 -800
  351. package/src/executors/bounded-exec/executor.test.ts +0 -1819
  352. package/src/executors/bounded-exec/go-progress-host.test.ts +0 -171
  353. package/src/executors/bounded-exec/hang-diagnostics.test.ts +0 -291
  354. package/src/executors/bounded-exec/progress.test.ts +0 -139
  355. package/src/executors/bounded-exec/ram-temp-held.test.ts +0 -264
  356. package/src/executors/bounded-exec/ram-temp-host.test.ts +0 -635
  357. package/src/executors/bounded-exec/ram-temp.test.ts +0 -750
  358. package/src/executors/bounded-exec/run-cpu-pool.test.ts +0 -79
  359. package/src/executors/bounded-exec/runner-hook.test.ts +0 -193
  360. package/src/executors/bounded-exec/runner-lifecycle.test.ts +0 -82
  361. package/src/executors/bounded-exec/verdict.test.ts +0 -545
  362. package/src/executors/cargo-zigbuild/executor.test.ts +0 -129
  363. package/src/executors/clean-outputs/executor.test.ts +0 -20
  364. package/src/executors/typescript-emit/executor.test.ts +0 -83
  365. package/src/failure-summary.ts +0 -119
  366. package/src/generators/bounded-test-targets/generator.test.ts +0 -138
  367. package/src/generators/bun-test-tracing/generator.test.ts +0 -250
  368. package/src/generators/create-package/generator.test.ts +0 -190
  369. package/src/generators/make-public/generator.test.ts +0 -137
  370. package/src/graph-input-contract.test.ts +0 -379
  371. package/src/host-controller-wiring.test.ts +0 -31
  372. package/src/index.test.ts +0 -3321
  373. package/src/linked-snapshots.nx.test.ts +0 -254
  374. package/src/managed-files/forgejo-artifact.test.ts +0 -395
  375. package/src/managed-files/generator.test.ts +0 -243
  376. package/src/managed-files/github-host-cache-isolation.test.ts +0 -86
  377. package/src/managed-files/json-edit.test.ts +0 -216
  378. package/src/managed-files/managed-content.test.ts +0 -166
  379. package/src/managed-files/managed-format-json.test.ts +0 -308
  380. package/src/managed-files/repo-path.test.ts +0 -172
  381. package/src/managed-files/setup-devenv-free-disk.test.ts +0 -95
  382. package/src/managed-files/trace-db-artifact.test.ts +0 -7
  383. package/src/managed-files/tree-permissions.test.ts +0 -109
  384. package/src/managed-files/tree.test.ts +0 -123
  385. package/src/manifest-hash.test.ts +0 -219
  386. package/src/nextest-code-bound.test.ts +0 -161
  387. package/src/nextest-extraction.test.ts +0 -216
  388. package/src/nextest-extraction.ts +0 -371
  389. package/src/nextest-partitions.test.ts +0 -501
  390. package/src/nx-cache-bound.test.ts +0 -109
  391. package/src/nx-cache-restore-mtime.test.ts +0 -170
  392. package/src/nx-daemon-claim.test.ts +0 -279
  393. package/src/nx-daemon-idle-cpu.test.ts +0 -80
  394. package/src/nx-daemon-idle-policy.test.ts +0 -111
  395. package/src/nx-daemon-ignore-files.test.ts +0 -210
  396. package/src/nx-daemon-root-normalization.test.ts +0 -105
  397. package/src/nx-daemon-start-never.test.ts +0 -292
  398. package/src/nx-daemon-validity.test.ts +0 -1055
  399. package/src/nx-dot-input-policy.test.ts +0 -353
  400. package/src/nx-failure-life-cycles.test.ts +0 -207
  401. package/src/nx-files-archive-racy.test.ts +0 -97
  402. package/src/nx-foreign-workspace-env.test.ts +0 -329
  403. package/src/nx-incomplete-run-summary.test.ts +0 -70
  404. package/src/nx-plugin-load-errors.test.ts +0 -120
  405. package/src/nx-project-graph-errors.test.ts +0 -70
  406. package/src/nx-project-resolution-cache.test.ts +0 -176
  407. package/src/nx-raw-inputs.test.ts +0 -166
  408. package/src/nx-resident-graph-workers.test.ts +0 -112
  409. package/src/nx-run-information.test.ts +0 -118
  410. package/src/nx-skipped-task-exit.test.ts +0 -180
  411. package/src/nx-state-location.test.ts +0 -63
  412. package/src/nx-store-resolution.test.ts +0 -81
  413. package/src/nx-task-graph-cycles.test.ts +0 -148
  414. package/src/nx-task-output-lease.test.ts +0 -550
  415. package/src/nx-use-local.test.ts +0 -105
  416. package/src/owned-installation.test.ts +0 -105
  417. package/src/package-target-policy.test.ts +0 -1014
  418. package/src/producer-receipts.test.ts +0 -285
  419. package/src/release-config-policy.test.ts +0 -311
  420. package/src/runtime-input.test.ts +0 -393
  421. package/src/serial-group-wiring.test.ts +0 -326
  422. package/src/task-history-namespace.test.ts +0 -181
  423. package/src/task-results.test.ts +0 -228
  424. package/src/test-clock-policy.test.ts +0 -338
  425. package/src/test-program.test.ts +0 -303
  426. package/src/test-timings.test.ts +0 -240
  427. package/src/test-walk-policy.test.ts +0 -620
  428. package/src/testing.test.ts +0 -509
  429. package/src/typecheck-test-policy.test.ts +0 -1468
  430. package/src/typescript-resolution.test.ts +0 -76
  431. package/src/version-actions.test.ts +0 -80
  432. package/src/workspace-config-policy.test.ts +0 -737
@@ -1,501 +0,0 @@
1
- import { afterAll, afterEach, beforeAll, expect, it } from 'bun:test';
2
- import { type ChildProcess, spawn } from 'node:child_process';
3
- import { mkdir, mkdtemp, readdir, readFile, realpath, rm, symlink, writeFile } from 'node:fs/promises';
4
- import { tmpdir } from 'node:os';
5
- import { join } from 'node:path';
6
- import { fileURLToPath } from 'node:url';
7
- import type { TargetConfiguration } from 'nx/src/devkit-exports.js';
8
- import { useFixtureCargoHome } from './__tests__/fixture-cargo-home.js';
9
- import { testFileInstallation } from './__tests__/owned-installation.js';
10
- import { BOUNDED_TEST_IDLE_TIMEOUT_MS, BOUNDED_TEST_KILL_AFTER_MS } from './bounded-test-policy.js';
11
- import type { NxTaskContext } from './executors/bounded-exec/executor.js';
12
- import { hostLeaseProcesses } from './executors/bounded-exec/ram-temp.js';
13
- import type { BoundedExecOptions } from './executors/bounded-exec/schema.js';
14
- import {
15
- type BoundedExecRecord,
16
- JUNIT_FILE,
17
- readRecord,
18
- taskDirectory,
19
- writeRecord,
20
- } from './executors/bounded-exec/verdict.js';
21
- import { createNodesV2ForPlatform } from './index.js';
22
- import { NEXTEST_EXTRACTION_DIRECTORY, nextestArchiveKey } from './nextest-extraction.js';
23
-
24
- useFixtureCargoHome();
25
-
26
- const GROUP_TARGET = 'cargo-test-group-serial-probe';
27
- const GROUP_ID = `partition-fixture:${GROUP_TARGET}`;
28
- const GROUP_HASH = 'serial-probe-hash';
29
- // The filter the plugin's group runner carries; the empty-selection case replaces exactly this text.
30
- const SERIAL_FILTER_ARG = "-E '(test(/serial_probe_/))'";
31
-
32
- const ordinary = Array.from({ length: 13 }, (_, index) => `ordinary_${index}`);
33
- // The class the plugin's nextest.toml singles out with an override: the
34
- // compile-fail tests carry a raised slow-timeout, so they are lifted out of the
35
- // ordinary hash.
36
- const exceptional = [
37
- ...Array.from({ length: 6 }, (_, index) => `compile_fail_partition_${index}`),
38
- ...Array.from({ length: 6 }, (_, index) => `partition_${index}_fail_to_compile`),
39
- ];
40
- const serial = Array.from({ length: 4 }, (_, index) => `serial_probe_${index}`);
41
- const expected = [...ordinary, ...exceptional, ...serial];
42
-
43
- /** The one Cargo fixture and archive every case reads, built once in beforeAll. */
44
- interface SharedFixture {
45
- readonly root: string;
46
- readonly targets: Readonly<Record<string, TargetConfiguration>>;
47
- readonly passingSeed: BoundedExecRecord;
48
- }
49
-
50
- /** A child this test started and has not yet seen close, with the command line that names it. */
51
- interface OpenChild {
52
- readonly command: string;
53
- readonly closed: Promise<unknown>;
54
- readonly graceful: boolean;
55
- }
56
-
57
- /** Set first in beforeAll, so afterAll can keep or remove a root even when beforeAll fails part way. */
58
- let fixtureRoot: string | undefined;
59
- /** Set last in beforeAll: the fixture every case reads. */
60
- let shared: SharedFixture | undefined;
61
- const openChildren = new Map<ChildProcess, OpenChild>();
62
- /** Set once teardown begins: a body still running then may not start a child, nor keep the result of one. */
63
- let ending = false;
64
- /** The current setup or case body, so teardown waits for it before another case or removal. */
65
- let bodyDone: Promise<void> = Promise.resolve();
66
- /** A failed barrier keeps the fixture, even if a later cleanup attempt succeeds. */
67
- let barrierFailure: string | undefined;
68
- /** The Nx installation the fixture links; it must leave it as it was made. */
69
- const installation = testFileInstallation('smoo-nextest-partitions-installation');
70
-
71
- beforeAll(
72
- caseBody(async () => {
73
- const root = await realpath(await mkdtemp(join(tmpdir(), 'smoo-nextest-partitions-')));
74
- fixtureRoot = root;
75
- await writeFile(join(root, 'package.json'), '{"name":"partition-fixture","private":true}\n');
76
- await writeFile(join(root, '.gitignore'), 'node_modules/\ntarget/\n.nx/\n*.log\n');
77
- await writeFile(
78
- join(root, 'Cargo.toml'),
79
- '[workspace]\nresolver = "2"\n\n[package]\nname = "partition-probe"\nversion = "0.1.0"\nedition = "2021"\n\n[package.metadata.smoothbricks.test]\nshards = 3\n',
80
- );
81
- await mkdir(join(root, '.config'));
82
- await writeFile(
83
- join(root, '.config/nextest.toml'),
84
- [
85
- '[test-groups.serial-probe]',
86
- 'max-threads = 1',
87
- '',
88
- '[[profile.default.overrides]]',
89
- "filter = 'test(/serial_probe_/)'",
90
- `platform = 'cfg(target_os="macos")'`,
91
- "test-group = 'serial-probe'",
92
- '',
93
- ].join('\n'),
94
- );
95
- await mkdir(join(root, 'src'));
96
- await writeFile(
97
- join(root, 'src/lib.rs'),
98
- `#[cfg(test)] mod tests {
99
- use std::io::Write;
100
- fn record(name: &str) {
101
- let mut file = std::fs::OpenOptions::new().create(true).append(true)
102
- .open(std::env::var("PARTITION_EXECUTIONS").unwrap()).unwrap();
103
- file.write_all(format!("{name}\\n").as_bytes()).unwrap();
104
- }
105
- fn fail_when_forced() {
106
- if std::env::var_os("PARTITION_FAIL_SERIAL").is_some() {
107
- panic!("forced failure");
108
- }
109
- }
110
- ${expected.map((name) => ` #[test] fn ${name}() { record("${name}");${serial.includes(name) ? ' fail_when_forced();' : ''} }`).join('\n')}
111
- }
112
- `,
113
- );
114
- await symlink(await installation.nodeModules(), join(root, 'node_modules'), 'dir');
115
- await run(root, ['git', 'init', '--quiet']);
116
- await run(root, ['cargo', 'generate-lockfile', '--offline']);
117
- const [, infer] = createNodesV2ForPlatform('darwin', 'arm64');
118
- const result = await infer(['package.json'], undefined, { workspaceRoot: root, nxJsonConfiguration: {} });
119
- const targets = result[0]?.[1].projects?.['.']?.targets;
120
- if (targets === undefined) throw new Error('Cargo fixture inferred no targets');
121
- // The archive is the one real prerequisite: every runner executes its binaries.
122
- await run(root, ['sh', '-c', command(targets, 'cargo-test-archive')]);
123
- const source = { root, targets };
124
- const passingSeed = await groupSucceeds(source);
125
- shared = { ...source, passingSeed };
126
- }),
127
- );
128
-
129
- /**
130
- * One case's body, run as its own promise. `ending` is cleared for this case, and afterEach waits for the
131
- * promise before the next case may start, so a body the deadline abandons cannot leak children into it.
132
- */
133
- function caseBody(body: () => Promise<void>): () => Promise<void> {
134
- return async () => {
135
- ending = false;
136
- bodyDone = body();
137
- await bodyDone;
138
- };
139
- }
140
-
141
- /**
142
- * The safety barrier. It runs after every case, and once more before the fixture is removed.
143
- *
144
- * A case's deadline abandons its body mid-`await`, so nothing it started may outlive the case. In order:
145
- * `ending` makes every later `runTracked` refuse to spawn, and makes a captured-only child still running print its
146
- * capture instead of returning it; each plain child's process
147
- * group is killed; then the lease owner ends every process still working in the fixture, a driver first,
148
- * with SIGTERM so its bounded executor relays the stop and releases its lease. Only once every child's exit has
149
- * settled and the body has settled does the barrier report. A child whose exit was not confirmed, or any
150
- * process left working, is returned by name, not hidden.
151
- */
152
- async function settle(): Promise<string[]> {
153
- ending = true;
154
- const open = [...openChildren];
155
- openChildren.clear();
156
- for (const [child, entry] of open) {
157
- if (!entry.graceful) killProcessGroup(child);
158
- }
159
- let leftovers: string[];
160
- try {
161
- leftovers = fixtureRoot === undefined ? [] : await hostLeaseProcesses.stopWorkingIn(fixtureRoot);
162
- } catch (error) {
163
- barrierFailure = `the lease owner could not end its processes: ${String(error)}`;
164
- throw error;
165
- }
166
- // Each close either resolved, so its child ended, or rejected, so its exit was never confirmed and it is named.
167
- const exits = await Promise.all(
168
- open.map(async ([, entry]) => {
169
- try {
170
- await entry.closed;
171
- return null;
172
- } catch (error) {
173
- return `${entry.command}: ${String(error)}`;
174
- }
175
- }),
176
- );
177
- await Promise.allSettled([bodyDone]);
178
- const problems: string[] = [];
179
- const unconfirmed = exits.filter((line): line is string => line !== null);
180
- if (unconfirmed.length > 0) {
181
- problems.push(`child processes whose exit was not confirmed:\n${unconfirmed.join('\n')}`);
182
- }
183
- if (leftovers.length > 0) problems.push(`processes left working in the fixture:\n${leftovers.join('\n')}`);
184
- if (problems.length > 0) barrierFailure = problems.join('\n');
185
- return problems;
186
- }
187
-
188
- afterEach(async () => {
189
- const problems = await settle();
190
- if (problems.length > 0) throw new Error(`test ended with ${problems.join('\n')}`);
191
- });
192
-
193
- /**
194
- * Removes the one fixture root, after the same barrier every case runs. If the barrier cannot account for
195
- * every process, or the lease owner errors, the root is kept and the error names it, so the processes it
196
- * names still have their directory.
197
- */
198
- afterAll(async () => {
199
- if (fixtureRoot === undefined) return;
200
- const root = fixtureRoot;
201
- try {
202
- await settle();
203
- } catch (error) {
204
- throw new Error(`kept fixture ${root}: the lease owner could not end its processes: ${String(error)}`);
205
- }
206
- if (barrierFailure !== undefined) throw new Error(`kept fixture ${root}:\n${barrierFailure}`);
207
- fixtureRoot = undefined;
208
- shared = undefined;
209
- await rm(root, { recursive: true, force: true });
210
- });
211
-
212
- // After the fixture's own teardown, so every process that could read the installation has ended.
213
- afterAll(() => installation.retire());
214
-
215
- function fixture(): SharedFixture {
216
- if (shared === undefined) {
217
- throw new Error('the shared Cargo fixture was not built: its beforeAll did not complete');
218
- }
219
- return shared;
220
- }
221
-
222
- function groupContext(root: string): NxTaskContext {
223
- return {
224
- root,
225
- projectName: 'partition-fixture',
226
- targetName: GROUP_TARGET,
227
- taskGraph: { tasks: { [GROUP_ID]: { hash: GROUP_HASH } } },
228
- };
229
- }
230
-
231
- /**
232
- * The group's verdict directory in the fixture's own workspace data, the same place the overlay sends the real
233
- * executor. readRecord proves the two agree: a record written anywhere else leaves the verdict null.
234
- */
235
- function groupDirectory(root: string): string {
236
- return taskDirectory(join(root, '.nx/workspace-data'), GROUP_ID);
237
- }
238
-
239
- /**
240
- * The group's options as the plan infers them, run from the fixture root: the inferred cwd is the cargo root, which
241
- * is the fixture root. `command` replaces the run's command, which stays the plan's byte-identical one otherwise.
242
- */
243
- function groupOptions(
244
- targets: Readonly<Record<string, TargetConfiguration>>,
245
- root: string,
246
- run = command(targets, GROUP_TARGET),
247
- ): BoundedExecOptions {
248
- // The group runner is bounded by progress like every test target: no ceiling, one runnable test at a time.
249
- expect(targets[GROUP_TARGET]?.options).toMatchObject({
250
- idleTimeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS,
251
- killAfterMs: BOUNDED_TEST_KILL_AFTER_MS,
252
- parallelism: 1,
253
- });
254
- expect(targets[GROUP_TARGET]?.options).not.toHaveProperty('timeoutMs');
255
- return {
256
- command: run,
257
- cwd: root,
258
- idleTimeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS,
259
- killAfterMs: BOUNDED_TEST_KILL_AFTER_MS,
260
- parallelism: 1,
261
- };
262
- }
263
-
264
- /**
265
- * Every archived test runs exactly once, in the runner that owns its class, and the serial group lists exactly
266
- * its probes. The runners are independent, so they run side by side exactly as Nx fans them out.
267
- */
268
- async function executesEveryTestOnce(): Promise<void> {
269
- const { root, targets } = fixture();
270
- // One log per runner kind, so the proof is exact selection and not only coverage: the ordinary shards ran
271
- // every ordinary test once and nothing else, the exceptional shards did the same for theirs, and the serial
272
- // group ran its class once in one unpartitioned runner.
273
- const serialLog = join(root, 'serial.log');
274
- const partitions = [
275
- { kind: 'shard', log: join(root, 'ordinary.log'), tests: ordinary },
276
- { kind: 'exceptions-shard', log: join(root, 'exceptional.log'), tests: exceptional },
277
- ];
278
- await Promise.all([
279
- ...partitions.flatMap(({ kind, log }) =>
280
- [1, 2, 3].map((index) =>
281
- run(root, ['sh', '-c', command(targets, `cargo-test-partition-probe-${kind}${index}`)], {
282
- PARTITION_EXECUTIONS: log,
283
- }),
284
- ),
285
- ),
286
- run(root, ['sh', '-c', command(targets, GROUP_TARGET)], { PARTITION_EXECUTIONS: serialLog }),
287
- ]);
288
- for (const { log, tests } of [...partitions, { log: serialLog, tests: serial }]) {
289
- const observed = (await readFile(log, 'utf8')).trim().split('\n').sort();
290
- expect(observed).toEqual([...tests].sort());
291
- }
292
- // The six runners shared one extraction, in Cargo's build tree: the archive's directory holds only the
293
- // archive, the declared Nx output.
294
- expect(await readdir(join(root, 'target', NEXTEST_EXTRACTION_DIRECTORY))).toEqual([
295
- await nextestArchiveKey(join(root, '.cache/nextest/archive.tar.zst')),
296
- ]);
297
- expect(await readdir(join(root, '.cache/nextest'))).toEqual(['archive.tar.zst']);
298
- // The serial group is one unpartitioned runner.
299
- expect(command(targets, GROUP_TARGET)).not.toContain('--partition');
300
- }
301
-
302
- /**
303
- * The real default executor, run for real on this fixture's group in a driver process. Its verdict is typed
304
- * passed and returned to its caller: fixture setup retains one real seed before any case runs.
305
- */
306
- async function groupSucceeds(source: Pick<SharedFixture, 'root' | 'targets'> = fixture()): Promise<BoundedExecRecord> {
307
- const { root, targets } = source;
308
- const directory = groupDirectory(root);
309
- const realCommand = command(targets, GROUP_TARGET);
310
- // Group policy requires --no-fail-fast: ordinary failures must not stop the remaining tests. Checked before any run.
311
- expect(realCommand).toContain('--no-fail-fast');
312
- expect(realCommand).not.toContain('max-fail');
313
- // The probes read PARTITION_EXECUTIONS and PARTITION_FAIL_SERIAL from the environment. Each run sets them on the
314
- // driver's spawn; the runner inherits them, since bounded-exec merges process.env into every runner. The command
315
- // stays the byte-identical one the plan generates.
316
- const successLog = join(root, 'group-success.log');
317
- await rm(successLog, { force: true });
318
- const success = await runGroupExecutor(root, groupOptions(targets, root), groupContext(root), {
319
- PARTITION_EXECUTIONS: successLog,
320
- });
321
- expect(success.code, success.output).toBe(0);
322
- const passed = await readRecord(directory);
323
- if (passed === null) throw new Error('a group run that passed wrote no verdict');
324
- expect(passed).toMatchObject({ task: GROUP_ID, hash: GROUP_HASH, verdict: { outcome: 'passed' } });
325
- // Budgeted runs reserve only the group's one runnable test; unbudgeted hosts have no receipt.
326
- if (passed.cpu !== undefined) {
327
- expect(passed.cpu).toMatchObject({ tokens: 1, want: 1 });
328
- }
329
- expect((await readFile(successLog, 'utf8')).trim().split('\n').sort()).toEqual([...serial].sort());
330
- return passed;
331
- }
332
-
333
- /**
334
- * A group whose filter selects nothing fails rather than passing a run that ran no test. The fixture's real passing
335
- * run seeds the stale verdict and report the run must replace; the marker log proves no probe ran.
336
- */
337
- async function emptySelectionFails(): Promise<void> {
338
- const { root, targets, passingSeed } = fixture();
339
- const directory = groupDirectory(root);
340
- await writeRecord(directory, passingSeed);
341
- await writeFile(join(directory, JUNIT_FILE), 'stale report\n');
342
- const realCommand = command(targets, GROUP_TARGET);
343
- const emptied = realCommand.replace(SERIAL_FILTER_ARG, "-E 'none()'");
344
- if (emptied === realCommand) throw new Error(`the group runner carries no ${SERIAL_FILTER_ARG} to empty`);
345
- const emptyLog = join(root, 'group-empty.log');
346
- await rm(emptyLog, { force: true });
347
- const empty = await runGroupExecutor(root, groupOptions(targets, root, emptied), groupContext(root), {
348
- PARTITION_EXECUTIONS: emptyLog,
349
- });
350
- expect(empty.code, empty.output).toBe(2);
351
- const record = await readRecord(directory);
352
- expect(record).toMatchObject({ task: GROUP_ID, hash: GROUP_HASH, verdict: { outcome: 'failed' } });
353
- await expect(readFile(join(directory, JUNIT_FILE), 'utf8')).resolves.not.toBe('stale report\n');
354
- await expect(readFile(emptyLog, 'utf8')).rejects.toMatchObject({ code: 'ENOENT' });
355
- }
356
-
357
- /**
358
- * Continuation past failure: each serial probe records, then fails through `fail_when_forced` because
359
- * PARTITION_FAIL_SERIAL is set. The group must still run and report all four. This is the observed
360
- * continuation, not a mutant count, and it says nothing about serialization: the override is macOS-only.
361
- */
362
- async function continuesPastFailures(): Promise<void> {
363
- const { root, targets } = fixture();
364
- const directory = groupDirectory(root);
365
- const failureLog = join(root, 'group-failure.log');
366
- const failed = await runGroupExecutor(root, groupOptions(targets, root), groupContext(root), {
367
- PARTITION_EXECUTIONS: failureLog,
368
- PARTITION_FAIL_SERIAL: '1',
369
- });
370
- expect(failed.code, failed.output).toBe(2);
371
- const failedRecord = await readRecord(directory);
372
- if (failedRecord === null) throw new Error('a group run that failed wrote no verdict');
373
- if (failedRecord.verdict.outcome !== 'failed') {
374
- throw new Error(`a failing group wrote verdict ${failedRecord.verdict.outcome}, not failed`);
375
- }
376
- expect(failedRecord.verdict.tests).toHaveLength(serial.length);
377
- for (const name of serial) {
378
- expect(
379
- failedRecord.verdict.tests.some((test) => test.includes(name)),
380
- name,
381
- ).toBe(true);
382
- }
383
- expect((await readFile(failureLog, 'utf8')).trim().split('\n').sort()).toEqual([...serial].sort());
384
- }
385
-
386
- it(
387
- 'executes every archived test once across ordinary, exceptional and serial-group runners',
388
- caseBody(executesEveryTestOnce),
389
- );
390
- it(
391
- 'runs the serial group through the real default executor and keeps its passing verdict',
392
- caseBody(async () => {
393
- await groupSucceeds();
394
- }),
395
- );
396
- it('fails a serial group whose filter selects no test, replacing the previous verdict', caseBody(emptySelectionFails));
397
- it('runs the serial group past failing probes and reports all four', caseBody(continuesPastFailures));
398
-
399
- function command(targets: Readonly<Record<string, TargetConfiguration>>, name: string): string {
400
- const single: unknown = targets[name]?.options?.command;
401
- if (typeof single !== 'string') throw new Error(`${name} inferred no executable command`);
402
- return single;
403
- }
404
-
405
- function killProcessGroup(child: ChildProcess): void {
406
- if (child.pid === undefined) return;
407
- try {
408
- process.kill(process.platform === 'win32' ? child.pid : -child.pid, 'SIGKILL');
409
- } catch (error) {
410
- if (!(error instanceof Error && 'code' in error && error.code === 'ESRCH')) throw error;
411
- }
412
- }
413
-
414
- /** A child that ran to its close: its exit code and what it printed to stdout and stderr together. */
415
- interface Tracked {
416
- readonly code: number | null;
417
- readonly output: string;
418
- }
419
-
420
- async function runTracked(
421
- root: string,
422
- args: string[],
423
- options: { overlay?: Record<string, string>; graceful?: boolean; tee?: boolean } = {},
424
- ): Promise<Tracked> {
425
- if (ending) throw new Error(`teardown has begun; not starting ${args.join(' ')}`);
426
- const [program, ...rest] = args;
427
- if (program === undefined) throw new Error('run needs a program');
428
- const child = spawn(program, rest, {
429
- cwd: root,
430
- env: { ...process.env, ...options.overlay },
431
- detached: process.platform !== 'win32',
432
- });
433
- child.stdin?.end();
434
- const output: Buffer[] = [];
435
- const tee = options.tee ?? false;
436
- child.stdout?.on('data', (chunk: Buffer) => {
437
- output.push(chunk);
438
- if (tee) process.stdout.write(chunk);
439
- });
440
- child.stderr?.on('data', (chunk: Buffer) => {
441
- output.push(chunk);
442
- if (tee) process.stderr.write(chunk);
443
- });
444
- const closed = new Promise<number | null>((resolve, reject) => {
445
- child.once('error', reject);
446
- child.once('close', resolve);
447
- });
448
- openChildren.set(child, { command: args.join(' '), closed, graceful: options.graceful ?? false });
449
- let code: number | null;
450
- try {
451
- code = await closed;
452
- } finally {
453
- openChildren.delete(child);
454
- // Teardown abandoned this case, so no caller will print the capture. A captured-only child prints it here; a teed
455
- // child already printed it live.
456
- if (ending && !tee) process.stdout.write(Buffer.concat(output).toString());
457
- }
458
- if (ending) {
459
- throw new Error(
460
- `teardown began while ${args.join(' ')} ran; its output is printed above and its result is discarded`,
461
- );
462
- }
463
- return { code, output: Buffer.concat(output).toString() };
464
- }
465
-
466
- async function run(root: string, args: string[], overlay: Record<string, string> = {}): Promise<void> {
467
- const { code, output } = await runTracked(root, args, { overlay });
468
- expect(code, `${args.join(' ')}\n${output}`).toBe(0);
469
- }
470
-
471
- /**
472
- * The built production executor, in a driver process whose runner group the lease owner can end.
473
- * The test target already depends on build: do not compile the TypeScript project again in every driver.
474
- */
475
- const EXECUTOR_MODULE = fileURLToPath(new URL('../dist/executors/bounded-exec/executor.js', import.meta.url));
476
-
477
- /**
478
- * Exit 0 when the executor reports success, 2 when its run fails. A crash in the driver
479
- * exits 1, with the stack in `output`. `process.exitCode`, not `process.exit`, so stdout and stderr flush.
480
- * Its stdout and stderr are teed live as they arrive, and the same text is returned in `output` for assertions.
481
- * `environment` carries a run's probe variables onto the driver's spawn. The workspace data key comes last, so
482
- * no caller's entry can override the fixture's own workspace data.
483
- */
484
- async function runGroupExecutor(
485
- root: string,
486
- options: BoundedExecOptions,
487
- context: NxTaskContext,
488
- environment: Record<string, string> = {},
489
- ): Promise<Tracked> {
490
- const script = `import boundedExecExecutor from ${JSON.stringify(EXECUTOR_MODULE)};
491
- console.log('driver ready: calling the default executor');
492
- const result = await boundedExecExecutor(${JSON.stringify(options)}, ${JSON.stringify(context)});
493
- console.log('driver done: default executor success=' + result.success);
494
- process.exitCode = result.success ? 0 : 2;`;
495
- const result = await runTracked(root, ['node', '--input-type=module', '-e', script], {
496
- graceful: true,
497
- tee: true,
498
- overlay: { ...environment, NX_WORKSPACE_DATA_DIRECTORY: join(root, '.nx/workspace-data') },
499
- });
500
- return result;
501
- }
@@ -1,109 +0,0 @@
1
- import { expect, it } from 'bun:test';
2
- import { execFileSync, spawn } from 'node:child_process';
3
- import { mkdir, readFile, symlink, writeFile } from 'node:fs/promises';
4
- import { join } from 'node:path';
5
- import { guardEvent } from './__tests__/counted-cargo.js';
6
- import { fixtureNxEnv, withNxFixture } from './__tests__/fixture-nx-env.js';
7
-
8
- /**
9
- * Guards the cache-bound hunk of `patches/nx@23.2.1.patch`, the local build of
10
- * nrwl/nx#37269. When nx.json sets no `maxCacheSize`, Nx 23.2.1 bounds its
11
- * cache at a tenth of the disk holding it, and asks its native
12
- * `getDefaultMaxCacheSize`, which lists every mounted disk (`sysinfo`
13
- * `Disks::new_with_refreshed_list`). On macOS that is a `getfsstat` plus IOKit
14
- * and CacheDelete round trips per mount, on the client's main thread, between
15
- * hashing and the first task: about 80 ms on a quiet host, and up to 2.3 s
16
- * measured while disk images attach, detach or resize. Fixture `release pack`
17
- * runs stalled 16 s and 24 s in that same window with their daemon idle; that
18
- * this call was the stall is inferred, not captured. The patched bound asks
19
- * only the cache directory's filesystem (`statfs`).
20
- *
21
- * The fixture's Nx runs with that native call replaced by one that throws, so
22
- * a run that still consults the host's disk inventory fails instead of passing
23
- * whenever the host happens to be quiet. Drop the hunk, and keep this test,
24
- * once the Nx version in use contains that fix.
25
- */
26
-
27
- const repositoryRoot = join(import.meta.dir, '../../..');
28
-
29
- /** Loaded into every fixture Nx process before Nx itself. */
30
- const FORBID_DISK_INVENTORY = `require('nx/src/native').getDefaultMaxCacheSize = () => {
31
- throw new Error('Nx enumerated the host disks to bound its cache');
32
- };
33
- `;
34
-
35
- async function runNx(root: string, env: Record<string, string>): Promise<{ code: number | null; output: string }> {
36
- const child = spawn(
37
- 'node',
38
- [join(repositoryRoot, 'node_modules/.bin/nx'), 'run', 'app:build', '--outputStyle=static'],
39
- { cwd: root, env, detached: process.platform !== 'win32', stdio: ['ignore', 'pipe', 'pipe'] },
40
- );
41
- let output = '';
42
- child.stdout?.setEncoding('utf8').on('data', (text: string) => {
43
- output += text;
44
- });
45
- child.stderr?.setEncoding('utf8').on('data', (text: string) => {
46
- output += text;
47
- });
48
- const { promise: ended, resolve, reject } = Promise.withResolvers<number | null>();
49
- child.once('error', reject);
50
- child.once('close', resolve);
51
- try {
52
- const code = await guardEvent(
53
- ended,
54
- 'Nx app:build to close',
55
- () => `pid ${child.pid}, exit ${child.exitCode}, signal ${child.signalCode}\n${output}`,
56
- );
57
- return { code, output };
58
- } catch (error) {
59
- if (child.pid !== undefined && child.exitCode === null && child.signalCode === null) {
60
- try {
61
- process.kill(process.platform === 'win32' ? child.pid : -child.pid, 'SIGKILL');
62
- } catch (killError) {
63
- if (!(killError instanceof Error && 'code' in killError && killError.code === 'ESRCH')) {
64
- throw new AggregateError([error, killError], 'could not retire the failed fixture Nx command');
65
- }
66
- }
67
- }
68
- await ended.catch(() => undefined);
69
- throw error;
70
- }
71
- }
72
-
73
- it('bounds the default cache from its own filesystem without listing the host disks', async () => {
74
- await withNxFixture('nx-cache-bound-', async ({ workspace: root, socketDirectory }) => {
75
- await mkdir(join(root, 'app'));
76
- await symlink(join(repositoryRoot, 'node_modules'), join(root, 'node_modules'), 'dir');
77
- await writeFile(join(root, '.gitignore'), 'node_modules\n.nx\napp/result.txt\n');
78
- await writeFile(join(root, 'package.json'), JSON.stringify({ name: 'cache-bound-fixture', private: true }));
79
- // No maxCacheSize: the bound is Nx's default, the code under test.
80
- await writeFile(join(root, 'nx.json'), '{}\n');
81
- await writeFile(
82
- join(root, 'app/project.json'),
83
- JSON.stringify({
84
- name: 'app',
85
- targets: {
86
- build: {
87
- executor: 'nx:run-commands',
88
- cache: true,
89
- inputs: [],
90
- outputs: ['{projectRoot}/result.txt'],
91
- options: { cwd: 'app', command: 'printf built > result.txt' },
92
- },
93
- },
94
- }),
95
- );
96
- await writeFile(join(root, 'forbid-disk-inventory.cjs'), FORBID_DISK_INVENTORY);
97
- execFileSync('git', ['init', '--quiet', root], { stdio: 'pipe' });
98
-
99
- // The bound is taken by the client that runs the tasks, daemon or not.
100
- // The cache directory does not exist yet, as on a checkout's first run.
101
- const { code, output } = await runNx(root, {
102
- ...fixtureNxEnv(root, socketDirectory),
103
- NODE_OPTIONS: `--require ${join(root, 'forbid-disk-inventory.cjs')}`,
104
- });
105
- expect(output).not.toContain('Nx enumerated the host disks');
106
- expect(code, output).toBe(0);
107
- expect(await readFile(join(root, 'app/result.txt'), 'utf8')).toBe('built');
108
- });
109
- });