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