@smoothbricks/nx-plugin 0.5.6 → 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.
- package/README.md +1095 -360
- package/dist/.build-inputs.json +138 -0
- package/dist/bin/smoo-nx-cargo-toolchain.d.ts +3 -0
- package/dist/bin/smoo-nx-cargo-toolchain.d.ts.map +1 -0
- package/dist/bin/smoo-nx-cargo-toolchain.js +8 -0
- package/dist/bin/smoo-nx-forbidden-spellings.d.ts +3 -0
- package/dist/bin/smoo-nx-forbidden-spellings.d.ts.map +1 -0
- package/dist/bin/smoo-nx-forbidden-spellings.js +32 -0
- package/dist/bin/smoo-nx-nextest-timings.d.ts +3 -0
- package/dist/bin/smoo-nx-nextest-timings.d.ts.map +1 -0
- package/dist/bin/smoo-nx-nextest-timings.js +28 -0
- package/dist/bounded-test-policy.d.ts +1 -1
- package/dist/bounded-test-policy.d.ts.map +1 -1
- package/dist/bounded-test-policy.js +14 -15
- package/dist/build-state-output-policy.d.ts +95 -1
- package/dist/build-state-output-policy.d.ts.map +1 -1
- package/dist/build-state-output-policy.js +368 -30
- package/dist/bun-lock-scope.d.ts +44 -0
- package/dist/bun-lock-scope.d.ts.map +1 -0
- package/dist/bun-lock-scope.js +97 -0
- package/dist/cargo-build-script-env.d.ts +49 -0
- package/dist/cargo-build-script-env.d.ts.map +1 -0
- package/dist/cargo-build-script-env.js +324 -0
- package/dist/cargo-closure-input.d.ts +31 -4
- package/dist/cargo-closure-input.d.ts.map +1 -1
- package/dist/cargo-closure-input.js +66 -6
- package/dist/cargo-retention-hook.d.ts +17 -0
- package/dist/cargo-retention-hook.d.ts.map +1 -0
- package/dist/cargo-retention-hook.js +85 -0
- package/dist/cargo-source-hash.d.ts +25 -7
- package/dist/cargo-source-hash.d.ts.map +1 -1
- package/dist/cargo-source-hash.js +108 -43
- package/dist/cargo-toolchain-paths.d.ts +40 -0
- package/dist/cargo-toolchain-paths.d.ts.map +1 -0
- package/dist/cargo-toolchain-paths.js +84 -0
- package/dist/cargo-toolchain-policy.d.ts +25 -8
- package/dist/cargo-toolchain-policy.d.ts.map +1 -1
- package/dist/cargo-toolchain-policy.js +39 -5
- package/dist/cargo-workspace.d.ts +10 -4
- package/dist/cargo-workspace.d.ts.map +1 -1
- package/dist/cargo-workspace.js +65 -95
- package/dist/cross-check-policy.d.ts +9 -9
- package/dist/cross-check-policy.d.ts.map +1 -1
- package/dist/cross-check-policy.js +11 -11
- package/dist/disk-command-policy.d.ts.map +1 -1
- package/dist/disk-command-policy.js +1 -0
- package/dist/ensure-built-receipt.d.ts +13 -5
- package/dist/ensure-built-receipt.d.ts.map +1 -1
- package/dist/ensure-built-receipt.js +126 -47
- package/dist/ensure-built-witness.d.ts +27 -8
- package/dist/ensure-built-witness.d.ts.map +1 -1
- package/dist/ensure-built-witness.js +45 -15
- package/dist/ensure-built.d.ts.map +1 -1
- package/dist/ensure-built.js +9 -1
- package/dist/eslint-config-closure.d.ts +7 -0
- package/dist/eslint-config-closure.d.ts.map +1 -0
- package/dist/eslint-config-closure.js +346 -0
- package/dist/executors/all-verdicts/executor.d.ts +35 -0
- package/dist/executors/all-verdicts/executor.d.ts.map +1 -0
- package/dist/executors/all-verdicts/executor.js +133 -0
- package/dist/executors/all-verdicts/schema.d.ts +10 -0
- package/dist/executors/all-verdicts/schema.d.ts.map +1 -0
- package/dist/executors/all-verdicts/schema.js +2 -0
- package/dist/executors/bounded-exec/bounds.d.ts +56 -0
- package/dist/executors/bounded-exec/bounds.d.ts.map +1 -0
- package/dist/executors/bounded-exec/bounds.js +43 -0
- package/dist/executors/bounded-exec/cpu-pool.d.ts +33 -36
- package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/cpu-pool.js +54 -119
- package/dist/executors/bounded-exec/executor.d.ts +19 -12
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +371 -239
- package/dist/executors/bounded-exec/gateway-lease.d.ts +22 -19
- package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -1
- package/dist/executors/bounded-exec/gateway-lease.js +81 -28
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts +18 -1
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
- package/dist/executors/bounded-exec/hang-diagnostics.js +148 -30
- package/dist/executors/bounded-exec/lease-wait.d.ts +43 -0
- package/dist/executors/bounded-exec/lease-wait.d.ts.map +1 -0
- package/dist/executors/bounded-exec/lease-wait.js +68 -0
- package/dist/executors/bounded-exec/lock-wait.d.ts +51 -0
- package/dist/executors/bounded-exec/lock-wait.d.ts.map +1 -0
- package/dist/executors/bounded-exec/lock-wait.js +108 -0
- package/dist/executors/bounded-exec/owned-subtree.d.ts +84 -0
- package/dist/executors/bounded-exec/owned-subtree.d.ts.map +1 -0
- package/dist/executors/bounded-exec/owned-subtree.js +178 -0
- package/dist/executors/bounded-exec/progress.d.ts +4 -1
- package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
- package/dist/executors/bounded-exec/progress.js +5 -2
- package/dist/executors/bounded-exec/ram-attach.d.ts +19 -0
- package/dist/executors/bounded-exec/ram-attach.d.ts.map +1 -0
- package/dist/executors/bounded-exec/ram-attach.js +207 -0
- package/dist/executors/bounded-exec/ram-detach.d.ts +25 -0
- package/dist/executors/bounded-exec/ram-detach.d.ts.map +1 -0
- package/dist/executors/bounded-exec/ram-detach.js +207 -0
- package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts +76 -0
- package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts.map +1 -1
- package/dist/executors/bounded-exec/ram-temp-fixtures.js +296 -0
- package/dist/executors/bounded-exec/ram-temp.d.ts +388 -88
- package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -1
- package/dist/executors/bounded-exec/ram-temp.js +1213 -399
- package/dist/executors/bounded-exec/run-cpu-pool.d.ts +4 -4
- package/dist/executors/bounded-exec/run-cpu-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/run-cpu-pool.js +20 -30
- package/dist/executors/bounded-exec/runner-hook.js +14 -5
- package/dist/executors/bounded-exec/runner-lifecycle.d.ts +14 -1
- package/dist/executors/bounded-exec/runner-lifecycle.d.ts.map +1 -1
- package/dist/executors/bounded-exec/runner-lifecycle.js +27 -6
- package/dist/executors/bounded-exec/{cpu-tokens.d.ts → runner-sizing.d.ts} +14 -42
- package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -0
- package/dist/executors/bounded-exec/{cpu-tokens.js → runner-sizing.js} +5 -35
- package/dist/executors/bounded-exec/runtime-pin.d.ts +73 -0
- package/dist/executors/bounded-exec/runtime-pin.d.ts.map +1 -0
- package/dist/executors/bounded-exec/runtime-pin.js +167 -0
- package/dist/executors/bounded-exec/schema.d.ts +18 -1
- package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
- package/dist/executors/bounded-exec/verdict.d.ts +40 -11
- package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
- package/dist/executors/bounded-exec/verdict.js +88 -19
- package/dist/executors/cargo-zigbuild/executor.d.ts +21 -0
- package/dist/executors/cargo-zigbuild/executor.d.ts.map +1 -1
- package/dist/executors/cargo-zigbuild/executor.js +67 -12
- package/dist/executors/clean-outputs/executor.js +1 -0
- package/dist/executors/scriptc-native/executor.d.ts +79 -0
- package/dist/executors/scriptc-native/executor.d.ts.map +1 -0
- package/dist/executors/scriptc-native/executor.js +367 -0
- package/dist/executors/scriptc-native/ffi-paths.d.ts +9 -0
- package/dist/executors/scriptc-native/ffi-paths.d.ts.map +1 -0
- package/dist/executors/scriptc-native/ffi-paths.js +25 -0
- package/dist/executors/scriptc-native/schema.d.ts +34 -0
- package/dist/executors/scriptc-native/schema.d.ts.map +1 -0
- package/dist/executors/scriptc-native/schema.js +1 -0
- package/dist/executors/typescript-emit/executor.d.ts +3 -1
- package/dist/executors/typescript-emit/executor.d.ts.map +1 -1
- package/dist/executors/typescript-emit/executor.js +164 -33
- package/dist/forbidden-spelling-policy.d.ts +56 -0
- package/dist/forbidden-spelling-policy.d.ts.map +1 -0
- package/dist/forbidden-spelling-policy.js +176 -0
- package/dist/generators/create-package/generator.d.ts.map +1 -1
- package/dist/generators/create-package/generator.js +3 -4
- package/dist/graph-input-contract.d.ts +14 -0
- package/dist/graph-input-contract.d.ts.map +1 -1
- package/dist/graph-input-contract.js +67 -2
- package/dist/index.d.ts +23 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +676 -215
- package/dist/managed-assets.d.ts +2 -0
- package/dist/managed-assets.d.ts.map +1 -1
- package/dist/managed-files/files.d.ts +3 -3
- package/dist/managed-files/files.d.ts.map +1 -1
- package/dist/managed-files/files.js +28 -3
- package/dist/managed-files/managed-format.d.ts.map +1 -1
- package/dist/managed-files/managed-format.js +1 -0
- package/dist/nextest-code-bound.js +1 -0
- package/dist/nextest-timings.d.ts +35 -0
- package/dist/nextest-timings.d.ts.map +1 -0
- package/dist/nextest-timings.js +168 -0
- package/dist/owned-installation.d.ts +6 -5
- package/dist/owned-installation.d.ts.map +1 -1
- package/dist/owned-installation.js +150 -26
- package/dist/package-target-policy.d.ts.map +1 -1
- package/dist/package-target-policy.js +2 -3
- package/dist/process-children.d.ts +7 -0
- package/dist/process-children.d.ts.map +1 -0
- package/dist/process-children.darwin.d.ts +7 -0
- package/dist/process-children.darwin.d.ts.map +1 -0
- package/dist/process-children.darwin.js +13 -0
- package/dist/process-children.js +14 -0
- package/dist/process-children.linux.d.ts +8 -0
- package/dist/process-children.linux.d.ts.map +1 -0
- package/dist/process-children.linux.js +25 -0
- package/dist/process-group.d.ts +108 -0
- package/dist/process-group.d.ts.map +1 -0
- package/dist/process-group.js +171 -0
- package/dist/process-listing.d.ts +7 -0
- package/dist/process-listing.d.ts.map +1 -0
- package/dist/process-listing.js +51 -0
- package/dist/producer-receipts.d.ts +8 -2
- package/dist/producer-receipts.d.ts.map +1 -1
- package/dist/producer-receipts.js +75 -48
- package/dist/task-graph-policy.d.ts +21 -0
- package/dist/task-graph-policy.d.ts.map +1 -0
- package/dist/task-graph-policy.js +91 -0
- package/dist/test-timings.js +4 -4
- package/dist/test-walk-policy.d.ts +14 -5
- package/dist/test-walk-policy.d.ts.map +1 -1
- package/dist/test-walk-policy.js +8 -2
- package/dist/testing.d.ts +73 -28
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +217 -223
- package/dist/tool-bins.d.ts +33 -0
- package/dist/tool-bins.d.ts.map +1 -0
- package/dist/tool-bins.js +72 -0
- package/dist/typecheck-test-policy.d.ts.map +1 -1
- package/dist/typecheck-test-policy.js +3 -4
- package/dist/wait-why-policy.d.ts +28 -0
- package/dist/wait-why-policy.d.ts.map +1 -0
- package/dist/wait-why-policy.js +223 -0
- package/dist/workspace-config-policy.d.ts +14 -8
- package/dist/workspace-config-policy.d.ts.map +1 -1
- package/dist/workspace-config-policy.js +60 -16
- package/dist/workspace-manifest.d.ts +41 -6
- package/dist/workspace-manifest.d.ts.map +1 -1
- package/dist/workspace-manifest.js +57 -0
- package/executors.json +21 -1
- package/loader.js +2 -0
- package/managed/raw/envrc +11 -0
- package/managed/raw/patches/nx@23.2.1.patch +2840 -199
- package/managed/raw/patches/ttsc@0.34.1.patch +119 -0
- package/managed/raw/tooling/direnv/cargo-fetch-bound.ts +245 -0
- package/managed/raw/tooling/direnv/cargo-fetch-run.ts +299 -0
- package/managed/raw/tooling/direnv/compiler-variables.sh +42 -0
- package/managed/raw/tooling/direnv/developer-links.ts +464 -25
- package/managed/raw/tooling/direnv/devenv.smoo.nix +78 -38
- package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +14 -12
- package/managed/raw/tooling/direnv/installed-bun-links.ts +308 -0
- package/managed/raw/tooling/direnv/linked-snapshots.ts +62 -3
- package/managed/raw/tooling/direnv/nx-socket-dir.sh +56 -17
- package/managed/raw/tooling/direnv/repo-path +68 -6
- package/managed/raw/tooling/direnv/secret-references.ts +13 -4
- package/managed/raw/tooling/direnv/setup-environment.ts +128 -537
- package/managed/raw/tooling/direnv/toolchain-stamp.ts +4 -2
- package/managed/raw/tooling/direnv/ttsc-env.sh +9 -0
- package/managed/raw/tooling/direnv/uv-relocation.ts +227 -0
- package/managed/raw/tooling/git-hooks/commit-msg.sh +2 -1
- package/managed/raw/tooling/git-hooks/pre-commit.sh +2 -1
- package/managed/raw/tooling/git-hooks/pre-push.sh +2 -1
- package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +85 -7
- package/managed/templates/github/actions/save-nix-devenv/action.yml +12 -2
- package/managed/templates/github/actions/setup-devenv/action.yml +2 -0
- package/package.json +77 -13
- package/src/bin/smoo-nx-cargo-toolchain.ts +11 -0
- package/src/bin/smoo-nx-forbidden-spellings.ts +33 -0
- package/src/bin/smoo-nx-nextest-timings.ts +31 -0
- package/src/bounded-test-policy.ts +12 -14
- package/src/build-state-output-policy.ts +458 -34
- package/src/bun-lock-scope.ts +108 -0
- package/src/cargo-build-script-env.ts +265 -0
- package/src/cargo-closure-input.ts +74 -7
- package/src/cargo-retention-hook.ts +94 -0
- package/src/cargo-source-hash.ts +138 -41
- package/src/cargo-toolchain-paths.ts +95 -0
- package/src/cargo-toolchain-policy.ts +49 -5
- package/src/cargo-workspace.ts +72 -123
- package/src/cross-check-policy.ts +12 -10
- package/src/disk-command-policy.ts +1 -0
- package/src/ensure-built-receipt.ts +132 -39
- package/src/ensure-built-witness.ts +62 -10
- package/src/ensure-built.ts +11 -1
- package/src/eslint-config-closure.ts +357 -0
- package/src/executors/all-verdicts/executor.ts +164 -0
- package/src/executors/all-verdicts/schema.json +22 -0
- package/src/executors/all-verdicts/schema.ts +10 -0
- package/src/executors/bounded-exec/bounds.ts +76 -0
- package/src/executors/bounded-exec/cpu-pool.ts +51 -117
- package/src/executors/bounded-exec/executor.ts +423 -259
- package/src/executors/bounded-exec/gateway-lease.ts +82 -33
- package/src/executors/bounded-exec/hang-diagnostics.ts +173 -31
- package/src/executors/bounded-exec/lease-wait.ts +89 -0
- package/src/executors/bounded-exec/lock-wait.ts +141 -0
- package/src/executors/bounded-exec/owned-subtree.ts +235 -0
- package/src/executors/bounded-exec/progress.ts +9 -3
- package/src/executors/bounded-exec/ram-attach.ts +238 -0
- package/src/executors/bounded-exec/ram-detach.ts +226 -0
- package/src/executors/bounded-exec/ram-temp-fixtures.ts +358 -0
- package/src/executors/bounded-exec/ram-temp-registry.txt +440 -0
- package/src/executors/bounded-exec/ram-temp.ts +1497 -460
- package/src/executors/bounded-exec/run-cpu-pool.ts +22 -30
- package/src/executors/bounded-exec/runner-hook.ts +14 -6
- package/src/executors/bounded-exec/runner-lifecycle.ts +31 -8
- package/src/executors/bounded-exec/{cpu-tokens.ts → runner-sizing.ts} +13 -59
- package/src/executors/bounded-exec/runtime-pin.ts +232 -0
- package/src/executors/bounded-exec/schema.json +11 -2
- package/src/executors/bounded-exec/schema.ts +19 -1
- package/src/executors/bounded-exec/verdict.ts +137 -34
- package/src/executors/cargo-zigbuild/executor.ts +82 -8
- package/src/executors/clean-outputs/executor.ts +1 -0
- package/src/executors/scriptc-native/executor.ts +394 -0
- package/src/executors/scriptc-native/ffi-paths.ts +29 -0
- package/src/executors/scriptc-native/schema.json +60 -0
- package/src/executors/scriptc-native/schema.ts +34 -0
- package/src/executors/typescript-emit/executor.ts +205 -38
- package/src/forbidden-spelling-policy.ts +226 -0
- package/src/generators/create-package/generator.ts +7 -7
- package/src/graph-input-contract.ts +61 -2
- package/src/index.ts +792 -225
- package/src/managed-assets.ts +3 -0
- package/src/managed-files/files.ts +28 -3
- package/src/managed-files/managed-format.ts +1 -0
- package/src/nextest-code-bound.ts +1 -0
- package/src/nextest-timings.ts +106 -0
- package/src/owned-installation.ts +150 -23
- package/src/package-target-policy.ts +2 -3
- package/src/process-children.darwin.ts +14 -0
- package/src/process-children.linux.ts +33 -0
- package/src/process-children.ts +22 -0
- package/src/process-group.ts +209 -0
- package/src/process-listing.ts +54 -0
- package/src/producer-receipts.ts +68 -45
- package/src/task-graph-policy.ts +98 -0
- package/src/test-walk-policy.ts +23 -8
- package/src/testing.ts +240 -232
- package/src/tool-bins.ts +108 -0
- package/src/typecheck-test-policy.ts +2 -3
- package/src/wait-why-policy.ts +226 -0
- package/src/workspace-config-policy.ts +63 -15
- package/src/workspace-manifest.ts +89 -6
- package/test-timings.json +123 -98
- package/dist/bin/smoo-nx-failures.d.ts +0 -3
- package/dist/bin/smoo-nx-failures.d.ts.map +0 -1
- package/dist/bin/smoo-nx-failures.js +0 -3
- package/dist/bin/smoo-nx-nextest-extract.d.ts +0 -3
- package/dist/bin/smoo-nx-nextest-extract.d.ts.map +0 -1
- package/dist/bin/smoo-nx-nextest-extract.js +0 -42
- package/dist/executors/bounded-exec/cpu-tokens.d.ts.map +0 -1
- package/dist/failure-summary.d.ts +0 -5
- package/dist/failure-summary.d.ts.map +0 -1
- package/dist/failure-summary.js +0 -118
- package/dist/nextest-extraction.d.ts +0 -117
- package/dist/nextest-extraction.d.ts.map +0 -1
- package/dist/nextest-extraction.js +0 -303
- package/managed/raw/patches/ttsc@0.30.4.patch +0 -2255
- package/src/__tests__/cargo-closure-filesets.ts +0 -94
- package/src/__tests__/cargo-closure-fixture.ts +0 -113
- package/src/__tests__/counted-cargo-process.ts +0 -286
- package/src/__tests__/counted-cargo.ts +0 -713
- package/src/__tests__/directory-change.ts +0 -27
- package/src/__tests__/fixture-cargo-home.ts +0 -36
- package/src/__tests__/fixture-nx-env.ts +0 -193
- package/src/__tests__/owned-installation.ts +0 -13
- package/src/__tests__/past-tick.ts +0 -12
- package/src/__tests__/progress-clock.ts +0 -43
- package/src/__tests__/runtime-input.ts +0 -23
- package/src/bin/smoo-nx-bound-failures.test.ts +0 -127
- package/src/bin/smoo-nx-failures.ts +0 -4
- package/src/bin/smoo-nx-nextest-extract.ts +0 -44
- package/src/bounded-test-policy.test.ts +0 -1029
- package/src/build-state-output-policy.test.ts +0 -115
- package/src/bun-bootstrap.test.ts +0 -102
- package/src/bun-file-packages.test.ts +0 -47
- package/src/cargo-closure-filesets.test.ts +0 -63
- package/src/cargo-closure-input.property.test.ts +0 -50
- package/src/cargo-closure-input.test.ts +0 -506
- package/src/cargo-closure-key.test.ts +0 -240
- package/src/cargo-resolve-cache.test.ts +0 -1181
- package/src/cargo-source-hash.test.ts +0 -707
- package/src/cargo-workspace.test.ts +0 -615
- package/src/cross-check-policy.test.ts +0 -316
- package/src/disk-command-policy.test.ts +0 -61
- package/src/ensure-built-receipt.test.ts +0 -279
- package/src/ensure-built-witness.test.ts +0 -688
- package/src/ensure-built.test.ts +0 -1462
- package/src/executors/bounded-exec/cargo-progress-host.test.ts +0 -332
- package/src/executors/bounded-exec/cpu-pool.test.ts +0 -684
- package/src/executors/bounded-exec/cpu-tokens.test.ts +0 -519
- package/src/executors/bounded-exec/disk-lease.test.ts +0 -219
- package/src/executors/bounded-exec/executor-host.test.ts +0 -800
- package/src/executors/bounded-exec/executor.test.ts +0 -1819
- package/src/executors/bounded-exec/go-progress-host.test.ts +0 -171
- package/src/executors/bounded-exec/hang-diagnostics.test.ts +0 -291
- package/src/executors/bounded-exec/progress.test.ts +0 -139
- package/src/executors/bounded-exec/ram-temp-held.test.ts +0 -264
- package/src/executors/bounded-exec/ram-temp-host.test.ts +0 -635
- package/src/executors/bounded-exec/ram-temp.test.ts +0 -750
- package/src/executors/bounded-exec/run-cpu-pool.test.ts +0 -79
- package/src/executors/bounded-exec/runner-hook.test.ts +0 -193
- package/src/executors/bounded-exec/runner-lifecycle.test.ts +0 -82
- package/src/executors/bounded-exec/verdict.test.ts +0 -545
- package/src/executors/cargo-zigbuild/executor.test.ts +0 -129
- package/src/executors/clean-outputs/executor.test.ts +0 -20
- package/src/executors/typescript-emit/executor.test.ts +0 -83
- package/src/failure-summary.ts +0 -119
- package/src/generators/bounded-test-targets/generator.test.ts +0 -138
- package/src/generators/bun-test-tracing/generator.test.ts +0 -250
- package/src/generators/create-package/generator.test.ts +0 -190
- package/src/generators/make-public/generator.test.ts +0 -137
- package/src/graph-input-contract.test.ts +0 -379
- package/src/host-controller-wiring.test.ts +0 -31
- package/src/index.test.ts +0 -3319
- package/src/linked-snapshots.nx.test.ts +0 -254
- package/src/managed-files/forgejo-artifact.test.ts +0 -395
- package/src/managed-files/generator.test.ts +0 -243
- package/src/managed-files/github-host-cache-isolation.test.ts +0 -86
- package/src/managed-files/json-edit.test.ts +0 -216
- package/src/managed-files/managed-content.test.ts +0 -166
- package/src/managed-files/managed-format-json.test.ts +0 -308
- package/src/managed-files/repo-path.test.ts +0 -172
- package/src/managed-files/setup-devenv-free-disk.test.ts +0 -95
- package/src/managed-files/trace-db-artifact.test.ts +0 -7
- package/src/managed-files/tree-permissions.test.ts +0 -109
- package/src/managed-files/tree.test.ts +0 -123
- package/src/manifest-hash.test.ts +0 -219
- package/src/nextest-code-bound.test.ts +0 -161
- package/src/nextest-extraction.test.ts +0 -216
- package/src/nextest-extraction.ts +0 -371
- package/src/nextest-partitions.test.ts +0 -501
- package/src/nx-cache-bound.test.ts +0 -109
- package/src/nx-cache-restore-mtime.test.ts +0 -170
- package/src/nx-daemon-claim.test.ts +0 -279
- package/src/nx-daemon-idle-cpu.test.ts +0 -80
- package/src/nx-daemon-idle-policy.test.ts +0 -111
- package/src/nx-daemon-ignore-files.test.ts +0 -210
- package/src/nx-daemon-root-normalization.test.ts +0 -105
- package/src/nx-daemon-start-never.test.ts +0 -292
- package/src/nx-daemon-validity.test.ts +0 -1055
- package/src/nx-dot-input-policy.test.ts +0 -353
- package/src/nx-failure-life-cycles.test.ts +0 -207
- package/src/nx-files-archive-racy.test.ts +0 -97
- package/src/nx-foreign-workspace-env.test.ts +0 -329
- package/src/nx-incomplete-run-summary.test.ts +0 -70
- package/src/nx-plugin-load-errors.test.ts +0 -120
- package/src/nx-project-graph-errors.test.ts +0 -70
- package/src/nx-project-resolution-cache.test.ts +0 -176
- package/src/nx-raw-inputs.test.ts +0 -166
- package/src/nx-resident-graph-workers.test.ts +0 -112
- package/src/nx-run-information.test.ts +0 -118
- package/src/nx-skipped-task-exit.test.ts +0 -180
- package/src/nx-state-location.test.ts +0 -63
- package/src/nx-store-resolution.test.ts +0 -81
- package/src/nx-task-graph-cycles.test.ts +0 -148
- package/src/nx-task-output-lease.test.ts +0 -550
- package/src/nx-use-local.test.ts +0 -105
- package/src/owned-installation.test.ts +0 -105
- package/src/package-target-policy.test.ts +0 -1014
- package/src/producer-receipts.test.ts +0 -285
- package/src/release-config-policy.test.ts +0 -311
- package/src/runtime-input.test.ts +0 -393
- package/src/serial-group-wiring.test.ts +0 -326
- package/src/task-history-namespace.test.ts +0 -181
- package/src/task-results.test.ts +0 -228
- package/src/test-clock-policy.test.ts +0 -338
- package/src/test-program.test.ts +0 -303
- package/src/test-timings.test.ts +0 -240
- package/src/test-walk-policy.test.ts +0 -620
- package/src/testing.test.ts +0 -509
- package/src/typecheck-test-policy.test.ts +0 -1468
- package/src/typescript-resolution.test.ts +0 -76
- package/src/version-actions.test.ts +0 -80
- package/src/workspace-config-policy.test.ts +0 -737
|
@@ -1,707 +0,0 @@
|
|
|
1
|
-
import { expect, it } from 'bun:test';
|
|
2
|
-
import { execFileSync } from 'node:child_process';
|
|
3
|
-
import { createHash } from 'node:crypto';
|
|
4
|
-
import { statSync } from 'node:fs';
|
|
5
|
-
import {
|
|
6
|
-
chmod,
|
|
7
|
-
mkdir,
|
|
8
|
-
mkdtemp,
|
|
9
|
-
readFile,
|
|
10
|
-
realpath,
|
|
11
|
-
rename,
|
|
12
|
-
rm,
|
|
13
|
-
stat,
|
|
14
|
-
symlink,
|
|
15
|
-
utimes,
|
|
16
|
-
writeFile,
|
|
17
|
-
} from 'node:fs/promises';
|
|
18
|
-
import { homedir, tmpdir } from 'node:os';
|
|
19
|
-
import { dirname, join, relative } from 'node:path';
|
|
20
|
-
import { useFixtureCargoHome } from './__tests__/fixture-cargo-home.js';
|
|
21
|
-
import { runtimeInputValue } from './__tests__/runtime-input.js';
|
|
22
|
-
import { CARGO_ANCESTOR_INPUTS, compiledInFiles, hashCargoPathInputs, readCargoResolve } from './cargo-source-hash.js';
|
|
23
|
-
|
|
24
|
-
useFixtureCargoHome();
|
|
25
|
-
|
|
26
|
-
it.each(['app', '.'])('invalidates transitive and inherited Cargo inputs with Nx rooted at %s', async (nxDirectory) => {
|
|
27
|
-
const root = await mkdtemp(join(tmpdir(), 'cargo-hash-'));
|
|
28
|
-
const app = join(root, 'app');
|
|
29
|
-
const manifest = join(app, 'Cargo.toml');
|
|
30
|
-
const nxRoot = join(root, nxDirectory);
|
|
31
|
-
async function put(path: string, text: string): Promise<void> {
|
|
32
|
-
const file = join(root, path);
|
|
33
|
-
await mkdir(dirname(file), { recursive: true });
|
|
34
|
-
await writeFile(file, text);
|
|
35
|
-
}
|
|
36
|
-
try {
|
|
37
|
-
await put(
|
|
38
|
-
'app/Cargo.toml',
|
|
39
|
-
'[package]\nname="app"\nversion="0.1.0"\nedition="2021"\n[dependencies]\nbridge={path="../external/bridge"}\n[workspace]\n',
|
|
40
|
-
);
|
|
41
|
-
await put('app/src/lib.rs', 'pub fn run() {}\n');
|
|
42
|
-
await put(
|
|
43
|
-
'external/Cargo.toml',
|
|
44
|
-
'[workspace]\nmembers=["bridge","leaf"]\nresolver="2"\n[workspace.package]\nedition="2021"\n',
|
|
45
|
-
);
|
|
46
|
-
await put(
|
|
47
|
-
'external/bridge/Cargo.toml',
|
|
48
|
-
'[package]\nname="bridge"\nversion="0.1.0"\nedition.workspace=true\n[dependencies]\nleaf={path="../leaf"}\n',
|
|
49
|
-
);
|
|
50
|
-
await put('external/bridge/src/lib.rs', 'pub fn bridge() {}\n');
|
|
51
|
-
await put('external/leaf/Cargo.toml', '[package]\nname="leaf"\nversion="0.1.0"\nedition.workspace=true\n');
|
|
52
|
-
await put('external/leaf/src/lib.rs', 'pub fn leaf() -> u8 { 1 }\n');
|
|
53
|
-
execFileSync('cargo', ['generate-lockfile', '--offline', '--manifest-path', manifest], { stdio: 'pipe' });
|
|
54
|
-
const initial = await hashCargoPathInputs(manifest, nxRoot);
|
|
55
|
-
await put('external/leaf/src/lib.rs', 'pub fn leaf() -> u8 { 2 }\n');
|
|
56
|
-
const sourceChanged = await hashCargoPathInputs(manifest, nxRoot);
|
|
57
|
-
expect(sourceChanged).not.toBe(initial);
|
|
58
|
-
await put(
|
|
59
|
-
'external/Cargo.toml',
|
|
60
|
-
'[workspace]\nmembers=["bridge","leaf"]\nresolver="2"\n[workspace.package]\nedition="2024"\n',
|
|
61
|
-
);
|
|
62
|
-
const inheritedChanged = await hashCargoPathInputs(manifest, nxRoot);
|
|
63
|
-
expect(inheritedChanged).not.toBe(sourceChanged);
|
|
64
|
-
await put('external/leaf/target/noise.rs', 'uncompiled build output');
|
|
65
|
-
expect(await hashCargoPathInputs(manifest, nxRoot)).toBe(inheritedChanged);
|
|
66
|
-
} finally {
|
|
67
|
-
await rm(root, { recursive: true, force: true });
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it('identical external inputs hash equally at different checkout depths, with bytes and file names still significant', async () => {
|
|
72
|
-
const root = await realpath(await mkdtemp(join(tmpdir(), 'cargo-hash-portable-')));
|
|
73
|
-
const shared = join(root, 'shared');
|
|
74
|
-
const roots: readonly [string, string] = [join(root, 'main'), join(root, 'sheds/deep/unit')];
|
|
75
|
-
try {
|
|
76
|
-
await mkdir(join(shared, 'src'), { recursive: true });
|
|
77
|
-
await writeFile(
|
|
78
|
-
join(shared, 'Cargo.toml'),
|
|
79
|
-
'[package]\nname="shared"\nversion="0.1.0"\nedition="2021"\n[workspace]\n',
|
|
80
|
-
);
|
|
81
|
-
const include = 'const DATA: &str = include_str!(' + JSON.stringify(join(root, 'data.txt')) + ');\n';
|
|
82
|
-
await writeFile(join(shared, 'src/lib.rs'), 'pub fn value() -> u8 { 7 }\n' + include);
|
|
83
|
-
await writeFile(join(shared, 'src/extra.rs'), 'pub const EXTRA: u8 = 9;\n');
|
|
84
|
-
await writeFile(join(root, 'data.txt'), 'shared-data-one');
|
|
85
|
-
const manifest =
|
|
86
|
-
'[package]\nname="consumer"\nversion="0.1.0"\nedition="2021"\n[dependencies]\nshared={path=' +
|
|
87
|
-
JSON.stringify(shared) +
|
|
88
|
-
'}\n[workspace]\n';
|
|
89
|
-
for (const workspace of roots) {
|
|
90
|
-
await mkdir(join(workspace, 'src'), { recursive: true });
|
|
91
|
-
await writeFile(join(workspace, 'Cargo.toml'), manifest);
|
|
92
|
-
await writeFile(join(workspace, 'src/lib.rs'), 'pub fn value() -> u8 { shared::value() }\n' + include);
|
|
93
|
-
await symlink(join(shared, 'src'), join(workspace, 'linked-src'), 'dir');
|
|
94
|
-
execFileSync('cargo', ['generate-lockfile', '--offline', '--manifest-path', join(workspace, 'Cargo.toml')], {
|
|
95
|
-
stdio: 'pipe',
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
expect(await readFile(join(roots[0], 'Cargo.lock'), 'utf8')).toBe(
|
|
99
|
-
await readFile(join(roots[1], 'Cargo.lock'), 'utf8'),
|
|
100
|
-
);
|
|
101
|
-
const before: string[] = [];
|
|
102
|
-
const after: string[] = [];
|
|
103
|
-
for (const includeWorkspace of [false, true]) {
|
|
104
|
-
const hashes = await Promise.all(
|
|
105
|
-
roots.map((workspace) => hashCargoPathInputs(join(workspace, 'Cargo.toml'), workspace, { includeWorkspace })),
|
|
106
|
-
);
|
|
107
|
-
expect(hashes[0]).toBeDefined();
|
|
108
|
-
expect(hashes[1]).toBe(hashes[0]);
|
|
109
|
-
before.push(hashes.join(','));
|
|
110
|
-
}
|
|
111
|
-
await writeFile(join(root, 'data.txt'), 'shared-data-two');
|
|
112
|
-
for (const [index, includeWorkspace] of [false, true].entries()) {
|
|
113
|
-
const hashes = await Promise.all(
|
|
114
|
-
roots.map((workspace) => hashCargoPathInputs(join(workspace, 'Cargo.toml'), workspace, { includeWorkspace })),
|
|
115
|
-
);
|
|
116
|
-
expect(hashes[1]).toBe(hashes[0]);
|
|
117
|
-
expect(hashes.join(',')).not.toBe(before[index]);
|
|
118
|
-
after.push(hashes.join(','));
|
|
119
|
-
}
|
|
120
|
-
await rename(join(shared, 'src/extra.rs'), join(shared, 'src/renamed.rs'));
|
|
121
|
-
const renamed = await Promise.all(
|
|
122
|
-
roots.map((workspace) => hashCargoPathInputs(join(workspace, 'Cargo.toml'), workspace)),
|
|
123
|
-
);
|
|
124
|
-
expect(renamed[1]).toBe(renamed[0]);
|
|
125
|
-
expect(renamed.join(',')).not.toBe(after[0]);
|
|
126
|
-
} finally {
|
|
127
|
-
await rm(root, { recursive: true, force: true });
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it('the runtime input is byte-identical under cargo lock contention: nothing on stderr', async () => {
|
|
132
|
-
// Nx hashes a runtime input's stdout and stderr together, and hashes once per
|
|
133
|
-
// distinct task env, so the bin runs many times at once at the start of a
|
|
134
|
-
// run. Cargo reports package-cache lock contention on stderr; a private
|
|
135
|
-
// CARGO_HOME makes that contention real here.
|
|
136
|
-
const root = await mkdtemp(join(tmpdir(), 'cargo-hash-'));
|
|
137
|
-
const manifest = join(root, 'Cargo.toml');
|
|
138
|
-
try {
|
|
139
|
-
await mkdir(join(root, 'src'), { recursive: true });
|
|
140
|
-
await writeFile(manifest, '[package]\nname="app"\nversion="0.1.0"\nedition="2021"\n[workspace]\n');
|
|
141
|
-
await writeFile(join(root, 'src', 'lib.rs'), 'pub fn run() {}\n');
|
|
142
|
-
// A runtime input inherits the Nx process's environment untouched. Node
|
|
143
|
-
// warns with its own pid when FORCE_COLOR and NO_COLOR are both set.
|
|
144
|
-
// The declared wrapper excludes successful diagnostics from the value;
|
|
145
|
-
// all eight genuinely contended runs must still succeed and hash equally.
|
|
146
|
-
const env = { ...process.env, CARGO_HOME: join(root, '.cargo-home'), FORCE_COLOR: 'true', NO_COLOR: '1' };
|
|
147
|
-
execFileSync('cargo', ['generate-lockfile', '--offline', '--manifest-path', manifest], { stdio: 'pipe', env });
|
|
148
|
-
// Invoke the declared runtime-input owner, not the raw bin: successful stderr is not a hash value.
|
|
149
|
-
const bin = join(import.meta.dir, '..', 'dist', 'bin', 'smoo-nx-cargo-hash.js');
|
|
150
|
-
const runtimeInput = join(import.meta.dir, '..', 'runtime-input.sh');
|
|
151
|
-
const runs = await Promise.all(
|
|
152
|
-
Array.from({ length: 8 }, async () => {
|
|
153
|
-
const proc = Bun.spawn(['sh', runtimeInput, 'node', bin, manifest], {
|
|
154
|
-
cwd: root,
|
|
155
|
-
env,
|
|
156
|
-
stdout: 'pipe',
|
|
157
|
-
stderr: 'pipe',
|
|
158
|
-
});
|
|
159
|
-
const [stdout, stderr, exitCode] = await Promise.all([
|
|
160
|
-
new Response(proc.stdout).text(),
|
|
161
|
-
new Response(proc.stderr).text(),
|
|
162
|
-
proc.exited,
|
|
163
|
-
]);
|
|
164
|
-
return { stdout, stderr, exitCode };
|
|
165
|
-
}),
|
|
166
|
-
);
|
|
167
|
-
for (const run of runs) {
|
|
168
|
-
expect(run.exitCode).toBe(0);
|
|
169
|
-
expect(run.stderr).toBe('');
|
|
170
|
-
}
|
|
171
|
-
expect(new Set(runs.map((run) => run.stdout)).size).toBe(1);
|
|
172
|
-
} finally {
|
|
173
|
-
await rm(root, { recursive: true, force: true });
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
it('failed runtime inputs have the same key at different checkout paths and still name the cause', async () => {
|
|
178
|
-
const root = await mkdtemp(join(tmpdir(), 'cargo-hash-refusal-'));
|
|
179
|
-
try {
|
|
180
|
-
const bin = join(import.meta.dir, '../dist/bin/smoo-nx-cargo-hash.js');
|
|
181
|
-
for (const directory of ['first', 'second']) {
|
|
182
|
-
const workspace = join(root, directory);
|
|
183
|
-
await mkdir(workspace);
|
|
184
|
-
await writeFile(join(workspace, 'Cargo.toml'), '[package\n');
|
|
185
|
-
const child = Bun.spawn(['node', bin, 'Cargo.toml'], {
|
|
186
|
-
cwd: workspace,
|
|
187
|
-
env: process.env,
|
|
188
|
-
stdout: 'pipe',
|
|
189
|
-
stderr: 'pipe',
|
|
190
|
-
});
|
|
191
|
-
const [exitCode, stdout, stderr] = await Promise.all([
|
|
192
|
-
child.exited,
|
|
193
|
-
new Response(child.stdout).text(),
|
|
194
|
-
new Response(child.stderr).text(),
|
|
195
|
-
]);
|
|
196
|
-
expect({ exitCode, stdout }).toEqual({ exitCode: 1, stdout: 'cargo-input-unavailable\n' });
|
|
197
|
-
// The verdict is the key; stderr must retain Cargo's cause without the
|
|
198
|
-
// checkout path, but may also contain an unrelated native-loader warning.
|
|
199
|
-
expect(stderr).toContain('unclosed table');
|
|
200
|
-
expect(stderr).not.toContain(workspace);
|
|
201
|
-
expect(stderr).not.toContain(await realpath(workspace));
|
|
202
|
-
// The cause is not the verdict: the real producer still refuses the
|
|
203
|
-
// manifest with Cargo's operational cause.
|
|
204
|
-
const producer = Bun.spawn(['cargo', 'build', '--locked', '--offline'], {
|
|
205
|
-
cwd: workspace,
|
|
206
|
-
env: process.env,
|
|
207
|
-
stdout: 'pipe',
|
|
208
|
-
stderr: 'pipe',
|
|
209
|
-
});
|
|
210
|
-
const [producerCode, producerError] = await Promise.all([
|
|
211
|
-
producer.exited,
|
|
212
|
-
new Response(producer.stderr).text(),
|
|
213
|
-
new Response(producer.stdout).text(),
|
|
214
|
-
]);
|
|
215
|
-
expect(producerCode).not.toBe(0);
|
|
216
|
-
expect(producerError).toContain('Cargo.toml');
|
|
217
|
-
}
|
|
218
|
-
} finally {
|
|
219
|
-
await rm(root, { recursive: true, force: true });
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
async function workspaceCargoFixture(root: string) {
|
|
224
|
-
const workspace = join(root, 'workspace');
|
|
225
|
-
const manifest = join(workspace, 'Cargo.toml');
|
|
226
|
-
const sources = {
|
|
227
|
-
'workspace/Cargo.toml':
|
|
228
|
-
'[workspace]\nmembers=["packages/app","crates/bridge","crates/leaf","crates/unrelated"]\nresolver="2"\n',
|
|
229
|
-
'workspace/packages/app/Cargo.toml':
|
|
230
|
-
'[package]\nname="app"\nversion="0.1.0"\nedition="2021"\n[dependencies]\nbridge={path="../../crates/bridge"}\n',
|
|
231
|
-
'workspace/packages/app/src/main.rs': 'fn main() { println!("{}", bridge::answer()); }\n',
|
|
232
|
-
'workspace/crates/bridge/Cargo.toml':
|
|
233
|
-
'[package]\nname="bridge"\nversion="0.1.0"\nedition="2021"\n[dependencies]\nleaf={path="../leaf"}\nexternal={path="../../../external"}\n',
|
|
234
|
-
'workspace/crates/bridge/src/lib.rs': 'pub fn answer() -> u8 { leaf::answer() + external::answer() }\n',
|
|
235
|
-
'workspace/crates/leaf/Cargo.toml': '[package]\nname="leaf"\nversion="0.1.0"\nedition="2021"\n',
|
|
236
|
-
'workspace/crates/leaf/src/lib.rs': 'pub fn answer() -> u8 { 1 }\n',
|
|
237
|
-
'workspace/crates/unrelated/Cargo.toml': '[package]\nname="unrelated"\nversion="0.1.0"\nedition="2021"\n',
|
|
238
|
-
'workspace/crates/unrelated/src/lib.rs': 'pub fn unrelated() -> u8 { 3 }\n',
|
|
239
|
-
'external/Cargo.toml': '[package]\nname="external"\nversion="0.1.0"\nedition="2021"\n[workspace]\n',
|
|
240
|
-
'external/src/lib.rs': 'pub fn answer() -> u8 { 10 }\n',
|
|
241
|
-
};
|
|
242
|
-
for (const [path, text] of Object.entries(sources)) {
|
|
243
|
-
const file = join(root, path);
|
|
244
|
-
await mkdir(dirname(file), { recursive: true });
|
|
245
|
-
await writeFile(file, text);
|
|
246
|
-
}
|
|
247
|
-
execFileSync('cargo', ['generate-lockfile', '--offline', '--manifest-path', manifest], { stdio: 'pipe' });
|
|
248
|
-
return { workspace, manifest, leafSource: join(workspace, 'crates/leaf/src/lib.rs') };
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
it('include-workspace hashes in-workspace transitive source edits without changing the external-only contract', async () => {
|
|
252
|
-
const root = await mkdtemp(join(tmpdir(), 'cargo-hash-workspace-'));
|
|
253
|
-
try {
|
|
254
|
-
const { workspace, manifest, leafSource } = await workspaceCargoFixture(root);
|
|
255
|
-
const external = await hashCargoPathInputs(manifest, workspace);
|
|
256
|
-
const included = await hashCargoPathInputs(manifest, workspace, { includeWorkspace: true });
|
|
257
|
-
expect(await hashCargoPathInputs(manifest, workspace, { includeWorkspace: true })).toBe(included);
|
|
258
|
-
|
|
259
|
-
await writeFile(leafSource, 'pub fn answer() -> u8 { 2 }\n');
|
|
260
|
-
expect(await hashCargoPathInputs(manifest, workspace)).toBe(external);
|
|
261
|
-
const changed = await hashCargoPathInputs(manifest, workspace, { includeWorkspace: true });
|
|
262
|
-
expect(changed).not.toBe(included);
|
|
263
|
-
expect(await hashCargoPathInputs(manifest, workspace, { includeWorkspace: true })).toBe(changed);
|
|
264
|
-
|
|
265
|
-
await writeFile(join(root, 'external/src/lib.rs'), 'pub fn answer() -> u8 { 20 }\n');
|
|
266
|
-
expect(await hashCargoPathInputs(manifest, workspace)).not.toBe(external);
|
|
267
|
-
expect(await hashCargoPathInputs(manifest, workspace, { includeWorkspace: true })).not.toBe(changed);
|
|
268
|
-
} finally {
|
|
269
|
-
await rm(root, { recursive: true, force: true });
|
|
270
|
-
}
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
it.each(['external', 'workspace/node_modules/external'])(
|
|
274
|
-
'follows same-size same-mtime dependency edits in %s and hashes the newly reached source bytes',
|
|
275
|
-
async (externalDirectory) => {
|
|
276
|
-
const root = await realpath(await mkdtemp(join(tmpdir(), 'cargo-hash-boundary-')));
|
|
277
|
-
const workspace = join(root, 'workspace');
|
|
278
|
-
const manifest = join(workspace, 'Cargo.toml');
|
|
279
|
-
const external = join(root, externalDirectory);
|
|
280
|
-
const externalManifest = join(external, 'Cargo.toml');
|
|
281
|
-
async function put(file: string, text: string): Promise<void> {
|
|
282
|
-
await mkdir(dirname(file), { recursive: true });
|
|
283
|
-
await writeFile(file, text);
|
|
284
|
-
}
|
|
285
|
-
const dependencyManifest = (name: string) =>
|
|
286
|
-
'[package]\nname="external"\nversion="0.1.0"\nedition="2021"\n[workspace]\n' +
|
|
287
|
-
`[dependencies]\nside={path=${JSON.stringify(relative(external, join(root, name)))}}\n`;
|
|
288
|
-
const sideManifest = '[package]\nname="side"\nversion="0.1.0"\nedition="2021"\n[workspace]\n';
|
|
289
|
-
const timestamp = new Date(1_700_000_000_000);
|
|
290
|
-
try {
|
|
291
|
-
// A nested installed workspace must not be auto-enrolled as a member of this one.
|
|
292
|
-
await put(
|
|
293
|
-
manifest,
|
|
294
|
-
'[package]\nname="app"\nversion="0.1.0"\nedition="2021"\n[workspace]\nexclude=["node_modules/external"]\n' +
|
|
295
|
-
`[dependencies]\nexternal={path=${JSON.stringify(relative(workspace, external))}}\n`,
|
|
296
|
-
);
|
|
297
|
-
await put(join(workspace, 'src/lib.rs'), 'pub fn app() {}\n');
|
|
298
|
-
await put(externalManifest, dependencyManifest('left'));
|
|
299
|
-
await put(join(external, 'src/lib.rs'), 'pub fn external() {}\n');
|
|
300
|
-
for (const side of ['left', 'rght']) {
|
|
301
|
-
await put(join(root, side, 'Cargo.toml'), sideManifest);
|
|
302
|
-
await put(join(root, side, 'src/lib.rs'), 'pub fn side() -> u8 { 1 }\n');
|
|
303
|
-
}
|
|
304
|
-
execFileSync('git', ['init', '--quiet', workspace], { stdio: 'pipe' });
|
|
305
|
-
await put(join(workspace, '.gitignore'), 'node_modules/\n.nx/\n');
|
|
306
|
-
execFileSync('cargo', ['generate-lockfile', '--offline', '--manifest-path', manifest], { stdio: 'pipe' });
|
|
307
|
-
await utimes(externalManifest, timestamp, timestamp);
|
|
308
|
-
const before = await stat(externalManifest);
|
|
309
|
-
const lock = await readFile(join(workspace, 'Cargo.lock'), 'utf8');
|
|
310
|
-
const initialResolve = await readCargoResolve(manifest, workspace);
|
|
311
|
-
expect(initialResolve.local.map((pkg) => pkg.manifest)).toContain(join(root, 'left/Cargo.toml'));
|
|
312
|
-
const initial = await hashCargoPathInputs(manifest, workspace);
|
|
313
|
-
|
|
314
|
-
// Both packages have the same name/version, so the locked graph stays
|
|
315
|
-
// valid. Only the dependency manifest's bytes identify its new location.
|
|
316
|
-
await writeFile(externalManifest, dependencyManifest('rght'));
|
|
317
|
-
await utimes(externalManifest, timestamp, timestamp);
|
|
318
|
-
const after = await stat(externalManifest);
|
|
319
|
-
expect(after.size).toBe(before.size);
|
|
320
|
-
expect(after.mtimeMs).toBe(before.mtimeMs);
|
|
321
|
-
const changedResolve = await readCargoResolve(manifest, workspace);
|
|
322
|
-
const manifests = changedResolve.local.map((pkg) => pkg.manifest);
|
|
323
|
-
expect(manifests).toContain(join(root, 'rght/Cargo.toml'));
|
|
324
|
-
expect(manifests).not.toContain(join(root, 'left/Cargo.toml'));
|
|
325
|
-
expect(await readFile(join(workspace, 'Cargo.lock'), 'utf8')).toBe(lock);
|
|
326
|
-
const changed = await hashCargoPathInputs(manifest, workspace);
|
|
327
|
-
expect(changed).not.toBe(initial);
|
|
328
|
-
|
|
329
|
-
await writeFile(join(root, 'left/src/lib.rs'), 'pub fn side() -> u8 { 2 }\n');
|
|
330
|
-
expect(await hashCargoPathInputs(manifest, workspace)).toBe(changed);
|
|
331
|
-
const source = join(root, 'rght/src/lib.rs');
|
|
332
|
-
const sourceBefore = await stat(source);
|
|
333
|
-
await writeFile(source, 'pub fn side() -> u8 { 2 }\n');
|
|
334
|
-
await utimes(source, sourceBefore.atime, sourceBefore.mtime);
|
|
335
|
-
const sourceChanged = await hashCargoPathInputs(manifest, workspace);
|
|
336
|
-
expect(sourceChanged).not.toBe(changed);
|
|
337
|
-
|
|
338
|
-
await rm(join(root, 'rght/Cargo.toml'));
|
|
339
|
-
await expect(hashCargoPathInputs(manifest, workspace)).rejects.toThrow('Locked offline Cargo resolution failed');
|
|
340
|
-
await put(join(root, 'rght/Cargo.toml'), sideManifest);
|
|
341
|
-
expect(await hashCargoPathInputs(manifest, workspace)).toBe(sourceChanged);
|
|
342
|
-
} finally {
|
|
343
|
-
await rm(root, { recursive: true, force: true });
|
|
344
|
-
}
|
|
345
|
-
},
|
|
346
|
-
);
|
|
347
|
-
|
|
348
|
-
it('include-workspace CLI accepts an optional manifest and refuses unsupported arguments', async () => {
|
|
349
|
-
const root = await mkdtemp(join(tmpdir(), 'cargo-hash-cli-'));
|
|
350
|
-
try {
|
|
351
|
-
const { workspace, leafSource } = await workspaceCargoFixture(root);
|
|
352
|
-
const bin = join(import.meta.dir, '../dist/bin/smoo-nx-cargo-hash.js');
|
|
353
|
-
const run = async (args: string[]) => {
|
|
354
|
-
// Bun.spawn's default environment is the one this process started with,
|
|
355
|
-
// not process.env, so pass it: the file's own CARGO_HOME must reach the CLI.
|
|
356
|
-
const child = Bun.spawn(['bun', bin, ...args], {
|
|
357
|
-
cwd: workspace,
|
|
358
|
-
env: process.env,
|
|
359
|
-
stdout: 'pipe',
|
|
360
|
-
stderr: 'pipe',
|
|
361
|
-
});
|
|
362
|
-
const [exitCode, stdout, stderr] = await Promise.all([
|
|
363
|
-
child.exited,
|
|
364
|
-
new Response(child.stdout).text(),
|
|
365
|
-
new Response(child.stderr).text(),
|
|
366
|
-
]);
|
|
367
|
-
return { exitCode, stdout, stderr };
|
|
368
|
-
};
|
|
369
|
-
const external = await run(['Cargo.toml']);
|
|
370
|
-
expect(external.exitCode, external.stderr).toBe(0);
|
|
371
|
-
const included = await run(['--include-workspace']);
|
|
372
|
-
expect(included.exitCode, included.stderr).toBe(0);
|
|
373
|
-
expect(included.stderr).toBe('');
|
|
374
|
-
expect(await run(['--include-workspace', 'Cargo.toml'])).toEqual(included);
|
|
375
|
-
|
|
376
|
-
await writeFile(leafSource, 'pub fn answer() -> u8 { 2 }\n');
|
|
377
|
-
expect(await run([])).toEqual(external);
|
|
378
|
-
const changed = await run(['--include-workspace', 'Cargo.toml']);
|
|
379
|
-
expect(changed.exitCode, changed.stderr).toBe(0);
|
|
380
|
-
expect(changed.stderr).toBe('');
|
|
381
|
-
expect(changed.stdout).not.toBe(included.stdout);
|
|
382
|
-
expect(await run(['--include-workspace'])).toEqual(changed);
|
|
383
|
-
|
|
384
|
-
const closure = await run(['--include-workspace', '--closure', 'crates/leaf', 'Cargo.toml']);
|
|
385
|
-
expect(closure.exitCode, closure.stderr).toBe(0);
|
|
386
|
-
expect(closure.stderr).toBe('');
|
|
387
|
-
expect(closure.stdout).not.toBe(changed.stdout);
|
|
388
|
-
expect(await run(['--closure', 'crates/leaf', '--include-workspace'])).toEqual(closure);
|
|
389
|
-
|
|
390
|
-
for (const args of [
|
|
391
|
-
['--unknown'],
|
|
392
|
-
['--include-workspace', '--unknown'],
|
|
393
|
-
['Cargo.toml', '--include-workspace'],
|
|
394
|
-
['--include-workspace', 'Cargo.toml', 'extra'],
|
|
395
|
-
['--include-workspace', '--include-workspace'],
|
|
396
|
-
['--closure'],
|
|
397
|
-
['--closure', '--include-workspace'],
|
|
398
|
-
['--closure', 'crates/leaf', '--closure', 'packages/app'],
|
|
399
|
-
]) {
|
|
400
|
-
const refused = await run(args);
|
|
401
|
-
expect(refused.exitCode, refused.stderr).toBe(2);
|
|
402
|
-
expect(refused.stdout).toBe('cargo-input-invalid-arguments\n');
|
|
403
|
-
expect(refused.stderr).toBe('');
|
|
404
|
-
}
|
|
405
|
-
} finally {
|
|
406
|
-
await rm(root, { recursive: true, force: true });
|
|
407
|
-
}
|
|
408
|
-
});
|
|
409
|
-
|
|
410
|
-
it('closure hashes the dependency closure of one directory and ignores unrelated workspace members', async () => {
|
|
411
|
-
const root = await mkdtemp(join(tmpdir(), 'cargo-hash-closure-'));
|
|
412
|
-
try {
|
|
413
|
-
const { workspace, manifest, leafSource } = await workspaceCargoFixture(root);
|
|
414
|
-
const app = { includeWorkspace: true, closure: join(workspace, 'packages/app') };
|
|
415
|
-
const leaf = { includeWorkspace: true, closure: join(workspace, 'crates/leaf') };
|
|
416
|
-
const initial = await hashCargoPathInputs(manifest, workspace, app);
|
|
417
|
-
const leafOnly = await hashCargoPathInputs(manifest, workspace, leaf);
|
|
418
|
-
const whole = await hashCargoPathInputs(manifest, workspace, { includeWorkspace: true });
|
|
419
|
-
|
|
420
|
-
await writeFile(join(workspace, 'crates/unrelated/src/lib.rs'), 'pub fn unrelated() -> u8 { 4 }\n');
|
|
421
|
-
expect(await hashCargoPathInputs(manifest, workspace, app)).toBe(initial);
|
|
422
|
-
expect(await hashCargoPathInputs(manifest, workspace, { includeWorkspace: true })).not.toBe(whole);
|
|
423
|
-
|
|
424
|
-
await writeFile(join(workspace, 'crates/bridge/src/lib.rs'), 'pub fn answer() -> u8 { leaf::answer() }\n');
|
|
425
|
-
const bridgeChanged = await hashCargoPathInputs(manifest, workspace, app);
|
|
426
|
-
expect(bridgeChanged).not.toBe(initial);
|
|
427
|
-
expect(await hashCargoPathInputs(manifest, workspace, leaf)).toBe(leafOnly);
|
|
428
|
-
|
|
429
|
-
await writeFile(leafSource, 'pub fn answer() -> u8 { 2 }\n');
|
|
430
|
-
expect(await hashCargoPathInputs(manifest, workspace, app)).not.toBe(bridgeChanged);
|
|
431
|
-
expect(await hashCargoPathInputs(manifest, workspace, leaf)).not.toBe(leafOnly);
|
|
432
|
-
|
|
433
|
-
// The external package is reached through bridge, so the app closure sees it and the leaf closure does not.
|
|
434
|
-
const appBefore = await hashCargoPathInputs(manifest, workspace, app);
|
|
435
|
-
const leafBefore = await hashCargoPathInputs(manifest, workspace, leaf);
|
|
436
|
-
await writeFile(join(root, 'external/src/lib.rs'), 'pub fn answer() -> u8 { 20 }\n');
|
|
437
|
-
expect(await hashCargoPathInputs(manifest, workspace, app)).not.toBe(appBefore);
|
|
438
|
-
expect(await hashCargoPathInputs(manifest, workspace, leaf)).toBe(leafBefore);
|
|
439
|
-
|
|
440
|
-
await mkdir(join(workspace, 'docs'), { recursive: true });
|
|
441
|
-
await expect(
|
|
442
|
-
hashCargoPathInputs(manifest, workspace, { includeWorkspace: true, closure: join(workspace, 'docs') }),
|
|
443
|
-
).rejects.toThrow('no local Cargo package lies under');
|
|
444
|
-
} finally {
|
|
445
|
-
await rm(root, { recursive: true, force: true });
|
|
446
|
-
}
|
|
447
|
-
});
|
|
448
|
-
|
|
449
|
-
it('leaves gitignored sources beneath a package out of the digest but keeps an ignored package root', async () => {
|
|
450
|
-
const root = await mkdtemp(join(tmpdir(), 'cargo-hash-ignored-'));
|
|
451
|
-
try {
|
|
452
|
-
const { workspace, manifest } = await workspaceCargoFixture(root);
|
|
453
|
-
execFileSync('git', ['init', '--quiet', workspace], { stdio: 'pipe' });
|
|
454
|
-
await writeFile(join(workspace, '.gitignore'), 'target/\ngenerated.rs\ncrates/leaf/\n');
|
|
455
|
-
const options = { includeWorkspace: true };
|
|
456
|
-
const initial = await hashCargoPathInputs(manifest, workspace, options);
|
|
457
|
-
|
|
458
|
-
// A source a producer generates later: a fresh tree and a built one hash alike.
|
|
459
|
-
await writeFile(join(workspace, 'crates/bridge/src/generated.rs'), 'pub const GENERATED: u8 = 1;\n');
|
|
460
|
-
expect(await hashCargoPathInputs(manifest, workspace, options)).toBe(initial);
|
|
461
|
-
|
|
462
|
-
// An untracked source nobody ignores is an edit like any other.
|
|
463
|
-
await writeFile(join(workspace, 'crates/bridge/src/extra.rs'), 'pub const EXTRA: u8 = 1;\n');
|
|
464
|
-
const untracked = await hashCargoPathInputs(manifest, workspace, options);
|
|
465
|
-
expect(untracked).not.toBe(initial);
|
|
466
|
-
|
|
467
|
-
// A package whose own directory is ignored still hashes its sources.
|
|
468
|
-
await writeFile(join(workspace, 'crates/leaf/src/lib.rs'), 'pub fn answer() -> u8 { 3 }\n');
|
|
469
|
-
expect(await hashCargoPathInputs(manifest, workspace, options)).not.toBe(untracked);
|
|
470
|
-
} finally {
|
|
471
|
-
await rm(root, { recursive: true, force: true });
|
|
472
|
-
}
|
|
473
|
-
});
|
|
474
|
-
|
|
475
|
-
it('hashes a Cargo workspace that lives inside a directory its enclosing repository ignores', async () => {
|
|
476
|
-
// A sandbox's TMPDIR, or a checkout under another repository's ignored scratch directory: every
|
|
477
|
-
// package sits beneath one ignored ancestor, where `git ls-files` refuses the pathspec outright.
|
|
478
|
-
const repository = await mkdtemp(join(tmpdir(), 'cargo-hash-enclosed-'));
|
|
479
|
-
try {
|
|
480
|
-
execFileSync('git', ['init', '--quiet', repository], { stdio: 'pipe' });
|
|
481
|
-
await writeFile(join(repository, '.gitignore'), 'scratch/\n');
|
|
482
|
-
const { workspace, manifest, leafSource } = await workspaceCargoFixture(join(repository, 'scratch/deep'));
|
|
483
|
-
const options = { includeWorkspace: true };
|
|
484
|
-
const initial = await hashCargoPathInputs(manifest, workspace, options);
|
|
485
|
-
await writeFile(leafSource, 'pub fn answer() -> u8 { 2 }\n');
|
|
486
|
-
expect(await hashCargoPathInputs(manifest, workspace, options)).not.toBe(initial);
|
|
487
|
-
} finally {
|
|
488
|
-
await rm(repository, { recursive: true, force: true });
|
|
489
|
-
}
|
|
490
|
-
});
|
|
491
|
-
|
|
492
|
-
it('the runtime input reads no git configuration from the operator home', async () => {
|
|
493
|
-
// A host client's runtime input runs in a workspace's sandboxed daemon with the host's HOME
|
|
494
|
-
// (cowshed 04_sandbox.md). Git must not read that home: the sandbox denies its global
|
|
495
|
-
// configuration, and git dies on any error but a missing file; its global ignore file would
|
|
496
|
-
// decide which sources the key covers.
|
|
497
|
-
const root = await mkdtemp(join(tmpdir(), 'cargo-hash-operator-git-'));
|
|
498
|
-
try {
|
|
499
|
-
const { workspace } = await workspaceCargoFixture(root);
|
|
500
|
-
execFileSync('git', ['init', '--quiet', workspace], { stdio: 'pipe' });
|
|
501
|
-
const bin = join(import.meta.dir, '../dist/bin/smoo-nx-cargo-hash.js');
|
|
502
|
-
const run = async (home: string) => {
|
|
503
|
-
// The operator's environment, as a host client sends it: its HOME, and none of the
|
|
504
|
-
// git isolation a sandboxed job would carry.
|
|
505
|
-
const env: Record<string, string | undefined> = { ...process.env, HOME: home };
|
|
506
|
-
for (const name of [
|
|
507
|
-
'GIT_CONFIG_GLOBAL',
|
|
508
|
-
'GIT_CONFIG_NOSYSTEM',
|
|
509
|
-
'GIT_CONFIG_SYSTEM',
|
|
510
|
-
'GIT_CONFIG_COUNT',
|
|
511
|
-
'XDG_CONFIG_HOME',
|
|
512
|
-
]) {
|
|
513
|
-
delete env[name];
|
|
514
|
-
}
|
|
515
|
-
env.RUSTUP_HOME = process.env.RUSTUP_HOME ?? join(homedir(), '.rustup');
|
|
516
|
-
const child = Bun.spawn(['node', bin, '--include-workspace'], {
|
|
517
|
-
cwd: workspace,
|
|
518
|
-
env,
|
|
519
|
-
stdout: 'pipe',
|
|
520
|
-
stderr: 'pipe',
|
|
521
|
-
});
|
|
522
|
-
const [exitCode, stdout, stderr] = await Promise.all([
|
|
523
|
-
child.exited,
|
|
524
|
-
new Response(child.stdout).text(),
|
|
525
|
-
new Response(child.stderr).text(),
|
|
526
|
-
]);
|
|
527
|
-
return { exitCode, stdout, stderr };
|
|
528
|
-
};
|
|
529
|
-
const clean = join(root, 'clean-home');
|
|
530
|
-
await mkdir(clean);
|
|
531
|
-
const baseline = await run(clean);
|
|
532
|
-
expect(baseline.exitCode, baseline.stderr).toBe(0);
|
|
533
|
-
|
|
534
|
-
// A global configuration git cannot access. A self-referential link fails access() with
|
|
535
|
-
// ELOOP where the sandbox fails it with EPERM; git dies on either.
|
|
536
|
-
const denied = join(root, 'denied-home');
|
|
537
|
-
await mkdir(join(denied, '.config/git'), { recursive: true });
|
|
538
|
-
await symlink('config', join(denied, '.config/git/config'));
|
|
539
|
-
expect(await run(denied)).toEqual(baseline);
|
|
540
|
-
|
|
541
|
-
// A global ignore file that would hide every source the key covers.
|
|
542
|
-
const ignoring = join(root, 'ignoring-home');
|
|
543
|
-
await mkdir(join(ignoring, '.config/git'), { recursive: true });
|
|
544
|
-
await writeFile(join(ignoring, '.config/git/ignore'), '*.rs\n');
|
|
545
|
-
expect(await run(ignoring)).toEqual(baseline);
|
|
546
|
-
} finally {
|
|
547
|
-
await rm(root, { recursive: true, force: true });
|
|
548
|
-
}
|
|
549
|
-
});
|
|
550
|
-
|
|
551
|
-
it.each(['helper', 'cli'])(
|
|
552
|
-
'include-workspace gives a custom Nx cached Cargo consumer a runtime input that follows transitive edits via %s',
|
|
553
|
-
async (mode) => {
|
|
554
|
-
const root = await mkdtemp(join(tmpdir(), 'cargo-hash-consumer-'));
|
|
555
|
-
const dist = join(import.meta.dir, '../dist');
|
|
556
|
-
try {
|
|
557
|
-
const { workspace, manifest, leafSource } = await workspaceCargoFixture(root);
|
|
558
|
-
const hashProgram =
|
|
559
|
-
`import { hashCargoPathInputs } from ${JSON.stringify(join(dist, 'cargo-source-hash.js'))}; ` +
|
|
560
|
-
'console.log(await hashCargoPathInputs("Cargo.toml", process.cwd(), { includeWorkspace: true }));';
|
|
561
|
-
// What a consumer's nx.json names as a `runtime` input; Nx keys the task on its stdout.
|
|
562
|
-
const runtime =
|
|
563
|
-
mode === 'helper'
|
|
564
|
-
? `bun -e '${hashProgram}'`
|
|
565
|
-
: `bun ${JSON.stringify(join(dist, 'bin/smoo-nx-cargo-hash.js'))} --include-workspace`;
|
|
566
|
-
|
|
567
|
-
const initial = await runtimeInputValue(runtime, workspace);
|
|
568
|
-
expect(initial).toBe(`${await hashCargoPathInputs(manifest, workspace, { includeWorkspace: true })}\n`);
|
|
569
|
-
expect(await runtimeInputValue(runtime, workspace)).toBe(initial);
|
|
570
|
-
|
|
571
|
-
// Reached from the consumer only through bridge.
|
|
572
|
-
await writeFile(leafSource, 'pub fn answer() -> u8 { 2 }\n');
|
|
573
|
-
const edited = await runtimeInputValue(runtime, workspace);
|
|
574
|
-
expect(edited).not.toBe(initial);
|
|
575
|
-
expect(edited).toBe(`${await hashCargoPathInputs(manifest, workspace, { includeWorkspace: true })}\n`);
|
|
576
|
-
} finally {
|
|
577
|
-
await rm(root, { recursive: true, force: true });
|
|
578
|
-
}
|
|
579
|
-
},
|
|
580
|
-
);
|
|
581
|
-
|
|
582
|
-
it('keeps the v2 transcript across forward source includes and an ignored source included through an alias', async () => {
|
|
583
|
-
const root = await realpath(await mkdtemp(join(tmpdir(), 'cargo-hash-fused-')));
|
|
584
|
-
const manifest = join(root, 'Cargo.toml');
|
|
585
|
-
const contents = new Map([
|
|
586
|
-
['Cargo.toml', '[workspace]\nmembers=["a","z"]\nresolver="2"\n'],
|
|
587
|
-
['a/Cargo.toml', '[package]\nname="a"\nversion="0.1.0"\nedition="2021"\n'],
|
|
588
|
-
['z/Cargo.toml', '[package]\nname="z"\nversion="0.1.0"\nedition="2021"\n'],
|
|
589
|
-
['a/src/lib.rs', 'const Z: &str = include_str!("../../z/src/lib.rs");\n'],
|
|
590
|
-
['z/src/lib.rs', 'const H: &str = include_str!("../hidden.txt");\nconst P: &str = include_str!("payload.bin");\n'],
|
|
591
|
-
['z/src/hidden.rs', 'const S: &str = include_str!("secret.bin");\n'],
|
|
592
|
-
['z/src/payload.bin', 'payload'],
|
|
593
|
-
['z/src/secret.bin', 'secret'],
|
|
594
|
-
['.gitignore', 'z/src/hidden.rs\n'],
|
|
595
|
-
]);
|
|
596
|
-
try {
|
|
597
|
-
for (const [path, text] of contents) {
|
|
598
|
-
await mkdir(dirname(join(root, path)), { recursive: true });
|
|
599
|
-
await writeFile(join(root, path), text);
|
|
600
|
-
}
|
|
601
|
-
await symlink('src/hidden.rs', join(root, 'z/hidden.txt'));
|
|
602
|
-
execFileSync('git', ['init', '--quiet', root], { stdio: 'pipe' });
|
|
603
|
-
execFileSync('cargo', ['generate-lockfile', '--offline', '--manifest-path', manifest], { stdio: 'pipe' });
|
|
604
|
-
// Independent explicit v2 transcript. In particular, z's source is named by a,
|
|
605
|
-
// while hidden.rs is discovery-only until the unignored alias names its bytes.
|
|
606
|
-
const inputs: { file: string; key: string }[] = [
|
|
607
|
-
{ file: manifest, key: JSON.stringify(['a', '0.1.0', 'ancestor', '1/Cargo.toml']) },
|
|
608
|
-
{ file: join(root, 'a/Cargo.toml'), key: JSON.stringify(['a', '0.1.0', 'file', 'Cargo.toml']) },
|
|
609
|
-
{ file: join(root, 'a/src/lib.rs'), key: JSON.stringify(['a', '0.1.0', 'file', 'src/lib.rs']) },
|
|
610
|
-
{
|
|
611
|
-
file: join(root, 'z/src/lib.rs'),
|
|
612
|
-
key: JSON.stringify(['a', '0.1.0', 'include', 'src/lib.rs\0../../z/src/lib.rs']),
|
|
613
|
-
},
|
|
614
|
-
{ file: join(root, 'z/Cargo.toml'), key: JSON.stringify(['z', '0.1.0', 'file', 'Cargo.toml']) },
|
|
615
|
-
{
|
|
616
|
-
file: join(root, 'z/src/secret.bin'),
|
|
617
|
-
key: JSON.stringify(['z', '0.1.0', 'include', 'src/hidden.rs\0secret.bin']),
|
|
618
|
-
},
|
|
619
|
-
{
|
|
620
|
-
file: join(root, 'z/src/hidden.rs'),
|
|
621
|
-
key: JSON.stringify(['z', '0.1.0', 'include', 'src/lib.rs\0../hidden.txt']),
|
|
622
|
-
},
|
|
623
|
-
{
|
|
624
|
-
file: join(root, 'z/src/payload.bin'),
|
|
625
|
-
key: JSON.stringify(['z', '0.1.0', 'include', 'src/lib.rs\0payload.bin']),
|
|
626
|
-
},
|
|
627
|
-
];
|
|
628
|
-
for (let ancestor = dirname(root), depth = 2; ; ancestor = dirname(ancestor), depth += 1) {
|
|
629
|
-
for (const name of CARGO_ANCESTOR_INPUTS) {
|
|
630
|
-
const file = join(ancestor, name);
|
|
631
|
-
if (statSync(file, { throwIfNoEntry: false })?.isFile()) {
|
|
632
|
-
inputs.push({ file, key: JSON.stringify(['a', '0.1.0', 'ancestor', depth + '/' + name]) });
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
if (dirname(ancestor) === ancestor) break;
|
|
636
|
-
}
|
|
637
|
-
const expected = createHash('sha256');
|
|
638
|
-
expected.update('cargo-path-inputs-v2\0');
|
|
639
|
-
expected.update(JSON.stringify(['z', '0.1.0', 'link', 'hidden.txt']));
|
|
640
|
-
expected.update('\0symlink\0src/hidden.rs\0');
|
|
641
|
-
for (const { file, key } of inputs.sort((left, right) =>
|
|
642
|
-
left.key < right.key ? -1 : left.key > right.key ? 1 : 0,
|
|
643
|
-
)) {
|
|
644
|
-
const bytes = await readFile(file);
|
|
645
|
-
expected.update(key);
|
|
646
|
-
expected.update('\0' + bytes.length + '\0');
|
|
647
|
-
expected.update(bytes);
|
|
648
|
-
}
|
|
649
|
-
const before = await hashCargoPathInputs(manifest, root, { includeWorkspace: true });
|
|
650
|
-
expect(before).toBe(expected.digest('hex'));
|
|
651
|
-
await writeFile(join(root, 'z/src/secret.bin'), 'changed');
|
|
652
|
-
expect(await hashCargoPathInputs(manifest, root, { includeWorkspace: true })).not.toBe(before);
|
|
653
|
-
} finally {
|
|
654
|
-
await rm(root, { recursive: true, force: true });
|
|
655
|
-
}
|
|
656
|
-
});
|
|
657
|
-
|
|
658
|
-
it('keeps literal discovery exact and refuses unreadable sources', async () => {
|
|
659
|
-
const root = await realpath(await mkdtemp(join(tmpdir(), 'cargo-hash-literals-')));
|
|
660
|
-
const source = join(root, 'src/lib.rs');
|
|
661
|
-
const unicode = 'spelling-e\u0301-\u{10000}-payload';
|
|
662
|
-
try {
|
|
663
|
-
await mkdir(dirname(source), { recursive: true });
|
|
664
|
-
await writeFile(
|
|
665
|
-
join(root, 'Cargo.toml'),
|
|
666
|
-
'[package]\nname="literals"\nversion="0.1.0"\nedition="2021"\n[workspace]\n',
|
|
667
|
-
);
|
|
668
|
-
await writeFile(join(root, 'src/data'), 'data');
|
|
669
|
-
await writeFile(join(root, 'src', unicode), 'unicode spelling');
|
|
670
|
-
await writeFile(
|
|
671
|
-
source,
|
|
672
|
-
[
|
|
673
|
-
'const A: &str = include_str!(r#"data"#,);',
|
|
674
|
-
'const B: &[u8] = include_bytes!["data"];',
|
|
675
|
-
'const C: &str = include_str!{"data"};',
|
|
676
|
-
`const U: &str = include_str!(${JSON.stringify(unicode)});`,
|
|
677
|
-
'// include_str!("missing")',
|
|
678
|
-
'/* outer /* include_bytes!("missing") */ comment */',
|
|
679
|
-
'const D: &str = r###"include_str!("missing")"###;',
|
|
680
|
-
'include!("missing");',
|
|
681
|
-
'include_str!("");',
|
|
682
|
-
'include_str!("da\\\\ta");',
|
|
683
|
-
'include_str!(concat!("da", "ta"));',
|
|
684
|
-
'include_str!("missing");',
|
|
685
|
-
'include_str!("data"];',
|
|
686
|
-
'include_str!("unterminated',
|
|
687
|
-
].join('\n'),
|
|
688
|
-
);
|
|
689
|
-
expect(compiledInFiles(root, new Map())).toEqual([
|
|
690
|
-
{ file: join(root, 'src/data'), source, literal: 'data' },
|
|
691
|
-
{ file: join(root, 'src', unicode), source, literal: unicode },
|
|
692
|
-
]);
|
|
693
|
-
execFileSync('cargo', ['generate-lockfile', '--offline', '--manifest-path', join(root, 'Cargo.toml')], {
|
|
694
|
-
stdio: 'pipe',
|
|
695
|
-
});
|
|
696
|
-
await chmod(source, 0);
|
|
697
|
-
expect(() => compiledInFiles(root, new Map())).toThrow();
|
|
698
|
-
// A cold native Cargo census can report the denial before the source read;
|
|
699
|
-
// both paths must preserve the operational refusal rather than skip the file.
|
|
700
|
-
await expect(hashCargoPathInputs(join(root, 'Cargo.toml'), root, { includeWorkspace: true })).rejects.toThrow(
|
|
701
|
-
'EACCES',
|
|
702
|
-
);
|
|
703
|
-
} finally {
|
|
704
|
-
await chmod(source, 0o600);
|
|
705
|
-
await rm(root, { recursive: true, force: true });
|
|
706
|
-
}
|
|
707
|
-
});
|