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