@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/src/cargo-workspace.ts
CHANGED
|
@@ -4,6 +4,8 @@ import { dirname, isAbsolute, join, normalize, posix, relative, resolve, sep } f
|
|
|
4
4
|
import { readNxJson } from 'nx/src/config/nx-json.js';
|
|
5
5
|
import { parse as parseToml, type TomlTable } from 'smol-toml';
|
|
6
6
|
|
|
7
|
+
import { type CompiledCargoInput, compiledInFiles } from './cargo-source-hash.js';
|
|
8
|
+
|
|
7
9
|
export interface CargoWorkspacePackage {
|
|
8
10
|
name: string;
|
|
9
11
|
dir: string;
|
|
@@ -237,11 +239,12 @@ export interface CargoPackageTestInputsOptions {
|
|
|
237
239
|
export interface CargoInputsCache {
|
|
238
240
|
readonly manifests: Map<string, Promise<TomlTable>>;
|
|
239
241
|
readonly nestedCrateDirs: Map<string, string[]>;
|
|
242
|
+
readonly compiledInFiles: Map<string, CompiledCargoInput[]>;
|
|
240
243
|
readonly results: Map<string, Promise<string[]>>;
|
|
241
244
|
}
|
|
242
245
|
|
|
243
246
|
export function createCargoInputsCache(): CargoInputsCache {
|
|
244
|
-
return { manifests: new Map(), nestedCrateDirs: new Map(), results: new Map() };
|
|
247
|
+
return { manifests: new Map(), nestedCrateDirs: new Map(), compiledInFiles: new Map(), results: new Map() };
|
|
245
248
|
}
|
|
246
249
|
|
|
247
250
|
export function cargoPackageTestInputs(options: CargoPackageTestInputsOptions): Promise<string[]> {
|
|
@@ -390,6 +393,12 @@ async function deriveCargoPackageTestInputs(
|
|
|
390
393
|
const childDir = relative(absoluteProjectRoot, child).split(sep).join('/');
|
|
391
394
|
if (!dirs.has(childDir)) exclusions.add(`!${inputPath(child)}/**`);
|
|
392
395
|
}
|
|
396
|
+
// `include_str!("../../../skills/SKILL.md")` compiles a file the package's own
|
|
397
|
+
// fileset does not reach; a target that does not hash it serves a binary
|
|
398
|
+
// built from the file's old bytes.
|
|
399
|
+
for (const { file } of compiledInFiles(absoluteDir, cache.compiledInFiles)) {
|
|
400
|
+
if (isOutsideRoot(relative(absoluteDir, file))) declaredSources.add(file);
|
|
401
|
+
}
|
|
393
402
|
}
|
|
394
403
|
for (const source of [...declaredSources].sort()) {
|
|
395
404
|
const sourceRelative = relative(workspaceRoot, source);
|
|
@@ -632,8 +641,10 @@ export const CARGO_TEST_ARCHIVE_TARGET = 'cargo-test-archive';
|
|
|
632
641
|
* does NOT create this parent directory and fails the whole build when it is
|
|
633
642
|
* missing ("error writing to archive ... No such file or directory"), so the
|
|
634
643
|
* target mkdir's it first.
|
|
644
|
+
* The archive is an Nx-restored output, so it lives on the source volume, never
|
|
645
|
+
* beneath Cargo's symlinked target directory (16_build_volumes.md).
|
|
635
646
|
*/
|
|
636
|
-
export const CARGO_TEST_ARCHIVE_FILE = '
|
|
647
|
+
export const CARGO_TEST_ARCHIVE_FILE = '.cache/nextest/archive.tar.zst';
|
|
637
648
|
|
|
638
649
|
/**
|
|
639
650
|
* One foreign target triple this cargo workspace also archives its tests for.
|
|
@@ -725,13 +736,29 @@ export function listCargoCrossTestTargets(absoluteProjectRoot: string): CargoCro
|
|
|
725
736
|
*/
|
|
726
737
|
export const CARGO_TEST_EXCEPTIONS_SUFFIX = 'exceptions';
|
|
727
738
|
|
|
739
|
+
/** Name prefix of the runner a serial test group gets; see `serialTestGroups`. */
|
|
740
|
+
export const CARGO_TEST_GROUP_PREFIX = 'cargo-test-group-';
|
|
741
|
+
|
|
728
742
|
/**
|
|
729
743
|
* A crate on one target keeps the bare name; a split crate suffixes the piece,
|
|
730
744
|
* so `cargo-test-example-core-shard2` still reads as "example-core's tests".
|
|
731
745
|
*/
|
|
732
746
|
export function cargoTestPackageTargetName(packageName: string, piece?: string): string {
|
|
733
747
|
const base = `cargo-test-${packageName}`;
|
|
734
|
-
|
|
748
|
+
const name = piece === undefined ? base : `${base}-${piece}`;
|
|
749
|
+
// A crate named `group-*` would take the name of a serial group's runner.
|
|
750
|
+
if (name.startsWith(CARGO_TEST_GROUP_PREFIX)) {
|
|
751
|
+
throw new Error(`cargo crate ${packageName} would be named ${name}, reserved for a nextest test group runner`);
|
|
752
|
+
}
|
|
753
|
+
return name;
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
/**
|
|
757
|
+
* A serial group's runner. It selects by filter across the whole workspace, so
|
|
758
|
+
* it is no crate: `packageNameFromCargoTestTarget` reads it as none.
|
|
759
|
+
*/
|
|
760
|
+
export function cargoTestGroupTargetName(group: string): string {
|
|
761
|
+
return `${CARGO_TEST_GROUP_PREFIX}${group}`;
|
|
735
762
|
}
|
|
736
763
|
|
|
737
764
|
/**
|
|
@@ -739,15 +766,17 @@ export function cargoTestPackageTargetName(packageName: string, piece?: string):
|
|
|
739
766
|
* check that the per-crate targets cover every workspace member. Pieces of one
|
|
740
767
|
* crate collapse back to that crate, so a split crate counts as covered once.
|
|
741
768
|
*
|
|
742
|
-
* The
|
|
743
|
-
*
|
|
744
|
-
*
|
|
769
|
+
* The workspace-wide `cargo-test-*` targets are not crates: reading them as one
|
|
770
|
+
* would invent members named "compile" and "archive", and a serial group's runner
|
|
771
|
+
* would invent one named after its group. Each reports every crate's coverage
|
|
772
|
+
* against a set that can never match.
|
|
745
773
|
*/
|
|
746
774
|
export function packageNameFromCargoTestTarget(targetName: string): string | null {
|
|
747
775
|
if (
|
|
748
776
|
!targetName.startsWith('cargo-test-') ||
|
|
749
777
|
targetName === CARGO_TEST_COMPILE_TARGET ||
|
|
750
|
-
targetName === CARGO_TEST_ARCHIVE_TARGET
|
|
778
|
+
targetName === CARGO_TEST_ARCHIVE_TARGET ||
|
|
779
|
+
targetName.startsWith(CARGO_TEST_GROUP_PREFIX)
|
|
751
780
|
) {
|
|
752
781
|
return null;
|
|
753
782
|
}
|
|
@@ -789,10 +818,298 @@ export function exceptionalTestFilter(nextestConfigPath: string): string | null
|
|
|
789
818
|
}
|
|
790
819
|
}
|
|
791
820
|
}
|
|
821
|
+
return filterUnion(filters);
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
/** The filters as one filterset that any of them matches, or null for none. */
|
|
825
|
+
function filterUnion(filters: readonly string[]): string | null {
|
|
792
826
|
const unique = [...new Set(filters)];
|
|
793
827
|
return unique.length === 0 ? null : unique.map((filter) => `(${filter})`).join(' or ');
|
|
794
828
|
}
|
|
795
829
|
|
|
830
|
+
/**
|
|
831
|
+
* The only `platform` a serial group's overrides may declare: nextest's cfg for macOS. The group
|
|
832
|
+
* runs on macOS hosts only, a host decision made by the planner, never a cfg parse here.
|
|
833
|
+
*/
|
|
834
|
+
export const SERIAL_TEST_GROUP_PLATFORM = 'cfg(target_os="macos")';
|
|
835
|
+
|
|
836
|
+
/**
|
|
837
|
+
* Which workspace members a serial group's filter can select tests from: exactly the named
|
|
838
|
+
* packages when every clause of the filter is scoped to one, otherwise every member.
|
|
839
|
+
*/
|
|
840
|
+
export type SerialTestGroupScope =
|
|
841
|
+
| { readonly kind: 'packages'; readonly packages: readonly string[] }
|
|
842
|
+
| { readonly kind: 'workspace' };
|
|
843
|
+
|
|
844
|
+
/**
|
|
845
|
+
* One nextest test group capped at a single thread, and the tests its overrides
|
|
846
|
+
* assign it.
|
|
847
|
+
*/
|
|
848
|
+
export interface SerialTestGroup {
|
|
849
|
+
/** The group's name, as `[test-groups]` declares it. */
|
|
850
|
+
group: string;
|
|
851
|
+
/** Every default-profile override filter that names the group, as one filterset. */
|
|
852
|
+
filter: string;
|
|
853
|
+
/** The members the filter can select from, which are the members whose sources its runner hashes. */
|
|
854
|
+
scope: SerialTestGroupScope;
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
/**
|
|
858
|
+
* The repository's test groups capped at one thread (`max-threads = 1`), each
|
|
859
|
+
* with the tests its default-profile overrides assign it.
|
|
860
|
+
*
|
|
861
|
+
* A serial group is declared exactly once, in `.config/nextest.toml`: the name
|
|
862
|
+
* under `[test-groups]` plus the overrides that name it. Its runner's filter is
|
|
863
|
+
* derived from those overrides rather than restated, so the runner and the
|
|
864
|
+
* per-crate exclusions cannot drift from what nextest actually serializes.
|
|
865
|
+
*
|
|
866
|
+
* Each group also carries the `scope` of its filter (`filterScope`): the members its runner hashes.
|
|
867
|
+
* A group whose every clause is scoped to a `package(<name>)` reruns only when those crates or their
|
|
868
|
+
* local dependencies change; any other group is scoped to the whole workspace. Nothing here orders one
|
|
869
|
+
* group against another: they are separate runners, and a repository that needs two never concurrent
|
|
870
|
+
* declares the edge between their targets itself.
|
|
871
|
+
*
|
|
872
|
+
* Every override naming a serial group must declare `SERIAL_TEST_GROUP_PLATFORM`.
|
|
873
|
+
* This plugin has no cfg evaluator, so it honours exactly that platform and
|
|
874
|
+
* refuses any other rather than guessing where the group applies.
|
|
875
|
+
*
|
|
876
|
+
* Returns [] when the file is absent or declares no serial group, so a workspace
|
|
877
|
+
* without one keeps exactly its existing targets.
|
|
878
|
+
*/
|
|
879
|
+
export function serialTestGroups(nextestConfigPath: string): SerialTestGroup[] {
|
|
880
|
+
if (!existsSync(nextestConfigPath)) {
|
|
881
|
+
return [];
|
|
882
|
+
}
|
|
883
|
+
const parsed: unknown = parseToml(readFileSync(nextestConfigPath, 'utf-8'));
|
|
884
|
+
if (!isRecord(parsed)) {
|
|
885
|
+
return [];
|
|
886
|
+
}
|
|
887
|
+
const declaredValue = parsed['test-groups'];
|
|
888
|
+
const declaredGroups: Record<string, unknown> = isRecord(declaredValue) ? declaredValue : {};
|
|
889
|
+
const serial = Object.keys(declaredGroups)
|
|
890
|
+
.filter((name) => {
|
|
891
|
+
const declared = declaredGroups[name];
|
|
892
|
+
return isRecord(declared) && declared['max-threads'] === 1;
|
|
893
|
+
})
|
|
894
|
+
.sort((left, right) => left.localeCompare(right));
|
|
895
|
+
const profiles: Record<string, unknown> = isRecord(parsed.profile) ? parsed.profile : {};
|
|
896
|
+
const defaults: Record<string, unknown> = isRecord(profiles.default) ? profiles.default : {};
|
|
897
|
+
const overridesValue: unknown = defaults.overrides;
|
|
898
|
+
const overrides: unknown[] = Array.isArray(overridesValue) ? overridesValue : [];
|
|
899
|
+
return serial.flatMap((group) => {
|
|
900
|
+
const filters: string[] = [];
|
|
901
|
+
for (const override of overrides) {
|
|
902
|
+
if (!isRecord(override) || override['test-group'] !== group) {
|
|
903
|
+
continue;
|
|
904
|
+
}
|
|
905
|
+
if (override.platform !== SERIAL_TEST_GROUP_PLATFORM) {
|
|
906
|
+
throw new Error(
|
|
907
|
+
`${nextestConfigPath}: test-group "${group}" overrides must declare platform = '${SERIAL_TEST_GROUP_PLATFORM}' ` +
|
|
908
|
+
`(the only platform a serial group runs on here), got ${JSON.stringify(override.platform ?? null)}`,
|
|
909
|
+
);
|
|
910
|
+
}
|
|
911
|
+
if (typeof override.filter === 'string' && override.filter.length > 0) {
|
|
912
|
+
filters.push(override.filter);
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
const filter = filterUnion(filters);
|
|
916
|
+
return filter === null ? [] : [{ group, filter, scope: filterScope(filter) }];
|
|
917
|
+
});
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
/**
|
|
921
|
+
* The packages `filter` can select tests from, read off its `package(<name>)` predicates. The scope is
|
|
922
|
+
* never narrower than the selection: whatever this does not read with certainty is the whole workspace.
|
|
923
|
+
*
|
|
924
|
+
* The filter is read as nextest reads it, with nextest's precedence — parentheses, then `not` and `!`,
|
|
925
|
+
* then `and`, `&` and `-`, then `or`, `|` and `+`, each level left to right — and with nextest's blanks,
|
|
926
|
+
* which are spaces and line endings. Each expression is bounded by the packages it can select from:
|
|
927
|
+
*
|
|
928
|
+
* - `package(<name>)` and `package(=<name>)`, for a plain Cargo name, bound it to that package. A glob,
|
|
929
|
+
* `~contains`, `/regex/` or `#glob` name can match any package, so it bounds nothing.
|
|
930
|
+
* - Every other predicate bounds nothing, and nor does `not`: `not package(a)` selects from every other
|
|
931
|
+
* package, and `deps` and `rdeps` reach beyond the package they name.
|
|
932
|
+
* - `a and b` selects only what both select, so it is bounded by the narrower of the two bounds, and
|
|
933
|
+
* `a - b`, which is `a and not b`, by `a`. `a or b` is bounded by both together, so one unbounded
|
|
934
|
+
* clause leaves the union unbounded however the union is spelled.
|
|
935
|
+
*
|
|
936
|
+
* A predicate's argument ends where nextest ends it: a regex at its closing `/`, any other matcher at its
|
|
937
|
+
* first `)`. Only arguments that need none of nextest's escape sequences are read: a backslash, or a comma
|
|
938
|
+
* outside a regex, makes where the predicate ends depend on escapes this does not implement. Those, a
|
|
939
|
+
* filter that does not parse, and one whose packages exclude each other have no bound.
|
|
940
|
+
*/
|
|
941
|
+
export function filterScope(filter: string): SerialTestGroupScope {
|
|
942
|
+
const read = readUnion(filter, 0);
|
|
943
|
+
if (read === null || skipBlank(filter, read.end) !== filter.length || read.bound === 'any' || read.bound.size === 0) {
|
|
944
|
+
return { kind: 'workspace' };
|
|
945
|
+
}
|
|
946
|
+
return { kind: 'packages', packages: [...read.bound].sort((left, right) => left.localeCompare(right)) };
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
/** What a filterset can select from: only the named packages, or `'any'` when no package bounds it. */
|
|
950
|
+
type PackageBound = ReadonlySet<string> | 'any';
|
|
951
|
+
|
|
952
|
+
/** A filterset prefix that has been read: the packages it can select from, and the offset just past it. */
|
|
953
|
+
interface ReadFilter {
|
|
954
|
+
readonly bound: PackageBound;
|
|
955
|
+
readonly end: number;
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
/** nextest's loosest-binding level: `or`, `|` and `+` between chains of `and`. */
|
|
959
|
+
function readUnion(text: string, from: number): ReadFilter | null {
|
|
960
|
+
let left = readIntersection(text, from);
|
|
961
|
+
while (left !== null) {
|
|
962
|
+
const operatorEnd = skipUnionOperator(text, left.end);
|
|
963
|
+
if (operatorEnd === null) return left;
|
|
964
|
+
const right = readIntersection(text, operatorEnd);
|
|
965
|
+
if (right === null) return null;
|
|
966
|
+
const bound = left.bound === 'any' || right.bound === 'any' ? 'any' : new Set([...left.bound, ...right.bound]);
|
|
967
|
+
left = { bound, end: right.end };
|
|
968
|
+
}
|
|
969
|
+
return null;
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
/** A chain of `and`, `&` and `-`, which bind tighter than a union, left to right. */
|
|
973
|
+
function readIntersection(text: string, from: number): ReadFilter | null {
|
|
974
|
+
let left = readOperand(text, from);
|
|
975
|
+
while (left !== null) {
|
|
976
|
+
const operator = readIntersectionOperator(text, left.end);
|
|
977
|
+
if (operator === null) return left;
|
|
978
|
+
const right = readOperand(text, operator.end);
|
|
979
|
+
left =
|
|
980
|
+
right === null
|
|
981
|
+
? null
|
|
982
|
+
: { bound: operator.difference ? left.bound : boundIntersection(left.bound, right.bound), end: right.end };
|
|
983
|
+
}
|
|
984
|
+
return null;
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
/** A negation, a parenthesised filterset, or one predicate. */
|
|
988
|
+
function readOperand(text: string, from: number): ReadFilter | null {
|
|
989
|
+
const at = skipBlank(text, from);
|
|
990
|
+
const word = readWord(text, at, 'not');
|
|
991
|
+
const negated = word ?? (text.charAt(at) === '!' ? at + 1 : null);
|
|
992
|
+
if (negated !== null) {
|
|
993
|
+
const operand = readOperand(text, negated);
|
|
994
|
+
return operand === null ? null : { bound: 'any', end: operand.end };
|
|
995
|
+
}
|
|
996
|
+
if (text.charAt(at) !== '(') return readPredicate(text, at);
|
|
997
|
+
const inner = readUnion(text, at + 1);
|
|
998
|
+
if (inner === null) return null;
|
|
999
|
+
const close = skipBlank(text, inner.end);
|
|
1000
|
+
return text.charAt(close) === ')' ? { bound: inner.bound, end: close + 1 } : null;
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
/** What follows a predicate's `(`: nothing, or a name matcher. */
|
|
1004
|
+
const PREDICATE_ARGUMENTS: Record<string, 'none' | 'matcher'> = {
|
|
1005
|
+
all: 'none',
|
|
1006
|
+
none: 'none',
|
|
1007
|
+
default: 'none',
|
|
1008
|
+
test: 'matcher',
|
|
1009
|
+
group: 'matcher',
|
|
1010
|
+
package: 'matcher',
|
|
1011
|
+
deps: 'matcher',
|
|
1012
|
+
rdeps: 'matcher',
|
|
1013
|
+
binary_id: 'matcher',
|
|
1014
|
+
kind: 'matcher',
|
|
1015
|
+
binary: 'matcher',
|
|
1016
|
+
platform: 'matcher',
|
|
1017
|
+
};
|
|
1018
|
+
|
|
1019
|
+
/** One predicate: `all()` and its kin, or a name followed by its parenthesised matcher. */
|
|
1020
|
+
function readPredicate(text: string, at: number): ReadFilter | null {
|
|
1021
|
+
const identifier = /[a-z_]+/y;
|
|
1022
|
+
identifier.lastIndex = at;
|
|
1023
|
+
const predicate = identifier.exec(text)?.[0];
|
|
1024
|
+
if (predicate === undefined) return null;
|
|
1025
|
+
const open = skipBlank(text, at + predicate.length);
|
|
1026
|
+
if (text.charAt(open) !== '(') return null;
|
|
1027
|
+
const argument = Object.hasOwn(PREDICATE_ARGUMENTS, predicate) ? PREDICATE_ARGUMENTS[predicate] : undefined;
|
|
1028
|
+
if (argument === undefined) return null;
|
|
1029
|
+
if (argument === 'none') {
|
|
1030
|
+
const close = skipBlank(text, open + 1);
|
|
1031
|
+
return text.charAt(close) === ')' ? { bound: 'any', end: close + 1 } : null;
|
|
1032
|
+
}
|
|
1033
|
+
const matcher = readMatcher(text, open + 1);
|
|
1034
|
+
return matcher === null
|
|
1035
|
+
? null
|
|
1036
|
+
: { bound: predicate === 'package' ? packageBound(matcher.text) : 'any', end: matcher.end };
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
/**
|
|
1040
|
+
* The argument of a predicate whose `(` ends just before `from`, as written between its parentheses, and
|
|
1041
|
+
* the offset past its `)`; null when it cannot be delimited exactly as nextest delimits it.
|
|
1042
|
+
*/
|
|
1043
|
+
function readMatcher(text: string, from: number): { readonly text: string; readonly end: number } | null {
|
|
1044
|
+
const start = skipBlank(text, from);
|
|
1045
|
+
const close = text.charAt(start) === '/' ? regexMatcherClose(text, start) : plainMatcherClose(text, start);
|
|
1046
|
+
return close === null ? null : { text: text.slice(from, close), end: close + 1 };
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
/** The `)` that follows the `/regex/` starting at `start`, when the regex holds no backslash. */
|
|
1050
|
+
function regexMatcherClose(text: string, start: number): number | null {
|
|
1051
|
+
const slash = text.indexOf('/', start + 1);
|
|
1052
|
+
if (slash < 0 || text.slice(start, slash).includes('\\')) return null;
|
|
1053
|
+
const close = skipBlank(text, slash + 1);
|
|
1054
|
+
return text.charAt(close) === ')' ? close : null;
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
/** The first `)` at or after `start`, when nothing before it is a backslash or a comma. */
|
|
1058
|
+
function plainMatcherClose(text: string, start: number): number | null {
|
|
1059
|
+
const close = text.indexOf(')', start);
|
|
1060
|
+
return close < 0 || /[,\\]/.test(text.slice(start, close)) ? null : close;
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
/** A plain Cargo package name, with or without nextest's `=` prefix: nothing a glob can widen. */
|
|
1064
|
+
const PLAIN_PACKAGE_NAME = /^=?([A-Za-z0-9_-]+)$/;
|
|
1065
|
+
|
|
1066
|
+
function packageBound(matcher: string): PackageBound {
|
|
1067
|
+
const name = PLAIN_PACKAGE_NAME.exec(matcher)?.[1];
|
|
1068
|
+
return name === undefined ? 'any' : new Set([name]);
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
function boundIntersection(left: PackageBound, right: PackageBound): PackageBound {
|
|
1072
|
+
if (left === 'any') return right;
|
|
1073
|
+
if (right === 'any') return left;
|
|
1074
|
+
return new Set([...left].filter((name) => right.has(name)));
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
/** The offset of the first character at or after `from` that nextest does not read as blank. */
|
|
1078
|
+
function skipBlank(text: string, from: number): number {
|
|
1079
|
+
const blank = /(?: |\r?\n)*/y;
|
|
1080
|
+
blank.lastIndex = from;
|
|
1081
|
+
return from + (blank.exec(text)?.[0].length ?? 0);
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
/** `word` at `at`, read as nextest reads an operator word: not the start of a longer identifier. */
|
|
1085
|
+
function readWord(text: string, at: number, word: string): number | null {
|
|
1086
|
+
const end = at + word.length;
|
|
1087
|
+
return text.startsWith(word, at) && !/[A-Za-z0-9_]/.test(text.charAt(end)) ? end : null;
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
/** The offset past the `or`, `|` or `+` that follows `from` after any blanks, or null. */
|
|
1091
|
+
function skipUnionOperator(text: string, from: number): number | null {
|
|
1092
|
+
const at = skipBlank(text, from);
|
|
1093
|
+
const character = text.charAt(at);
|
|
1094
|
+
return readWord(text, at, 'or') ?? (character === '|' || character === '+' ? at + 1 : null);
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
/** The `and`, `&` or `-` that follows `from` after any blanks: where it ends, and whether it subtracts. */
|
|
1098
|
+
function readIntersectionOperator(
|
|
1099
|
+
text: string,
|
|
1100
|
+
from: number,
|
|
1101
|
+
): { readonly end: number; readonly difference: boolean } | null {
|
|
1102
|
+
const at = skipBlank(text, from);
|
|
1103
|
+
const word = readWord(text, at, 'and');
|
|
1104
|
+
if (word !== null) return { end: word, difference: false };
|
|
1105
|
+
const character = text.charAt(at);
|
|
1106
|
+
if (character === '&') return { end: at + 1, difference: false };
|
|
1107
|
+
return character === '-' ? { end: at + 1, difference: true } : null;
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
/** The plugin's nextest.toml as the workspace root's `node_modules` links it. */
|
|
1111
|
+
export const PLUGIN_NEXTEST_CONFIG_PATH = 'node_modules/@smoothbricks/nx-plugin/nextest.toml';
|
|
1112
|
+
|
|
796
1113
|
/**
|
|
797
1114
|
* The plugin's own nextest settings, as a config layer BENEATH the repository's.
|
|
798
1115
|
*
|
|
@@ -811,10 +1128,19 @@ export function exceptionalTestFilter(nextestConfigPath: string): string | null
|
|
|
811
1128
|
* (`bounded-exec`, which spawns with `shell: true`) go through a shell — so the
|
|
812
1129
|
* command text stays identical everywhere. Quoted, because a workspace path may
|
|
813
1130
|
* contain spaces.
|
|
1131
|
+
*
|
|
1132
|
+
* The file is named through the workspace root's `node_modules` link, as
|
|
1133
|
+
* `NEXTEST_EXTRACT_BIN` is, never through where the plugin really lives: a
|
|
1134
|
+
* plugin linked from a checkout outside the workspace sits a different number
|
|
1135
|
+
* of `../` away from each workspace depending on how deep that workspace is,
|
|
1136
|
+
* and that count re-keyed every target of every Cargo project — and every
|
|
1137
|
+
* dependent task — in each workspace that sat at a new depth.
|
|
1138
|
+
*
|
|
1139
|
+
* `projectRoot` is the Cargo workspace's root relative to the Nx workspace
|
|
1140
|
+
* root, which is the directory these commands run in.
|
|
814
1141
|
*/
|
|
815
|
-
export function nextestToolConfigArg(
|
|
816
|
-
const
|
|
817
|
-
const path = rel.length === 0 ? configAbs : rel.split(sep).join('/');
|
|
1142
|
+
export function nextestToolConfigArg(projectRoot: string): string {
|
|
1143
|
+
const path = posix.join(posix.relative(projectRoot, '.'), PLUGIN_NEXTEST_CONFIG_PATH);
|
|
818
1144
|
return `--tool-config-file "smoo:$PWD/${path}"`;
|
|
819
1145
|
}
|
|
820
1146
|
|
|
@@ -6,6 +6,7 @@ import { join } from 'node:path';
|
|
|
6
6
|
import {
|
|
7
7
|
CARGO_CROSS_LINT_COMMAND,
|
|
8
8
|
CARGO_CROSS_LINT_TARGET,
|
|
9
|
+
CARGO_DENY_WARNINGS,
|
|
9
10
|
CARGO_LINT_CLIPPY_COMMAND,
|
|
10
11
|
CARGO_LINUX_TRIPLE,
|
|
11
12
|
CROSS_CHECK_SCRIPT_COMMAND,
|
|
@@ -57,10 +58,67 @@ describe('Linux cross-check policy', () => {
|
|
|
57
58
|
it('matches the severity and triple CI lints with', () => {
|
|
58
59
|
// A weaker local command passes where CI fails, which is the failure this
|
|
59
60
|
// gate exists to prevent rather than reproduce.
|
|
60
|
-
expect(CARGO_CROSS_LINT_COMMAND).toContain(
|
|
61
|
+
expect(CARGO_CROSS_LINT_COMMAND).toContain(CARGO_DENY_WARNINGS);
|
|
61
62
|
expect(CARGO_CROSS_LINT_COMMAND).toContain(`--target ${CARGO_LINUX_TRIPLE}`);
|
|
62
63
|
});
|
|
63
64
|
|
|
65
|
+
it('passes clippy-driver no arguments, so the gate and a plain clippy share one unit set', () => {
|
|
66
|
+
// Anything after `--` becomes CLIPPY_ARGS, part of every member's fingerprint.
|
|
67
|
+
for (const command of [CARGO_LINT_CLIPPY_COMMAND, CARGO_CROSS_LINT_COMMAND]) {
|
|
68
|
+
expect(command).not.toContain(' -- ');
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('fails on warnings it replays from units a plain clippy already checked', async () => {
|
|
73
|
+
const project = await mkdtemp(join(tmpdir(), 'cargo-lint-warnings-'));
|
|
74
|
+
const clippy = async (command: string): Promise<{ exitCode: number; output: string }> => {
|
|
75
|
+
const child = Bun.spawn(['sh', '-c', command], {
|
|
76
|
+
cwd: project,
|
|
77
|
+
env: { ...process.env, RUSTC_WRAPPER: '', RUSTC_WORKSPACE_WRAPPER: '' },
|
|
78
|
+
stdout: 'pipe',
|
|
79
|
+
stderr: 'pipe',
|
|
80
|
+
});
|
|
81
|
+
const [exitCode, stdout, stderr] = await Promise.all([
|
|
82
|
+
child.exited,
|
|
83
|
+
new Response(child.stdout).text(),
|
|
84
|
+
new Response(child.stderr).text(),
|
|
85
|
+
]);
|
|
86
|
+
return { exitCode, output: stdout + stderr };
|
|
87
|
+
};
|
|
88
|
+
try {
|
|
89
|
+
await mkdir(join(project, 'src'));
|
|
90
|
+
await writeFile(
|
|
91
|
+
join(project, 'Cargo.toml'),
|
|
92
|
+
'[package]\nname = "warning-fixture"\nversion = "0.1.0"\nedition = "2021"\n[workspace]\n',
|
|
93
|
+
);
|
|
94
|
+
await writeFile(
|
|
95
|
+
join(project, 'Cargo.lock'),
|
|
96
|
+
'version = 4\n\n[[package]]\nname = "warning-fixture"\nversion = "0.1.0"\n',
|
|
97
|
+
);
|
|
98
|
+
await writeFile(join(project, 'src/lib.rs'), 'pub fn planted() {\n let unused = 1;\n}\n');
|
|
99
|
+
const plain = cargoFrozen('clippy --workspace --all-targets');
|
|
100
|
+
|
|
101
|
+
const first = await clippy(plain);
|
|
102
|
+
expect(first).toMatchObject({ exitCode: 0 });
|
|
103
|
+
expect(first.output).toContain('Checking warning-fixture');
|
|
104
|
+
expect(first.output).toContain('unused variable');
|
|
105
|
+
|
|
106
|
+
// Fresh: the gate replays the plain run's units and their warning, and fails on it.
|
|
107
|
+
const gate = await clippy(CARGO_LINT_CLIPPY_COMMAND);
|
|
108
|
+
expect(gate.exitCode).not.toBe(0);
|
|
109
|
+
expect(gate.output).not.toContain('Checking warning-fixture');
|
|
110
|
+
expect(gate.output).toContain('unused variable');
|
|
111
|
+
expect(gate.output).toContain('warnings are denied by `build.warnings` configuration');
|
|
112
|
+
|
|
113
|
+
// And the gate left the plain run's units Fresh in turn.
|
|
114
|
+
const again = await clippy(plain);
|
|
115
|
+
expect(again).toMatchObject({ exitCode: 0 });
|
|
116
|
+
expect(again.output).not.toContain('Checking warning-fixture');
|
|
117
|
+
} finally {
|
|
118
|
+
await rm(project, { recursive: true, force: true });
|
|
119
|
+
}
|
|
120
|
+
}, 60_000);
|
|
121
|
+
|
|
64
122
|
it('fails closed on Darwin without the linux-cross compiler instead of compiling', () => {
|
|
65
123
|
// Without this guard a Darwin cache miss sits in ring's cc-rs looking for
|
|
66
124
|
// x86_64-linux-gnu-gcc. The linux-cross profile exports
|
|
@@ -94,8 +94,25 @@ export const CARGO_FETCH_TARGET = 'cargo-fetch';
|
|
|
94
94
|
export const CARGO_FETCH_COMMAND = 'cargo fetch --locked';
|
|
95
95
|
|
|
96
96
|
/**
|
|
97
|
-
*
|
|
98
|
-
*
|
|
97
|
+
* Deny warnings through Cargo's `build.warnings`, never `-- -D warnings`.
|
|
98
|
+
*
|
|
99
|
+
* Arguments after `--` reach clippy-driver through `CLIPPY_ARGS`, which Cargo
|
|
100
|
+
* hashes into every member unit's fingerprint. A gate that passes
|
|
101
|
+
* `-D warnings` therefore owns a unit set of its own: it and a plain
|
|
102
|
+
* `cargo clippy` invalidate each other, re-checking every member each time.
|
|
103
|
+
* `build.warnings` is Cargo's own verdict over the diagnostics it collected,
|
|
104
|
+
* including those it replays from Fresh units, and it reaches no compiler
|
|
105
|
+
* invocation, so every caller shares one unit set while the gate still fails.
|
|
106
|
+
*
|
|
107
|
+
* On the command line rather than in a config file: the gate's verdict is not
|
|
108
|
+
* a repository's local choice, and `--config` outranks every config file.
|
|
109
|
+
*/
|
|
110
|
+
export const CARGO_DENY_WARNINGS = `--config 'build.warnings="deny"'`;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Clippy rather than `cargo check`, and warnings denied, because that is
|
|
114
|
+
* exactly what CI's `lint` runs; a weaker local command would pass where CI
|
|
115
|
+
* fails.
|
|
99
116
|
*
|
|
100
117
|
* `--all-targets` is what answers "what does test mean when cross-compiling": it
|
|
101
118
|
* type-checks bins, tests, benches and examples for the target, so test CODE is
|
|
@@ -113,7 +130,8 @@ export const CARGO_FETCH_COMMAND = 'cargo fetch --locked';
|
|
|
113
130
|
*
|
|
114
131
|
* Keep the caller's CARGO_HOME: it owns registry sources, credentials and global
|
|
115
132
|
* Cargo configuration, including paths relative to that configuration. Relocating
|
|
116
|
-
* or replaying it through --config changes path resolution or precedence
|
|
133
|
+
* or replaying it through --config changes path resolution or precedence; the
|
|
134
|
+
* one `--config` here sets `build.warnings` alone.
|
|
117
135
|
* Cargo may serialize registry access on its package-cache lock; these checks
|
|
118
136
|
* are unbounded, and correctness takes priority over overlapping that access.
|
|
119
137
|
*
|
|
@@ -122,7 +140,7 @@ export const CARGO_FETCH_COMMAND = 'cargo fetch --locked';
|
|
|
122
140
|
* behind host builds.
|
|
123
141
|
*/
|
|
124
142
|
export const CARGO_CROSS_LINT_COMMAND = `${CARGO_CROSS_LINT_GUARD}; ${cargoFrozen(
|
|
125
|
-
`clippy --workspace --all-targets --target ${CARGO_LINUX_TRIPLE} --target-dir target/cargo-lint-cross
|
|
143
|
+
`clippy --workspace --all-targets --target ${CARGO_LINUX_TRIPLE} --target-dir target/cargo-lint-cross ${CARGO_DENY_WARNINGS}`,
|
|
126
144
|
)}`;
|
|
127
145
|
|
|
128
146
|
/**
|
|
@@ -134,8 +152,9 @@ export const CARGO_CROSS_LINT_COMMAND = `${CARGO_CROSS_LINT_GUARD}; ${cargoFroze
|
|
|
134
152
|
* a proc-macro and ordinary code use stays a distinct unit: a dev build
|
|
135
153
|
* compiles it once at the target profile, while a check build needs a separate
|
|
136
154
|
* host copy. Distinct hashes coexist, so neither command dirties the other.
|
|
155
|
+
* A plain `cargo clippy --workspace --all-targets` checks exactly these units.
|
|
137
156
|
*/
|
|
138
|
-
export const CARGO_LINT_CLIPPY_COMMAND = cargoFrozen(
|
|
157
|
+
export const CARGO_LINT_CLIPPY_COMMAND = cargoFrozen(`clippy --workspace --all-targets ${CARGO_DENY_WARNINGS}`);
|
|
139
158
|
|
|
140
159
|
/** Root `package.json` script name, in the repo's `verb:qualifier` style. */
|
|
141
160
|
export const CROSS_CHECK_SCRIPT_NAME = 'check:linux';
|
|
@@ -198,7 +217,7 @@ export function cargoCrossTestTargetName(triple: string): string {
|
|
|
198
217
|
* the other's name.
|
|
199
218
|
*/
|
|
200
219
|
export function cargoCrossTestArchiveFile(triple: string): string {
|
|
201
|
-
return
|
|
220
|
+
return `.cache/nextest/archive-${triple}.tar.zst`;
|
|
202
221
|
}
|
|
203
222
|
|
|
204
223
|
const CARGO_CROSS_TEST_ARCHIVE_PREFIX = cargoCrossTestArchiveTargetName('');
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { describe, expect, it } from 'bun:test';
|
|
2
|
+
import { directDiskCommands, PHYSICAL_BOOT_LAYER } from './disk-command-policy.js';
|
|
3
|
+
|
|
4
|
+
const imageTool = '/usr/bin/hdiutil';
|
|
5
|
+
const diskTool = '/usr/sbin/diskutil';
|
|
6
|
+
|
|
7
|
+
describe('disk-image execution boundary', () => {
|
|
8
|
+
it('rejects direct process calls in Rust, Node, Python and shell, including aliases', () => {
|
|
9
|
+
for (const source of [
|
|
10
|
+
`Command::new("${imageTool}").args(["attach", image]);`,
|
|
11
|
+
`const PROGRAM: &str = "${diskTool}"; Command::new(PROGRAM);`,
|
|
12
|
+
`const executable = '${imageTool}'; spawn(executable, ['attach', image]);`,
|
|
13
|
+
`execFileSync('${diskTool}', ['image', 'attach', image]);`,
|
|
14
|
+
`Bun.spawn(['${imageTool}', 'attach', image]);`,
|
|
15
|
+
`Bun.spawn({ cmd: ['${imageTool}', 'attach', image] });`,
|
|
16
|
+
`argv = ['${diskTool}', 'eject', device]\nsubprocess.run(argv)`,
|
|
17
|
+
`subprocess.run(['${diskTool}', 'image', 'attach', image]);`,
|
|
18
|
+
`sh(['${diskTool}', 'eject', device])`,
|
|
19
|
+
`$\`${imageTool} detach \${device}\``,
|
|
20
|
+
`#!/bin/sh\n${imageTool} attach "$image"`,
|
|
21
|
+
`info=$(${diskTool} info -plist "$device")`,
|
|
22
|
+
]) {
|
|
23
|
+
expect(directDiskCommands(source).length, source).toBeGreaterThan(0);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('allows the shared command layer, its Nx adapter, and declarative command requests', () => {
|
|
28
|
+
for (const source of [
|
|
29
|
+
`SystemCommandRunner.run(&CommandRequest::new("${imageTool}", ["detach", device]));`,
|
|
30
|
+
`host.run('${diskTool}', ['image', 'attach', image]);`,
|
|
31
|
+
`this.commands.run('${imageTool}', ['attach', image]);`,
|
|
32
|
+
`subprocess.run(['cowshed', 'disk-command', '${diskTool}', '--', 'info']);`,
|
|
33
|
+
'$`cowshed disk-command hdiutil -- detach "$device"`',
|
|
34
|
+
`// ${imageTool} attach is prohibited\n/* Command::new("${diskTool}") */`,
|
|
35
|
+
`"""Measure \`${diskTool} image attach\` and \`${imageTool} detach\`."""`,
|
|
36
|
+
`format!("retry with \`${imageTool} detach\`; this message executes nothing");`,
|
|
37
|
+
`{"op":"disk-lease","command":"${imageTool} detach /dev/disk9"}`,
|
|
38
|
+
]) {
|
|
39
|
+
expect(directDiskCommands(source), source).toEqual([]);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('admits only the fixed physical-volume boot commands in their owning layer', () => {
|
|
44
|
+
const boot = [
|
|
45
|
+
`info=$(${diskTool} info -plist "$uuid")`,
|
|
46
|
+
`| ${diskTool} apfs unlockVolume "$uuid" -nomount -stdinpassphrase`,
|
|
47
|
+
`${diskTool} mount -nobrowse -mountPoint "$mountpoint" "$uuid"`,
|
|
48
|
+
].join('\n');
|
|
49
|
+
expect(directDiskCommands(boot, PHYSICAL_BOOT_LAYER)).toEqual([]);
|
|
50
|
+
expect(directDiskCommands(boot, 'elsewhere.sh').length).toBeGreaterThan(0);
|
|
51
|
+
for (const verb of ['image attach', 'image create', 'attach', 'detach', 'eject']) {
|
|
52
|
+
expect(directDiskCommands(`${diskTool} ${verb} "$image"`, PHYSICAL_BOOT_LAYER)).toEqual([1]);
|
|
53
|
+
expect(directDiskCommands(`${imageTool} ${verb} "$image"`, PHYSICAL_BOOT_LAYER)).toEqual([1]);
|
|
54
|
+
}
|
|
55
|
+
expect(directDiskCommands(`HostCommand::new("${diskTool}", ["image", "attach", path])`)).toEqual([1]);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('reports the source line, retaining multiline comment offsets', () => {
|
|
59
|
+
expect(directDiskCommands(`/* example\nnot executed */\nspawn('${imageTool}', []);`)).toEqual([3]);
|
|
60
|
+
});
|
|
61
|
+
});
|