@smoothbricks/nx-plugin 0.4.4 → 0.4.6

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/src/index.test.ts CHANGED
@@ -73,7 +73,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
73
73
  };
74
74
  const rustOnly = await runLint();
75
75
  expect(rustOnly).toMatchObject({ exitCode: 0 });
76
- expect(rustOnly.output).toContain('cargo-lint-lint-crate');
76
+ expect(rustOnly.output).toContain('cargo-lint');
77
77
  await workspace.write('packages/rust/src/check.js', 'debugger;\n');
78
78
  const withJavaScript = await runLint();
79
79
  expect(withJavaScript.exitCode).not.toBe(0);
@@ -386,7 +386,8 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
386
386
  // needs the locked graph downloaded whether or not the chain runs first.
387
387
  for (const name of [
388
388
  'cargo-test-compile',
389
- 'cargo-lint-ferris-core',
389
+ 'cargo-test-archive',
390
+ 'cargo-lint',
390
391
  CARGO_CROSS_LINT_TARGET,
391
392
  'mutation',
392
393
  'bench',
@@ -403,15 +404,40 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
403
404
  });
404
405
  expect(targets['cargo-test']?.executor).toBe('nx:noop');
405
406
  expect(targets['cargo-test']?.dependsOn).toEqual(['cargo-test-ferris-core', 'cargo-test-ferris-wasm']);
406
- expect(targets['cargo-test-ferris-core']?.dependsOn).toEqual(['cargo-fetch', 'cargo-test-compile']);
407
- expect(targets['cargo-test-ferris-wasm']?.dependsOn).toEqual(['cargo-fetch', 'cargo-test-ferris-core']);
408
- // `--workspace -E 'package(...)'`, never `--package`: the filterset picks
409
- // the same tests without re-resolving features, so the run reuses what
410
- // cargo-test-compile built instead of rebuilding inside the bound. A
411
- // workspace member with no tests is still a successful per-crate target.
407
+ // One workspace compile, packed once. Every per-crate runner reads that
408
+ // archive, so the runners fan out instead of chaining: none of them
409
+ // builds, re-resolves features, or writes cargo's flocked `target/`.
410
+ expect(targets['cargo-test-archive']?.executor).toBe('nx:run-commands');
411
+ expect(targets['cargo-test-archive']?.cache).toBe(true);
412
+ expect(targets['cargo-test-archive']?.outputs).toEqual(['{projectRoot}/target/nextest/archive.tar.zst']);
413
+ expect(targets['cargo-test-archive']?.options).toMatchObject({ cwd: 'packages/ferris', parallel: false });
414
+ // nextest does not create the archive's parent directory and fails the
415
+ // whole build if it is missing (measured: "error writing to archive").
416
+ expect(targets['cargo-test-archive']?.options?.commands?.[0]).toBe('mkdir -p target/nextest');
417
+ // `--tool-config-file`, never `--config-file`: the plugin's settings must
418
+ // sit UNDER the repository's `.config/nextest.toml`, which is the only
419
+ // place an `archive.include` for a cdylib or fixture can be declared.
420
+ // `$PWD` because tool config paths must be absolute and an absolute path
421
+ // in the command text would split one cache entry per checkout.
422
+ expect(String(targets['cargo-test-archive']?.options?.commands?.[1])).toMatch(
423
+ /^cargo --frozen nextest archive --workspace --archive-file target\/nextest\/archive\.tar\.zst --user-config-file none --tool-config-file "smoo:\$PWD\/.*nextest\.toml"$/,
424
+ );
425
+ expect(targets['cargo-test-archive']?.inputs).toContain('{projectRoot}/.config/nextest.toml');
426
+ expect(String(targets['cargo-test-archive']?.configurations?.production?.commands?.[1])).toContain(
427
+ 'nextest archive --workspace --release --archive-file',
428
+ );
429
+ expect(targets['cargo-test-ferris-core']?.dependsOn).toEqual(['cargo-fetch', 'cargo-test-archive']);
430
+ expect(targets['cargo-test-ferris-wasm']?.dependsOn).toEqual(['cargo-fetch', 'cargo-test-archive']);
431
+ // The runner executes the archive's binaries and remaps the workspace
432
+ // root: without `--workspace-remap`, a restored archive hands tests the
433
+ // PRODUCING tree's absolute CARGO_MANIFEST_DIR (measured on a moved tree).
434
+ // `--workspace` is not merely redundant here, nextest rejects it with
435
+ // `--archive-file`.
412
436
  expect(targets['cargo-test-ferris-core']?.options?.command).toMatch(
413
- /^cargo --frozen nextest run --workspace -E 'package\(ferris-core\)' --no-tests=pass --user-config-file none --config-file /,
437
+ /^cargo --frozen nextest run --archive-file target\/nextest\/archive\.tar\.zst --workspace-remap \. -E 'package\(ferris-core\)' --no-tests=pass --user-config-file none --tool-config-file "smoo:\$PWD\/.*nextest\.toml"$/,
414
438
  );
439
+ expect(targets['cargo-test-ferris-core']?.inputs).toContain('{projectRoot}/.config/nextest.toml');
440
+ expect(targets['cargo-test-ferris-core']?.configurations?.production).toEqual({});
415
441
  expect(targets['cargo-test-ferris-core']?.inputs).toEqual(
416
442
  expect.arrayContaining([
417
443
  '{projectRoot}/Cargo.toml',
@@ -420,16 +446,20 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
420
446
  ]),
421
447
  );
422
448
  expect(targets['cargo-test-ferris-core']?.inputs).not.toContain('{projectRoot}/crates/ferris-wasm/**/*');
423
- expect(targets['cargo-lint']?.dependsOn).toEqual(['cargo-lint-ferris-core', 'cargo-lint-ferris-wasm']);
424
- expect(targets['cargo-lint-ferris-core']?.options).toMatchObject({
449
+ // One clippy for the workspace in one target dir: a per-crate closure
450
+ // compiled every shared dependency once per crate.
451
+ expect(targets['cargo-lint']?.options).toMatchObject({
425
452
  cwd: 'packages/ferris',
426
453
  commands: [
427
- 'cargo fmt -p ferris-core --check',
428
- 'cargo --frozen clippy -p ferris-core --all-targets --target-dir target/cargo-lint-ferris-core -- -D warnings',
454
+ 'cargo fmt --all --check',
455
+ 'cargo --frozen clippy --workspace --all-targets --target-dir target/cargo-lint -- -D warnings',
429
456
  ],
430
457
  });
431
- expect(targets['cargo-lint-ferris-core']?.cache).toBe(true);
432
- expect(targets['cargo-lint-ferris-core']?.outputs).toEqual([]);
458
+ expect(targets['cargo-lint']?.cache).toBe(true);
459
+ expect(targets['cargo-lint']?.outputs).toEqual([]);
460
+ expect(targets['cargo-lint']?.inputs).toEqual(
461
+ expect.arrayContaining(['{projectRoot}/crates/ferris-core/**/*', '{projectRoot}/crates/ferris-wasm/**/*']),
462
+ );
433
463
  expect(targets.lint?.dependsOn).toEqual(['cargo-lint']);
434
464
  expect(targets[CARGO_CROSS_LINT_TARGET]?.options).toMatchObject({
435
465
  command: CARGO_CROSS_LINT_COMMAND,
@@ -447,6 +477,32 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
447
477
  }
448
478
  });
449
479
 
480
+ it('cleans every cargo directory its own commands write, including the ones caching refuses', async () => {
481
+ const workspace = await createWorkspace();
482
+ try {
483
+ await workspace.write('packages/ferris/package.json', '{"name":"ferris"}\n');
484
+ await workspace.write('packages/ferris/Cargo.toml', '[workspace]\nmembers = ["crates/ferris-core"]\n');
485
+ await workspace.write('packages/ferris/crates/ferris-core/Cargo.toml', '[package]\nname = "ferris-core"\n');
486
+
487
+ const targets = await inferProjectTargets(workspace, 'packages/ferris/package.json');
488
+
489
+ // A clippy target dir is not an Nx output — restoring an 11 GiB build
490
+ // tree from a cache is worse than rebuilding it — so `clean` cannot find
491
+ // these through `outputs`. They are read back off the commands that
492
+ // write them, which is why a new `--target-dir` cannot be forgotten here.
493
+ expect(targets.clean?.executor).toBe('@smoothbricks/nx-plugin:clean-outputs');
494
+ expect(targets.clean?.cache).toBe(false);
495
+ expect(targets.clean?.options?.outputs).toEqual([
496
+ '{projectRoot}/dist',
497
+ '{workspaceRoot}/packages/ferris/target/cargo-lint',
498
+ '{workspaceRoot}/packages/ferris/target/cargo-lint-cross',
499
+ '{workspaceRoot}/packages/ferris/target/nextest',
500
+ ]);
501
+ } finally {
502
+ await workspace.cleanup();
503
+ }
504
+ });
505
+
450
506
  it('keeps Rust-only lint source-aware after migrating defaults without replacing mixed or custom lint', async () => {
451
507
  const workspace = await createWorkspace();
452
508
  const root = 'packages/ferris';
@@ -567,6 +623,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
567
623
  const rootProject = '@fixture/codebase';
568
624
  const rootFetch = { projects: [rootProject], target: 'cargo-fetch' };
569
625
  const rootCompile = { projects: [rootProject], target: 'cargo-test-compile' };
626
+ const rootArchive = { projects: [rootProject], target: 'cargo-test-archive' };
570
627
 
571
628
  expect(
572
629
  [...projects]
@@ -582,28 +639,22 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
582
639
  command: 'cargo --frozen test --workspace --no-run',
583
640
  cwd: '.',
584
641
  });
585
- expect(root['cargo-lint']?.dependsOn).toEqual([
586
- { projects: ['native'], target: 'cargo-lint-native-napi' },
587
- { projects: ['runtime'], target: 'cargo-lint-runtime-core' },
588
- { projects: ['wasm'], target: 'cargo-lint-runtime-wasm' },
642
+ expect(root['cargo-lint']?.options?.commands).toEqual([
643
+ 'cargo fmt --all --check',
644
+ 'cargo --frozen clippy --workspace --all-targets --target-dir target/cargo-lint -- -D warnings',
589
645
  ]);
646
+ expect(root['cargo-lint']?.dependsOn).toContain('cargo-fetch');
590
647
  expect(root['cargo-test']?.dependsOn).toHaveLength(5);
591
648
 
592
- expect(runtime['cargo-test-runtime-core-shard1']?.dependsOn).toEqual([
593
- rootFetch,
594
- { projects: ['native'], target: 'cargo-test-native-napi' },
595
- ]);
596
- expect(runtime['cargo-test-runtime-core-shard2']?.dependsOn).toEqual([
597
- rootFetch,
598
- 'cargo-test-runtime-core-shard1',
599
- ]);
600
- expect(runtime['cargo-test-runtime-core-exceptions']?.dependsOn).toEqual([
601
- rootFetch,
602
- 'cargo-test-runtime-core-shard2',
603
- ]);
649
+ // Root mode: every piece of every project hangs off the one root archive,
650
+ // in any order. The crate is selected by filterset alone — `-p` would
651
+ // re-resolve features, and there is nothing left to build anyway.
652
+ expect(runtime['cargo-test-runtime-core-shard1']?.dependsOn).toEqual([rootFetch, rootArchive]);
653
+ expect(runtime['cargo-test-runtime-core-shard2']?.dependsOn).toEqual([rootFetch, rootArchive]);
654
+ expect(runtime['cargo-test-runtime-core-exceptions']?.dependsOn).toEqual([rootFetch, rootArchive]);
604
655
  expect(runtime['cargo-test-runtime-core-shard1']?.options).toMatchObject({ cwd: '.' });
605
656
  expect(runtime['cargo-test-runtime-core-shard1']?.options?.command).toContain(
606
- 'nextest run --workspace -p runtime-core',
657
+ "nextest run --archive-file target/nextest/archive.tar.zst --workspace-remap . -E 'package(runtime-core)",
607
658
  );
608
659
  expect(native['cargo-test-native-napi']?.options?.command).toContain('--no-tests=pass');
609
660
  expect(runtime['cargo-test']?.dependsOn).toEqual([
@@ -611,16 +662,13 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
611
662
  'cargo-test-runtime-core-shard2',
612
663
  'cargo-test-runtime-core-exceptions',
613
664
  ]);
614
- expect(runtime['cargo-lint']?.dependsOn).toEqual(['cargo-lint-runtime-core']);
665
+ // A package owning crates validates through the root's one clippy verdict.
666
+ expect(runtime['cargo-lint']?.dependsOn).toEqual([{ projects: [rootProject], target: 'cargo-lint' }]);
615
667
  expect(runtime.lint?.dependsOn).toEqual(['cargo-lint']);
616
- expect(runtime['cargo-lint-runtime-core']?.dependsOn).toEqual([rootFetch]);
617
- expect(runtime['cargo-lint-runtime-core']?.options?.cwd).toBe('.');
668
+ expect(runtime['cargo-lint-runtime-core']).toBeUndefined();
618
669
  expect(runtime.clean).toBeUndefined();
619
670
 
620
- expect(wasm['cargo-test-runtime-wasm']?.dependsOn).toEqual([
621
- rootFetch,
622
- { projects: ['runtime'], target: 'cargo-test-runtime-core-exceptions' },
623
- ]);
671
+ expect(wasm['cargo-test-runtime-wasm']?.dependsOn).toEqual([rootFetch, rootArchive]);
624
672
  expect(wasm['cargo-wasm']?.options).toMatchObject({ cwd: '.' });
625
673
  expect(wasm['cargo-wasm']?.options?.commands).toContain(
626
674
  'cargo --frozen build --release --target wasm32-unknown-unknown --target-dir target/cargo-wasm -p runtime-wasm',
@@ -630,7 +678,9 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
630
678
  expect(wasm.build?.dependsOn).toContainEqual(rootCompile);
631
679
  expect(wasm.clean?.executor).toBe('@smoothbricks/nx-plugin:clean-outputs');
632
680
 
633
- expect(native['cargo-test-native-napi']?.dependsOn).toEqual([rootFetch, 'napi-debug']);
681
+ // The crate whose project also builds the debug cdylib keeps that edge:
682
+ // its tests load the artifact `napi-debug` writes into `target/debug`.
683
+ expect(native['cargo-test-native-napi']?.dependsOn).toEqual([rootFetch, rootArchive, 'napi-debug']);
634
684
  expect(native['napi-debug']?.dependsOn).toContainEqual(rootCompile);
635
685
  expect(native['napi-debug']?.options).toMatchObject({
636
686
  cwd: '.',
@@ -652,8 +702,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
652
702
  it('keeps root packages, nested workspaces and multiple owned crates in their own lint graph', async () => {
653
703
  const workspace = await createWorkspace();
654
704
  const declared: Record<string, TargetConfiguration> = {
655
- 'cargo-lint-alpha-core': { dependsOn: ['...', 'prepare-check'] },
656
- 'cargo-lint': { dependsOn: ['cargo-lint-alpha-core'] },
705
+ 'cargo-lint': { dependsOn: ['...', 'prepare-check'] },
657
706
  lint: { dependsOn: ['cargo-lint', 'custom-check'] },
658
707
  };
659
708
  try {
@@ -686,45 +735,49 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
686
735
  const group = projects.get('packages/group')?.targets ?? {};
687
736
  const inner = projects.get('nested')?.targets ?? {};
688
737
  const leaf = projects.get('nested/modules/leaf')?.targets ?? {};
689
- expect(outer['cargo-lint']?.dependsOn).toEqual([
690
- { projects: ['group'], target: 'cargo-lint-alpha-core' },
691
- { projects: ['group'], target: 'cargo-lint-beta-wasm' },
692
- 'cargo-lint-host-core',
693
- ]);
694
- expect(group['cargo-lint']?.dependsOn).toEqual(['cargo-lint-alpha-core', 'cargo-lint-beta-wasm']);
738
+ // Each cargo workspace root runs one clippy over all its members; the
739
+ // packages owning crates validate through that verdict.
740
+ expect(outer['cargo-lint']?.options).toMatchObject({
741
+ cwd: '.',
742
+ commands: [
743
+ 'cargo fmt --all --check',
744
+ 'cargo --frozen clippy --workspace --all-targets --target-dir target/cargo-lint -- -D warnings',
745
+ ],
746
+ });
747
+ expect(outer['cargo-lint']?.inputs).toEqual(
748
+ expect.arrayContaining([
749
+ '{projectRoot}/packages/group/crates/alpha/**/*',
750
+ '{projectRoot}/packages/group/crates/beta/**/*',
751
+ ]),
752
+ );
753
+ expect(group['cargo-lint']?.dependsOn).toEqual([{ projects: ['outer-root'], target: 'cargo-lint' }]);
695
754
  expect(group.build?.dependsOn).toEqual([
696
755
  '^build',
697
756
  { projects: ['outer-root'], target: 'cargo-test-compile' },
698
757
  'tsc-js',
699
758
  ]);
700
- expect(outer['cargo-lint-host-core']?.options?.commands).toEqual([
701
- 'cargo fmt -p host-core --check',
702
- 'cargo --frozen clippy -p host-core --all-targets --target-dir target/cargo-lint-host-core -- -D warnings',
703
- ]);
704
- expect(inner['cargo-lint']?.dependsOn).toEqual([
705
- 'cargo-lint-inner-host',
706
- { projects: ['inner-leaf-project'], target: 'cargo-lint-inner-leaf' },
707
- ]);
708
- expect(leaf['cargo-lint-inner-leaf']?.options).toMatchObject({
709
- cwd: 'nested',
710
- commands: [
711
- 'cargo fmt -p inner-leaf --check',
712
- 'cargo --frozen clippy -p inner-leaf --all-targets --target-dir target/cargo-lint-inner-leaf -- -D warnings',
713
- ],
714
- });
715
- expect(leaf['cargo-lint-inner-leaf']?.dependsOn).toEqual([{ projects: ['inner-root'], target: 'cargo-fetch' }]);
716
- expect(leaf['cargo-lint-inner-leaf']?.inputs).toContain('{workspaceRoot}/nested/modules/leaf/**/*');
717
- expect(leaf['cargo-lint-inner-leaf']?.inputs).not.toContain('{workspaceRoot}/packages/group/crates/alpha/**/*');
759
+ expect(outer['cargo-lint-host-core']).toBeUndefined();
760
+ expect(inner['cargo-lint']?.options).toMatchObject({ cwd: 'nested' });
761
+ expect(inner['cargo-lint']?.inputs).toContain('{projectRoot}/**/*');
762
+ expect(inner['cargo-lint']?.inputs).not.toContain('{workspaceRoot}/packages/group/crates/alpha/**/*');
763
+ expect(leaf['cargo-lint']?.dependsOn).toEqual([{ projects: ['inner-root'], target: 'cargo-lint' }]);
764
+ expect(leaf['cargo-lint-inner-leaf']).toBeUndefined();
718
765
  expect(leaf['cargo-test-inner-leaf']?.options?.cwd).toBe('nested');
719
766
  expect(inner['cargo-test-compile']?.options?.cwd).toBe('nested');
720
- expect(leaf['cargo-test-inner-leaf']?.configurations?.production?.command).toContain('--workspace --release');
721
- expect(resolveDeclaredOverInferred(group, declared, 'cargo-lint-alpha-core')).toMatchObject({
722
- executor: 'nx:run-commands',
767
+ expect(leaf['cargo-test-inner-leaf']?.dependsOn).toEqual([
768
+ { projects: ['inner-root'], target: 'cargo-fetch' },
769
+ { projects: ['inner-root'], target: 'cargo-test-archive' },
770
+ ]);
771
+ // The profile lives in the archive, so the runner's production
772
+ // configuration has nothing left to say.
773
+ expect(leaf['cargo-test-inner-leaf']?.configurations?.production).toEqual({});
774
+ expect(inner['cargo-test-archive']?.options?.cwd).toBe('nested');
775
+ expect(resolveDeclaredOverInferred(group, declared, 'cargo-lint')).toMatchObject({
776
+ executor: 'nx:noop',
723
777
  cache: true,
724
778
  outputs: [],
725
- dependsOn: [{ projects: ['outer-root'], target: 'cargo-fetch' }, 'prepare-check'],
779
+ dependsOn: [{ projects: ['outer-root'], target: 'cargo-lint' }, 'prepare-check'],
726
780
  });
727
- expect(resolveDeclaredOverInferred(group, declared, 'cargo-lint')?.dependsOn).toEqual(['cargo-lint-alpha-core']);
728
781
  expect(resolveDeclaredOverInferred(group, declared, 'lint')?.dependsOn).toEqual(['cargo-lint', 'custom-check']);
729
782
  } finally {
730
783
  await workspace.cleanup();
@@ -739,7 +792,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
739
792
  await workspace.write('crate/Cargo.toml', '[package]\nname = "cache-crate"\n');
740
793
  await workspace.write('cargo-home/config.toml', '[build]\njobs = 1\n');
741
794
  const targets = await inferProjectTargets(workspace, 'package.json');
742
- const runtimeCommands = (targets['cargo-lint-cache-crate']?.inputs ?? []).flatMap((input) =>
795
+ const runtimeCommands = (targets['cargo-lint']?.inputs ?? []).flatMap((input) =>
743
796
  typeof input !== 'string' && 'runtime' in input ? [input.runtime] : [],
744
797
  );
745
798
  const capture = async (extraEnv: Record<string, string>) =>
@@ -784,20 +837,20 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
784
837
 
785
838
  const targets = await inferProjectTargets(workspace, 'packages/ferris/package.json');
786
839
 
787
- // Scoped by filterset over a workspace build: one crate runs, and the
788
- // build stays the one cargo-test-compile already paid for.
840
+ // Scoped by filterset over one archived workspace build: exactly one
841
+ // crate runs, and no `-p` re-resolves its features.
789
842
  expect(cargoPackageSelection(String(targets['cargo-test-ferris-core']?.options?.command ?? ''))).toEqual({
790
- workspaceBuild: true,
843
+ archiveRun: true,
791
844
  packageFlags: [],
792
845
  filtered: ['ferris-core'],
793
846
  });
794
847
  expect(cargoPackageSelection(String(targets['cargo-test-ferris-wasm']?.options?.command ?? ''))).toEqual({
795
- workspaceBuild: true,
848
+ archiveRun: true,
796
849
  packageFlags: [],
797
850
  filtered: ['ferris-wasm'],
798
851
  });
799
- expect(targets['cargo-test-ferris-core']?.dependsOn).toEqual(['cargo-fetch', 'cargo-test-compile']);
800
- expect(targets['cargo-test-ferris-wasm']?.dependsOn).toEqual(['cargo-fetch', 'cargo-test-ferris-core']);
852
+ expect(targets['cargo-test-ferris-core']?.dependsOn).toEqual(['cargo-fetch', 'cargo-test-archive']);
853
+ expect(targets['cargo-test-ferris-wasm']?.dependsOn).toEqual(['cargo-fetch', 'cargo-test-archive']);
801
854
  expect(targets['cargo-test']?.dependsOn).toEqual(['cargo-test-ferris-core', 'cargo-test-ferris-wasm']);
802
855
  } finally {
803
856
  await workspace.cleanup();
@@ -1083,12 +1136,17 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
1083
1136
  },
1084
1137
  });
1085
1138
  expect(targets['cargo-test']?.dependsOn).toEqual(['cargo-test-cowshed-napi']);
1086
- // cargo-fetch survives the napi-debug re-route: the per-crate runner is
1087
- // itself a frozen cargo command, so its precondition is its own edge and
1088
- // not something it inherits from cargo-test-compile's position.
1089
- expect(targets['cargo-test-cowshed-napi']?.dependsOn).toEqual(['cargo-fetch', 'napi-debug']);
1139
+ // cargo-fetch survives the napi-debug edge: the per-crate runner is itself
1140
+ // a frozen cargo command, so its precondition is its own edge. It reads
1141
+ // the workspace archive and still waits for the debug cdylib its own
1142
+ // project builds, because its tests load that artifact from `target/`.
1143
+ expect(targets['cargo-test-cowshed-napi']?.dependsOn).toEqual([
1144
+ 'cargo-fetch',
1145
+ 'cargo-test-archive',
1146
+ 'napi-debug',
1147
+ ]);
1090
1148
  expect(targets['cargo-test-cowshed-napi']?.options?.command).toMatch(
1091
- /^cargo --frozen nextest run --workspace -E 'package\(cowshed-napi\)' --no-tests=pass --user-config-file none --config-file /,
1149
+ /^cargo --frozen nextest run --archive-file target\/nextest\/archive\.tar\.zst --workspace-remap \. -E 'package\(cowshed-napi\)' --no-tests=pass --user-config-file none --tool-config-file "smoo:\$PWD\/.*nextest\.toml"$/,
1092
1150
  );
1093
1151
  expect(targets['napi-test']).toMatchObject({
1094
1152
  executor: '@smoothbricks/nx-plugin:bounded-exec',
@@ -1167,7 +1225,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
1167
1225
  // An unsharded crate keeps the bare name and takes no --partition, so
1168
1226
  // declaring nothing is exactly the old single-target behaviour.
1169
1227
  expect(targets['cargo-test-small']?.options?.command).toMatch(
1170
- /nextest run --workspace -E 'package\(small\)' --no-tests=pass --user-config-file none/,
1228
+ /nextest run --archive-file target\/nextest\/archive\.tar\.zst --workspace-remap \. -E 'package\(small\)' --no-tests=pass --user-config-file none/,
1171
1229
  );
1172
1230
  // The shards partition the crate MINUS the classes nextest.toml singles
1173
1231
  // out, i of N. Those are lifted out because a test-group only holds
@@ -1180,22 +1238,22 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
1180
1238
  }
1181
1239
  for (const index of [1, 2, 3]) {
1182
1240
  expect(targets[`cargo-test-big-shard${index}`]?.options?.command).toContain(
1183
- `--workspace -E 'package(big) and not (${exceptional})' --partition hash:${index}/3 --no-tests=pass`,
1241
+ `-E 'package(big) and not (${exceptional})' --partition hash:${index}/3 --no-tests=pass`,
1184
1242
  );
1185
1243
  expect(targets[`cargo-test-big-shard${index}`]?.options?.timeoutMs).toBe(BOUNDED_TEST_TIMEOUT_MS);
1186
1244
  }
1187
1245
  // Exact complement of the shards' filterset, so the union is the crate.
1188
1246
  expect(targets['cargo-test-big-exceptions']?.options?.command).toContain(
1189
- `--workspace -E 'package(big) and (${exceptional})' --no-tests=pass`,
1247
+ `-E 'package(big) and (${exceptional})' --no-tests=pass`,
1190
1248
  );
1191
1249
  expect(targets['cargo-test-big-exceptions']?.options?.command).not.toContain('--partition');
1192
1250
  expect(targets['cargo-test-big-exceptions']?.options?.timeoutMs).toBe(BOUNDED_TEST_TIMEOUT_MS);
1193
1251
  // An unsharded crate needs no pin: its whole suite is already one run.
1194
1252
  expect(targets['cargo-test-small-exceptions']).toBeUndefined();
1195
1253
  expect(targets['cargo-test-big']).toBeUndefined();
1196
- // Every piece reaches the aggregate, and they chain rather than fan out:
1197
- // cargo flocks one target/, and chaining also stops the pinned group
1198
- // contending with a shard over a machine-wide resource.
1254
+ // Every piece reaches the aggregate, and they all hang off the one
1255
+ // archive: a run extracts binaries to its own temp directory and writes
1256
+ // nothing to cargo's flocked target/, so nothing is left to serialize.
1199
1257
  expect(targets['cargo-test']?.dependsOn).toEqual([
1200
1258
  'cargo-test-big-shard1',
1201
1259
  'cargo-test-big-shard2',
@@ -1203,11 +1261,15 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
1203
1261
  'cargo-test-big-exceptions',
1204
1262
  'cargo-test-small',
1205
1263
  ]);
1206
- expect(targets['cargo-test-big-shard1']?.dependsOn).toEqual(['cargo-fetch', 'cargo-test-compile']);
1207
- expect(targets['cargo-test-big-shard2']?.dependsOn).toEqual(['cargo-fetch', 'cargo-test-big-shard1']);
1208
- expect(targets['cargo-test-big-shard3']?.dependsOn).toEqual(['cargo-fetch', 'cargo-test-big-shard2']);
1209
- expect(targets['cargo-test-big-exceptions']?.dependsOn).toEqual(['cargo-fetch', 'cargo-test-big-shard3']);
1210
- expect(targets['cargo-test-small']?.dependsOn).toEqual(['cargo-fetch', 'cargo-test-big-exceptions']);
1264
+ for (const name of [
1265
+ 'cargo-test-big-shard1',
1266
+ 'cargo-test-big-shard2',
1267
+ 'cargo-test-big-shard3',
1268
+ 'cargo-test-big-exceptions',
1269
+ 'cargo-test-small',
1270
+ ]) {
1271
+ expect(targets[name]?.dependsOn).toEqual(['cargo-fetch', 'cargo-test-archive']);
1272
+ }
1211
1273
  // Pieces of one crate share its inputs: they are one suite, split only to
1212
1274
  // fit the bound, so any change to the crate invalidates all of them.
1213
1275
  expect(targets['cargo-test-big-shard2']?.inputs).toEqual(targets['cargo-test-big-shard1']?.inputs);
@@ -1464,16 +1526,17 @@ function resolveDeclaredOverInferred(
1464
1526
  * How a cargo test command is scoped to one crate, split into the three facts
1465
1527
  * that can independently go wrong.
1466
1528
  *
1467
- * `--workspace` must be present: it makes the build fingerprint-identical to
1468
- * `cargo-test-compile`'s, so the bounded run reuses those artifacts. Narrowing
1469
- * must come from the nextest filterset, which selects what RUNS without
1470
- * changing what is BUILT. `--package` narrows too, but it re-resolves that
1471
- * crate's features, diverges from the workspace build, and rebuilds inside the
1472
- * bounded window — 57.9s of a 120s budget on a hosted 3-core macOS runner — so
1473
- * its presence is a regression even though it selects the same tests.
1529
+ * `--archive-file` must be present: the runner executes binaries one workspace
1530
+ * `cargo nextest archive --workspace` already built, so a per-crate run cannot
1531
+ * compile anything. Narrowing comes from the nextest filterset, which selects
1532
+ * what RUNS. `--package` narrows too, but it re-resolves that crate's features,
1533
+ * which is a build — 57.9s of a 120s bounded budget on a hosted 3-core macOS
1534
+ * runner when the runners still built — so its presence is a regression even
1535
+ * though it selects the same tests. nextest rejects it outright beside
1536
+ * `--archive-file`, and this assertion says so before cargo does.
1474
1537
  */
1475
1538
  function cargoPackageSelection(command: string): {
1476
- workspaceBuild: boolean;
1539
+ archiveRun: boolean;
1477
1540
  packageFlags: string[];
1478
1541
  filtered: string[];
1479
1542
  } {
@@ -1488,7 +1551,7 @@ function cargoPackageSelection(command: string): {
1488
1551
  }
1489
1552
  }
1490
1553
  return {
1491
- workspaceBuild: tokens.includes('--workspace'),
1554
+ archiveRun: tokens.includes('--archive-file'),
1492
1555
  packageFlags,
1493
1556
  filtered: [...command.matchAll(/\bpackage\(([^)]+)\)/g)].flatMap((match) =>
1494
1557
  match[1] === undefined ? [] : [match[1]],