@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,228 +0,0 @@
1
- import { afterAll, expect, it } from 'bun:test';
2
- import { mkdir, readdir, readFile, realpath, stat, symlink, writeFile } from 'node:fs/promises';
3
- import { join } from 'node:path';
4
- import { fixtureNxEnv, withNxFixture } from './__tests__/fixture-nx-env.js';
5
- import { testFileInstallation } from './__tests__/owned-installation.js';
6
-
7
- /**
8
- * The plugin's `preTasksExecution`/`postTasksExecution` hooks, run by a real Nx subprocess in a
9
- * fixture workspace that registers the compiled `@smoothbricks/nx-plugin`. The hooks write a hint
10
- * only under a controller-selected receipt id: an ordinary run and an invalid id leave no namespace,
11
- * and a failed task is recorded as a failure, never as a success. The receipt variable is spelled
12
- * here rather than imported, so the test loads only the compiled plugin through Nx.
13
- */
14
-
15
- const RECEIPT_ENV = 'COWSHED_NX_TASK_RECEIPT_ID';
16
- const RECEIPT = '0123456789abcdef0123456789abcdef';
17
- const CHANGED_RECEIPT = 'fedcba9876543210fedcba9876543210';
18
- /** The Nx CLI of a fixture workspace's own installation. */
19
- const nxEntry = (workspace: string) => join(workspace, 'node_modules', '.bin', 'nx');
20
- const HINTS = join('.nx', 'cache', '.cowshed-task-results');
21
-
22
- /** The Nx and the plugin under test, one copy this file's fixtures share; none may write into it. */
23
- const installation = testFileInstallation('task-results-installation');
24
- afterAll(() => installation.retire());
25
-
26
- /** A fixture workspace: `app:build` caches its copy of `source.txt`; `app:fail` always exits 3. */
27
- async function writeWorkspace(workspace: string): Promise<void> {
28
- await mkdir(join(workspace, 'app'), { recursive: true });
29
- const git = Bun.spawnSync(['git', 'init', '--quiet', workspace]);
30
- expect(git.exitCode, git.stderr.toString()).toBe(0);
31
- await symlink(await installation.nodeModules(), join(workspace, 'node_modules'), 'dir');
32
- await writeFile(
33
- join(workspace, 'nx.json'),
34
- JSON.stringify({ cacheDirectory: '.nx/cache', plugins: ['@smoothbricks/nx-plugin'] }),
35
- );
36
- await writeFile(
37
- join(workspace, 'app', 'project.json'),
38
- JSON.stringify({
39
- name: 'app',
40
- targets: {
41
- build: {
42
- executor: 'nx:run-commands',
43
- cache: true,
44
- inputs: ['{projectRoot}/source.txt'],
45
- outputs: ['{projectRoot}/result.txt'],
46
- // runs.txt is an undeclared execution marker: it counts real executions, not cache hits.
47
- options: { cwd: 'app', command: 'cp source.txt result.txt && echo run >> runs.txt' },
48
- },
49
- fail: { executor: 'nx:run-commands', cache: false, options: { cwd: 'app', command: 'exit 3' } },
50
- },
51
- }),
52
- );
53
- await writeFile(join(workspace, 'app', 'source.txt'), 'one');
54
- }
55
-
56
- /** Runs one target with `nx run` under `env`, returning its exit code, output and argv. */
57
- async function nx(workspace: string, env: Record<string, string>, target: string) {
58
- const argv = [process.execPath, nxEntry(workspace), 'run', target, '--outputStyle=static'];
59
- const child = Bun.spawn(argv, { cwd: workspace, env, stdout: 'pipe', stderr: 'pipe' });
60
- const [exitCode, stdout, stderr] = await Promise.all([
61
- child.exited,
62
- new Response(child.stdout).text(),
63
- new Response(child.stderr).text(),
64
- ]);
65
- return { exitCode, log: `${stdout}${stderr}`, argv };
66
- }
67
-
68
- async function exists(path: string): Promise<boolean> {
69
- try {
70
- await stat(path);
71
- return true;
72
- } catch (error) {
73
- if (error instanceof Error && 'code' in error && error.code === 'ENOENT') return false;
74
- throw error;
75
- }
76
- }
77
-
78
- /** Executions of `app:build`, one `run` line per real execution. */
79
- async function runCount(workspace: string): Promise<number> {
80
- const lines = (await readFile(join(workspace, 'app', 'runs.txt'), 'utf8')).split('\n');
81
- return lines.filter((line) => line === 'run').length;
82
- }
83
-
84
- /** The single hint in a receipt's namespace, parsed. */
85
- async function readHint(namespace: string): Promise<unknown> {
86
- const files = await readdir(namespace);
87
- expect(files).toHaveLength(1);
88
- const [file] = files;
89
- if (file === undefined) throw new Error(`no hint in ${namespace}`);
90
- return JSON.parse(await readFile(join(namespace, file), 'utf8'));
91
- }
92
-
93
- it('records a task hint only under a controller receipt, and never on an ordinary run', async () => {
94
- await withNxFixture(
95
- 'task-results',
96
- async ({ workspace, socketDirectory }) => {
97
- await writeWorkspace(workspace);
98
- // The inherited receipt is dropped: only this test's runs choose one.
99
- const { [RECEIPT_ENV]: _inherited, ...ordinary } = fixtureNxEnv(workspace, socketDirectory);
100
- const hints = join(workspace, HINTS);
101
- const source = join(workspace, 'app', 'source.txt');
102
-
103
- const first = await nx(workspace, ordinary, 'app:build');
104
- expect(first.exitCode, first.log).toBe(0);
105
- expect(await runCount(workspace)).toBe(1);
106
- expect(await exists(hints)).toBe(false);
107
-
108
- const hit = await nx(workspace, { ...ordinary, [RECEIPT_ENV]: RECEIPT }, 'app:build');
109
- expect(hit.exitCode, hit.log).toBe(0);
110
- expect(hit.log).toContain('local cache');
111
- expect(await runCount(workspace)).toBe(1);
112
- expect(await readdir(hints)).toEqual([RECEIPT]);
113
- expect(await readHint(join(hints, RECEIPT))).toMatchObject({
114
- version: 1,
115
- requestId: RECEIPT,
116
- workspaceRoot: workspace,
117
- run: { argv: [process.execPath, await realpath(nxEntry(workspace)), ...hit.argv.slice(2)] },
118
- tasks: [{ task: { id: 'app:build', hash: expect.stringMatching(/^\d+$/) }, status: 'local-cache', code: 0 }],
119
- });
120
-
121
- const invalid = await nx(workspace, { ...ordinary, [RECEIPT_ENV]: 'NOT-A-REQUEST-ID' }, 'app:build');
122
- expect(invalid.exitCode, invalid.log).toBe(0);
123
- expect(invalid.log).toContain('is not a controller-selected 32-hex request id');
124
- expect(await readdir(hints)).toEqual([RECEIPT]);
125
-
126
- await writeFile(source, 'two');
127
- const changed = await nx(workspace, { ...ordinary, [RECEIPT_ENV]: CHANGED_RECEIPT }, 'app:build');
128
- expect(changed.exitCode, changed.log).toBe(0);
129
- expect(await runCount(workspace)).toBe(2);
130
- expect((await readdir(hints)).sort()).toEqual([RECEIPT, CHANGED_RECEIPT].sort());
131
- expect(await readHint(join(hints, CHANGED_RECEIPT))).toMatchObject({
132
- version: 1,
133
- requestId: CHANGED_RECEIPT,
134
- run: { argv: [process.execPath, await realpath(nxEntry(workspace)), ...changed.argv.slice(2)] },
135
- tasks: [{ task: { id: 'app:build', hash: expect.stringMatching(/^\d+$/) }, status: 'success', code: 0 }],
136
- });
137
- },
138
- '.',
139
- );
140
- });
141
-
142
- it('records a failed task as a failure under a receipt, never as a success', async () => {
143
- await withNxFixture(
144
- 'task-results-failure',
145
- async ({ workspace, socketDirectory }) => {
146
- await writeWorkspace(workspace);
147
- const { [RECEIPT_ENV]: _inherited, ...ordinary } = fixtureNxEnv(workspace, socketDirectory);
148
-
149
- const failed = await nx(workspace, { ...ordinary, [RECEIPT_ENV]: RECEIPT }, 'app:fail');
150
- expect(failed.exitCode).not.toBe(0);
151
- expect(await readHint(join(workspace, HINTS, RECEIPT))).toMatchObject({
152
- requestId: RECEIPT,
153
- tasks: [{ task: { id: 'app:fail' }, status: 'failure', code: 1 }],
154
- });
155
- },
156
- '.',
157
- );
158
- });
159
-
160
- it('records hints through a daemon-backed Nx only under a checked receipt', async () => {
161
- await withNxFixture(
162
- 'task-results-daemon',
163
- async ({ workspace, socketDirectory }) => {
164
- await writeWorkspace(workspace);
165
- // The daemon is on, as in normal use: the hooks run in the daemon, which receives the client's env.
166
- const daemon: Record<string, string> = { ...fixtureNxEnv(workspace, socketDirectory), NX_DAEMON: 'true' };
167
- const { [RECEIPT_ENV]: _inherited, ...ordinary } = daemon;
168
- const hints = join(workspace, HINTS);
169
- const namespaceA = join(hints, RECEIPT);
170
-
171
- const first = await nx(workspace, ordinary, 'app:build');
172
- expect(first.exitCode, first.log).toBe(0);
173
- expect(await runCount(workspace)).toBe(1);
174
- expect(await exists(hints)).toBe(false);
175
-
176
- const checkedA = await nx(workspace, { ...ordinary, [RECEIPT_ENV]: RECEIPT }, 'app:build');
177
- expect(checkedA.exitCode, checkedA.log).toBe(0);
178
- expect(checkedA.log).toContain('[existing outputs match the cache, left as is]');
179
- expect(await runCount(workspace)).toBe(1);
180
- expect(await readHint(namespaceA)).toMatchObject({
181
- version: 1,
182
- requestId: RECEIPT,
183
- workspaceRoot: workspace,
184
- run: { argv: [checkedA.argv[0] ?? '', await realpath(nxEntry(workspace)), ...checkedA.argv.slice(2)] },
185
- tasks: [
186
- {
187
- task: { id: 'app:build', hash: expect.stringMatching(/^\d+$/) },
188
- status: 'local-cache-kept-existing',
189
- code: 0,
190
- },
191
- ],
192
- });
193
-
194
- // An ordinary run without a key must neither add a hint nor rewrite checked hint A.
195
- const [fileA] = await readdir(namespaceA);
196
- if (fileA === undefined) throw new Error(`no hint in ${namespaceA}`);
197
- const hintA = join(namespaceA, fileA);
198
- const bytesA = await readFile(hintA, 'utf8');
199
- const mtimeA = (await stat(hintA, { bigint: true })).mtimeNs;
200
- const ordinaryAgain = await nx(workspace, ordinary, 'app:build');
201
- expect(ordinaryAgain.exitCode, ordinaryAgain.log).toBe(0);
202
- expect(await readdir(hints)).toEqual([RECEIPT]);
203
- expect(await readdir(namespaceA)).toEqual([fileA]);
204
- expect(await readFile(hintA, 'utf8')).toBe(bytesA);
205
- expect((await stat(hintA, { bigint: true })).mtimeNs).toBe(mtimeA);
206
-
207
- // A new valid receipt records its own namespace, and the unchanged task is still not executed.
208
- const checkedB = await nx(workspace, { ...ordinary, [RECEIPT_ENV]: CHANGED_RECEIPT }, 'app:build');
209
- expect(checkedB.exitCode, checkedB.log).toBe(0);
210
- expect(await runCount(workspace)).toBe(1);
211
- expect((await readdir(hints)).sort()).toEqual([RECEIPT, CHANGED_RECEIPT].sort());
212
- expect(await readHint(join(hints, CHANGED_RECEIPT))).toMatchObject({
213
- version: 1,
214
- requestId: CHANGED_RECEIPT,
215
- workspaceRoot: workspace,
216
- run: { argv: [checkedB.argv[0] ?? '', await realpath(nxEntry(workspace)), ...checkedB.argv.slice(2)] },
217
- tasks: [
218
- {
219
- task: { id: 'app:build', hash: expect.stringMatching(/^\d+$/) },
220
- status: 'local-cache-kept-existing',
221
- code: 0,
222
- },
223
- ],
224
- });
225
- },
226
- '.',
227
- );
228
- });
@@ -1,338 +0,0 @@
1
- import { describe, expect, it } from 'bun:test';
2
- import { spawnSync } from 'node:child_process';
3
- import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
4
- import { tmpdir } from 'node:os';
5
- import { dirname, join } from 'node:path';
6
- import { type ClockOracleKind, findClockOracles, formatClockOracle, TEST_CLOCK_ORACLE } from './test-clock-policy.js';
7
- import { diffScope } from './test-walk-policy.js';
8
-
9
- const lines = (...source: string[]): string => `${source.join('\n')}\n`;
10
- // Assembled so this file's own cases carry no runner flag a scan of it would read as a bound.
11
- const flag = ['--time', 'out'].join('');
12
-
13
- describe('test-clock-policy', () => {
14
- // One walk: each planted site and each control is a step over one fixture directory, then the diff scope.
15
- it('refuses runner and test-owned deadlines, elapsed-time asserts and clocked bounds, passes the controls, and scopes to changed cases', () => {
16
- const root = mkdtempSync(join(tmpdir(), 'test-clock-policy-'));
17
- const write = (file: string, source: string): void => {
18
- mkdirSync(dirname(join(root, file)), { recursive: true });
19
- writeFileSync(join(root, file), source);
20
- };
21
- const kinds = (file: string) => findClockOracles(root, [file]).map((oracle) => oracle.kind);
22
- const git = (...args: string[]): string => {
23
- const result = spawnSync(
24
- 'git',
25
- ['-c', 'user.name=Fixture', '-c', 'user.email=fixture@example.invalid', ...args],
26
- {
27
- cwd: root,
28
- encoding: 'utf8',
29
- env: { ...process.env, GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_NOSYSTEM: '1' },
30
- },
31
- );
32
- if (result.status !== 0) throw new Error(`git ${args.join(' ')}: ${result.stderr}`);
33
- return result.stdout;
34
- };
35
- try {
36
- const planted: readonly [ClockOracleKind, string, string][] = [
37
- ['runner-deadline', 'tests/a.test.ts', "test('slow', async () => { await child.exited; }, 60_000);"],
38
- [
39
- 'runner-deadline',
40
- 'tests/a.test.ts',
41
- "test('slow', async () => { await child.exited; }, { timeout: 60_000 });",
42
- ],
43
- ['runner-deadline', 'tests/a.test.ts', "test.each([1])('n %d', async (n) => { await run(n); }, 30_000);"],
44
- ['runner-deadline', 'tests/a.test.ts', 'setDefaultTimeout(60_000);'],
45
- [
46
- 'clock-delta',
47
- 'tests/a.test.ts',
48
- "test('fast', async () => { const started = Date.now(); await run(); expect(Date.now() - started).toBeLessThan(5_000); });",
49
- ],
50
- [
51
- 'clock-delta',
52
- 'tests/a.test.ts',
53
- "test('fast', () => { const t = performance.now(); work(); const elapsedMs = performance.now() - t; expect(elapsedMs < 1_000).toBe(true); });",
54
- ],
55
- [
56
- 'clock-delta',
57
- 'tests/a.test.ts',
58
- "test('deadline', () => { const deadline = Date.now() + 1_000; work(); expect(Date.now()).toBeLessThanOrEqual(deadline); });",
59
- ],
60
- [
61
- 'clock-delta',
62
- 'tests/a.test.ts',
63
- "test('close', () => { expect(Math.abs(stamp() - Date.now())).not.toBeGreaterThan(1); });",
64
- ],
65
- [
66
- 'clock-delta',
67
- 'tests/quick.rs',
68
- lines(
69
- '#[test]',
70
- 'fn quick() {',
71
- ' let started = Instant::now();',
72
- ' work();',
73
- ' assert!(started.elapsed() < Duration::from_secs(10), "slow");',
74
- '}',
75
- ),
76
- ],
77
- [
78
- 'clock-delta',
79
- 'src/quick.rs',
80
- lines(
81
- 'fn work() {}',
82
- '#[cfg(test)]',
83
- 'mod tests {',
84
- ' #[test]',
85
- ' fn quick() {',
86
- ' let started = Instant::now();',
87
- ' let elapsed = started.elapsed();',
88
- ' assert!(Duration::from_millis(500) > elapsed);',
89
- ' }',
90
- '}',
91
- ),
92
- ],
93
- [
94
- 'clocked-bound',
95
- 'tests/a.test.ts',
96
- `test('times out', async () => { const result = await runBoundedExec({ command: 'node -e "setTimeout(() => {}, 5000)"', timeoutMs: 50 }); expect(result.success).toBe(false); });`,
97
- ],
98
- [
99
- 'clocked-bound',
100
- 'tests/a.test.ts',
101
- lines(
102
- "const SLOW = `test('slow', async () => { await new Promise((r) => setTimeout(r, 5000)); });`;",
103
- `test('per-test bound', async () => { expect(await verdictOf('bun test ${flag}=100 ./slow.test.ts', { 'slow.test.ts': SLOW })).toEqual({ outcome: 'bound' }); });`,
104
- ),
105
- ],
106
- [
107
- 'clocked-bound',
108
- 'tests/a.test.ts',
109
- "test('idle', async () => { await run({ argv: ['sleep', '5'], idleTimeoutSeconds: 1 }); });",
110
- ],
111
- [
112
- 'clocked-bound',
113
- 'tests/a.test.ts',
114
- "test('short stand-in', async () => { const path = await fakeChild('exec sleep 30'); await openService({ path, lspQueryTimeoutMs: 1_000 }); });",
115
- ],
116
- [
117
- 'clocked-bound',
118
- 'tests/a.test.ts',
119
- `test('talking child under a progress bound', async () => { await verdictOf('node -e "setInterval(() => console.log(1), 10)"', { idleTimeoutMs: 100 }); });`,
120
- ],
121
- [
122
- 'clocked-bound',
123
- 'tests/bound.rs',
124
- lines(
125
- '#[test]',
126
- 'fn bound() {',
127
- ' let outcome = run(Command::new("sleep").arg("5"), Options { timeout_ms: 50 });',
128
- ' assert!(outcome.timed_out);',
129
- '}',
130
- ),
131
- ],
132
- [
133
- 'test-deadline',
134
- 'tests/deadline.rs',
135
- lines(
136
- '#[test]',
137
- 'fn event() {',
138
- ' let (tx, rx) = channel();',
139
- ' spawn(tx);',
140
- ' rx.recv_timeout(Duration::from_secs(10)).expect("the event");',
141
- '}',
142
- ),
143
- ],
144
- [
145
- 'test-deadline',
146
- 'tests/deadline.rs',
147
- lines(
148
- '#[tokio::test]',
149
- 'async fn event() {',
150
- ' tokio::time::timeout(Duration::from_millis(500), served()).await.expect("served");',
151
- '}',
152
- ),
153
- ],
154
- ];
155
- for (const [kind, file, source] of planted) {
156
- write(file, source);
157
- expect([file, source, kinds(file)]).toEqual([file, source, [kind]]);
158
- rmSync(join(root, file));
159
- }
160
- write('tests/a.test.ts', planted[4]?.[2] ?? '');
161
- const diagnostic = findClockOracles(root, ['tests/a.test.ts']).map(formatClockOracle)[0] ?? '';
162
- for (const part of [
163
- `error[${TEST_CLOCK_ORACLE.id}]: ${TEST_CLOCK_ORACLE.message['clock-delta']}`,
164
- ' --> tests/a.test.ts:1:',
165
- ' = help: Elapsed time on a loaded host',
166
- ])
167
- expect(diagnostic).toContain(part);
168
- rmSync(join(root, 'tests/a.test.ts'));
169
-
170
- const controls: readonly [string, string][] = [
171
- [
172
- 'tests/c.test.ts',
173
- "test('injected clock', () => { const timer = new MemoryTimer(); const started = timer.now(); timer.advance(30); expect(timer.now() - started).toBeLessThan(31); });",
174
- ],
175
- [
176
- 'tests/c.test.ts',
177
- `test('exit decides', async () => { const run = await onProgressClock(() => false, 0, () => verdictOf('node -e ""', { timeoutMs: 5_000 })); expect(run.result).toEqual({ outcome: 'passed' }); });`,
178
- ],
179
- [
180
- 'tests/c.test.ts',
181
- `test('subject held off by construction', async () => { const result = await runBoundedExec({ command: 'node -e "process.stdin.resume()"', timeoutMs: 50 }); expect(result.terminalOutput).toContain('timeoutMs=50'); });`,
182
- ],
183
- [
184
- 'tests/c.test.ts',
185
- `test('bounds that cannot decide', async () => { await runBoundedExec({ command: 'node -e "setTimeout(() => {}, 400)"', idleTimeoutMs: 0, timeoutMs: 180_000 }); });`,
186
- ],
187
- [
188
- 'tests/c.test.ts',
189
- "test('waited at least', async () => { const started = performance.now(); await lock.acquired; expect(performance.now() - started).toBeGreaterThanOrEqual(100); });",
190
- ],
191
- [
192
- 'tests/c.test.ts',
193
- "test('stamped after', () => { const before = Date.now(); const record = make(); expect(record.at).toBeGreaterThanOrEqual(before); expect(before).toBeLessThanOrEqual(record.at); });",
194
- ],
195
- ['tests/c.test.ts', "test('cpu time', () => { expect(cpuTime.total).toBeLessThanOrEqual(100_000); });"],
196
- [
197
- 'tests/c.test.ts',
198
- "test('stand-in outlasts the leg', async () => { const path = await fakeChild('exec sleep 3600'); await openService({ path, lspQueryTimeoutMs: 1_000 }); });",
199
- ],
200
- [
201
- 'tests/c.test.ts',
202
- `test('silent child held past the backstop', async () => { await runBoundedExec({ command: 'node -e "setInterval(() => {}, 1 << 30)"', timeoutMs: 50, killAfterMs: 10 }); });`,
203
- ],
204
- [
205
- 'tests/c.test.ts',
206
- `test('a ceiling and a progress bound', async () => { await verdictOf('node -e "setInterval(() => console.log(1), 10)"', { timeoutMs: 200 }); await verdictOf('node -e "setInterval(() => {}, 1 << 30)"', { idleTimeoutMs: 100 }); });`,
207
- ],
208
- [
209
- 'tests/c.test.ts',
210
- `test('virtual progress clock', async () => { const script = "setInterval(() => console.error('SLOW'), 50);"; await onProgressClock((chunk) => chunk.includes('SLOW'), 400, () => runBoundedExec({ command: 'node runner.js', idleTimeoutMs: 400 })); expect(verdict).toMatchObject({ outcome: 'wedged', idleMs: 400 }); });`,
211
- ],
212
- [
213
- 'tests/c.rs',
214
- lines(
215
- '#[tokio::test]',
216
- 'async fn parked() {',
217
- ' let child = Command::new("sleep").arg("1");',
218
- ' assert!(tokio::time::timeout(Duration::from_millis(500), &mut parked).await.is_err());',
219
- '}',
220
- ),
221
- ],
222
- [
223
- 'tests/c.test.ts',
224
- lines(
225
- 'const elapsed = Date.now() - t0;',
226
- "test('shadowed', () => { const elapsed = timer.elapsed(); expect(elapsed).toBeLessThan(5); });",
227
- ),
228
- ],
229
- [
230
- 'tests/c.rs',
231
- lines(
232
- '#[test]',
233
- 'fn waited() {',
234
- ' let started = Instant::now();',
235
- ' acquire();',
236
- ' assert!(started.elapsed() >= Duration::from_millis(100));',
237
- ' let clock = ManualClock::new();',
238
- ' clock.advance(Duration::from_millis(30));',
239
- ' assert!(clock.elapsed() < Duration::from_millis(31));',
240
- '}',
241
- ),
242
- ],
243
- [
244
- 'tests/c.rs',
245
- lines(
246
- '#[test]',
247
- 'fn stamped() {',
248
- ' let wall_before = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_micros();',
249
- ' let since_us = start();',
250
- ' assert!(since_us >= wall_before);',
251
- ' let config = format!(r#"timeoutMs = 1; cmd = "sleep 5""#);',
252
- '}',
253
- ),
254
- ],
255
- [
256
- 'tests/c.rs',
257
- lines(
258
- '#[tokio::test]',
259
- 'async fn quiet() {',
260
- ' assert!(timeout(Duration::from_millis(50), rx.recv()).await.is_err());',
261
- ' timeout(NO_PROGRESS, served()).await.expect("served");',
262
- '}',
263
- ),
264
- ],
265
- [
266
- 'tests/c.rs',
267
- lines(
268
- '#[tokio::test(start_paused = true)]',
269
- 'async fn virtual_time() {',
270
- ' let deadline = Instant::now() + Duration::from_secs(5);',
271
- ' advance().await;',
272
- ' assert!(Instant::now() < deadline);',
273
- ' timeout(Duration::from_millis(500), served()).await.expect("served");',
274
- '}',
275
- ),
276
- ],
277
- ];
278
- for (const [file, source] of controls) {
279
- write(file, source);
280
- expect([source, kinds(file)]).toEqual([source, []]);
281
- rmSync(join(root, file));
282
- }
283
-
284
- // Diff scope: an existing elapsed bound in the upstream refuses nothing until its own case is edited, and then the
285
- // whole case is examined; the bin judges the same changes.
286
- const legacy = [
287
- "test('old elapsed bound', async () => {",
288
- ' const started = Date.now();',
289
- ' await run();',
290
- ' expect(Date.now() - started).toBeLessThan(5_000);',
291
- '});',
292
- "test('event case', async () => {",
293
- ' await child.exited;',
294
- '});',
295
- ];
296
- write('tests/legacy.test.ts', lines(...legacy));
297
- git('init', '--quiet', '-b', 'main');
298
- git('add', '.');
299
- git('commit', '--quiet', '-m', 'base');
300
- git('checkout', '--quiet', '-b', 'topic');
301
- const base = git('rev-parse', 'HEAD').trim();
302
- const judged = () => {
303
- const scope = diffScope(root, base);
304
- if (!scope.ok) throw new Error(scope.reason);
305
- return findClockOracles(root, scope.value.files, scope.value.changes).map((oracle) => [
306
- oracle.kind,
307
- oracle.line,
308
- ]);
309
- };
310
- expect(judged()).toEqual([]);
311
- write('tests/legacy.test.ts', lines(...legacy.slice(0, 6), ' await child.closed;', ...legacy.slice(7)));
312
- expect(judged()).toEqual([]);
313
- write(
314
- 'tests/legacy.test.ts',
315
- lines(...legacy.slice(0, 2), ' await run({ verbose: true });', ...legacy.slice(3)),
316
- );
317
- expect(judged()).toEqual([['clock-delta', 4]]);
318
- const scope = diffScope(root, base);
319
- expect(
320
- (scope.ok ? findClockOracles(root, scope.value.files, scope.value.changes) : [])
321
- .map(formatClockOracle)
322
- .map((each) => each.split('\n').slice(0, 2)),
323
- ).toEqual([
324
- [
325
- `error[${TEST_CLOCK_ORACLE.id}]: ${TEST_CLOCK_ORACLE.message['clock-delta']}: expect(Date.now() - started).toBeLessThan(5_000)`,
326
- ' --> tests/legacy.test.ts:4:3',
327
- ],
328
- ]);
329
- write('tests/new.test.ts', planted[0]?.[2] ?? '');
330
- expect(judged()).toEqual([
331
- ['clock-delta', 4],
332
- ['runner-deadline', 1],
333
- ]);
334
- } finally {
335
- rmSync(root, { recursive: true, force: true });
336
- }
337
- });
338
- });