@smoothbricks/nx-plugin 0.4.5 → 0.4.7

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',
@@ -394,6 +395,16 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
394
395
  expect(targets[name]?.dependsOn).toContain('cargo-fetch');
395
396
  }
396
397
  expect(targets['cargo-sweep']?.dependsOn).toBeUndefined();
398
+ // The archive and the compile it stands for hash every crate's sources
399
+ // AND the outputs of the targets they depend on: generated crate inputs
400
+ // are gitignored, so a repository that had to restate `inputs` to add
401
+ // them replaced the crate union with the root's `default` and shipped a
402
+ // stale archive to every per-crate test.
403
+ for (const name of ['cargo-test-compile', 'cargo-test-archive', 'cargo-lint', CARGO_CROSS_LINT_TARGET]) {
404
+ const inputs = targets[name]?.inputs ?? [];
405
+ expect(inputs).toContainEqual({ dependentTasksOutputFiles: '**/*', transitive: false });
406
+ expect(inputs).toContain('{projectRoot}/crates/ferris-core/**/*');
407
+ }
397
408
  expect(targets['cargo-test-compile']?.executor).toBe('nx:run-commands');
398
409
  expect(targets['cargo-test-compile']?.cache).toBe(false);
399
410
  expect(targets['cargo-test-compile']?.outputs).toEqual([]);
@@ -403,15 +414,40 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
403
414
  });
404
415
  expect(targets['cargo-test']?.executor).toBe('nx:noop');
405
416
  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.
417
+ // One workspace compile, packed once. Every per-crate runner reads that
418
+ // archive, so the runners fan out instead of chaining: none of them
419
+ // builds, re-resolves features, or writes cargo's flocked `target/`.
420
+ expect(targets['cargo-test-archive']?.executor).toBe('nx:run-commands');
421
+ expect(targets['cargo-test-archive']?.cache).toBe(true);
422
+ expect(targets['cargo-test-archive']?.outputs).toEqual(['{projectRoot}/target/nextest/archive.tar.zst']);
423
+ expect(targets['cargo-test-archive']?.options).toMatchObject({ cwd: 'packages/ferris', parallel: false });
424
+ // nextest does not create the archive's parent directory and fails the
425
+ // whole build if it is missing (measured: "error writing to archive").
426
+ expect(targets['cargo-test-archive']?.options?.commands?.[0]).toBe('mkdir -p target/nextest');
427
+ // `--tool-config-file`, never `--config-file`: the plugin's settings must
428
+ // sit UNDER the repository's `.config/nextest.toml`, which is the only
429
+ // place an `archive.include` for a cdylib or fixture can be declared.
430
+ // `$PWD` because tool config paths must be absolute and an absolute path
431
+ // in the command text would split one cache entry per checkout.
432
+ expect(String(targets['cargo-test-archive']?.options?.commands?.[1])).toMatch(
433
+ /^cargo --frozen nextest archive --workspace --archive-file target\/nextest\/archive\.tar\.zst --user-config-file none --tool-config-file "smoo:\$PWD\/.*nextest\.toml"$/,
434
+ );
435
+ expect(targets['cargo-test-archive']?.inputs).toContain('{projectRoot}/.config/nextest.toml');
436
+ expect(String(targets['cargo-test-archive']?.configurations?.production?.commands?.[1])).toContain(
437
+ 'nextest archive --workspace --release --archive-file',
438
+ );
439
+ expect(targets['cargo-test-ferris-core']?.dependsOn).toEqual(['cargo-fetch', 'cargo-test-archive']);
440
+ expect(targets['cargo-test-ferris-wasm']?.dependsOn).toEqual(['cargo-fetch', 'cargo-test-archive']);
441
+ // The runner executes the archive's binaries and remaps the workspace
442
+ // root: without `--workspace-remap`, a restored archive hands tests the
443
+ // PRODUCING tree's absolute CARGO_MANIFEST_DIR (measured on a moved tree).
444
+ // `--workspace` is not merely redundant here, nextest rejects it with
445
+ // `--archive-file`.
412
446
  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 /,
447
+ /^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
448
  );
449
+ expect(targets['cargo-test-ferris-core']?.inputs).toContain('{projectRoot}/.config/nextest.toml');
450
+ expect(targets['cargo-test-ferris-core']?.configurations?.production).toEqual({});
415
451
  expect(targets['cargo-test-ferris-core']?.inputs).toEqual(
416
452
  expect.arrayContaining([
417
453
  '{projectRoot}/Cargo.toml',
@@ -420,16 +456,20 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
420
456
  ]),
421
457
  );
422
458
  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({
459
+ // One clippy for the workspace in one target dir: a per-crate closure
460
+ // compiled every shared dependency once per crate.
461
+ expect(targets['cargo-lint']?.options).toMatchObject({
425
462
  cwd: 'packages/ferris',
426
463
  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',
464
+ 'cargo fmt --all --check',
465
+ 'cargo --frozen clippy --workspace --all-targets --target-dir target/cargo-lint -- -D warnings',
429
466
  ],
430
467
  });
431
- expect(targets['cargo-lint-ferris-core']?.cache).toBe(true);
432
- expect(targets['cargo-lint-ferris-core']?.outputs).toEqual([]);
468
+ expect(targets['cargo-lint']?.cache).toBe(true);
469
+ expect(targets['cargo-lint']?.outputs).toEqual([]);
470
+ expect(targets['cargo-lint']?.inputs).toEqual(
471
+ expect.arrayContaining(['{projectRoot}/crates/ferris-core/**/*', '{projectRoot}/crates/ferris-wasm/**/*']),
472
+ );
433
473
  expect(targets.lint?.dependsOn).toEqual(['cargo-lint']);
434
474
  expect(targets[CARGO_CROSS_LINT_TARGET]?.options).toMatchObject({
435
475
  command: CARGO_CROSS_LINT_COMMAND,
@@ -447,6 +487,32 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
447
487
  }
448
488
  });
449
489
 
490
+ it('cleans every cargo directory its own commands write, including the ones caching refuses', async () => {
491
+ const workspace = await createWorkspace();
492
+ try {
493
+ await workspace.write('packages/ferris/package.json', '{"name":"ferris"}\n');
494
+ await workspace.write('packages/ferris/Cargo.toml', '[workspace]\nmembers = ["crates/ferris-core"]\n');
495
+ await workspace.write('packages/ferris/crates/ferris-core/Cargo.toml', '[package]\nname = "ferris-core"\n');
496
+
497
+ const targets = await inferProjectTargets(workspace, 'packages/ferris/package.json');
498
+
499
+ // A clippy target dir is not an Nx output — restoring an 11 GiB build
500
+ // tree from a cache is worse than rebuilding it — so `clean` cannot find
501
+ // these through `outputs`. They are read back off the commands that
502
+ // write them, which is why a new `--target-dir` cannot be forgotten here.
503
+ expect(targets.clean?.executor).toBe('@smoothbricks/nx-plugin:clean-outputs');
504
+ expect(targets.clean?.cache).toBe(false);
505
+ expect(targets.clean?.options?.outputs).toEqual([
506
+ '{projectRoot}/dist',
507
+ '{workspaceRoot}/packages/ferris/target/cargo-lint',
508
+ '{workspaceRoot}/packages/ferris/target/cargo-lint-cross',
509
+ '{workspaceRoot}/packages/ferris/target/nextest',
510
+ ]);
511
+ } finally {
512
+ await workspace.cleanup();
513
+ }
514
+ });
515
+
450
516
  it('keeps Rust-only lint source-aware after migrating defaults without replacing mixed or custom lint', async () => {
451
517
  const workspace = await createWorkspace();
452
518
  const root = 'packages/ferris';
@@ -567,6 +633,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
567
633
  const rootProject = '@fixture/codebase';
568
634
  const rootFetch = { projects: [rootProject], target: 'cargo-fetch' };
569
635
  const rootCompile = { projects: [rootProject], target: 'cargo-test-compile' };
636
+ const rootArchive = { projects: [rootProject], target: 'cargo-test-archive' };
570
637
 
571
638
  expect(
572
639
  [...projects]
@@ -582,28 +649,22 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
582
649
  command: 'cargo --frozen test --workspace --no-run',
583
650
  cwd: '.',
584
651
  });
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' },
652
+ expect(root['cargo-lint']?.options?.commands).toEqual([
653
+ 'cargo fmt --all --check',
654
+ 'cargo --frozen clippy --workspace --all-targets --target-dir target/cargo-lint -- -D warnings',
589
655
  ]);
656
+ expect(root['cargo-lint']?.dependsOn).toContain('cargo-fetch');
590
657
  expect(root['cargo-test']?.dependsOn).toHaveLength(5);
591
658
 
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
- ]);
659
+ // Root mode: every piece of every project hangs off the one root archive,
660
+ // in any order. The crate is selected by filterset alone — `-p` would
661
+ // re-resolve features, and there is nothing left to build anyway.
662
+ expect(runtime['cargo-test-runtime-core-shard1']?.dependsOn).toEqual([rootFetch, rootArchive]);
663
+ expect(runtime['cargo-test-runtime-core-shard2']?.dependsOn).toEqual([rootFetch, rootArchive]);
664
+ expect(runtime['cargo-test-runtime-core-exceptions']?.dependsOn).toEqual([rootFetch, rootArchive]);
604
665
  expect(runtime['cargo-test-runtime-core-shard1']?.options).toMatchObject({ cwd: '.' });
605
666
  expect(runtime['cargo-test-runtime-core-shard1']?.options?.command).toContain(
606
- 'nextest run --workspace -p runtime-core',
667
+ "nextest run --archive-file target/nextest/archive.tar.zst --workspace-remap . -E 'package(runtime-core)",
607
668
  );
608
669
  expect(native['cargo-test-native-napi']?.options?.command).toContain('--no-tests=pass');
609
670
  expect(runtime['cargo-test']?.dependsOn).toEqual([
@@ -611,16 +672,13 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
611
672
  'cargo-test-runtime-core-shard2',
612
673
  'cargo-test-runtime-core-exceptions',
613
674
  ]);
614
- expect(runtime['cargo-lint']?.dependsOn).toEqual(['cargo-lint-runtime-core']);
675
+ // A package owning crates validates through the root's one clippy verdict.
676
+ expect(runtime['cargo-lint']?.dependsOn).toEqual([{ projects: [rootProject], target: 'cargo-lint' }]);
615
677
  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('.');
678
+ expect(runtime['cargo-lint-runtime-core']).toBeUndefined();
618
679
  expect(runtime.clean).toBeUndefined();
619
680
 
620
- expect(wasm['cargo-test-runtime-wasm']?.dependsOn).toEqual([
621
- rootFetch,
622
- { projects: ['runtime'], target: 'cargo-test-runtime-core-exceptions' },
623
- ]);
681
+ expect(wasm['cargo-test-runtime-wasm']?.dependsOn).toEqual([rootFetch, rootArchive]);
624
682
  expect(wasm['cargo-wasm']?.options).toMatchObject({ cwd: '.' });
625
683
  expect(wasm['cargo-wasm']?.options?.commands).toContain(
626
684
  'cargo --frozen build --release --target wasm32-unknown-unknown --target-dir target/cargo-wasm -p runtime-wasm',
@@ -630,7 +688,9 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
630
688
  expect(wasm.build?.dependsOn).toContainEqual(rootCompile);
631
689
  expect(wasm.clean?.executor).toBe('@smoothbricks/nx-plugin:clean-outputs');
632
690
 
633
- expect(native['cargo-test-native-napi']?.dependsOn).toEqual([rootFetch, 'napi-debug']);
691
+ // The crate whose project also builds the debug cdylib keeps that edge:
692
+ // its tests load the artifact `napi-debug` writes into `target/debug`.
693
+ expect(native['cargo-test-native-napi']?.dependsOn).toEqual([rootFetch, rootArchive, 'napi-debug']);
634
694
  expect(native['napi-debug']?.dependsOn).toContainEqual(rootCompile);
635
695
  expect(native['napi-debug']?.options).toMatchObject({
636
696
  cwd: '.',
@@ -652,8 +712,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
652
712
  it('keeps root packages, nested workspaces and multiple owned crates in their own lint graph', async () => {
653
713
  const workspace = await createWorkspace();
654
714
  const declared: Record<string, TargetConfiguration> = {
655
- 'cargo-lint-alpha-core': { dependsOn: ['...', 'prepare-check'] },
656
- 'cargo-lint': { dependsOn: ['cargo-lint-alpha-core'] },
715
+ 'cargo-lint': { dependsOn: ['...', 'prepare-check'] },
657
716
  lint: { dependsOn: ['cargo-lint', 'custom-check'] },
658
717
  };
659
718
  try {
@@ -686,45 +745,49 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
686
745
  const group = projects.get('packages/group')?.targets ?? {};
687
746
  const inner = projects.get('nested')?.targets ?? {};
688
747
  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']);
748
+ // Each cargo workspace root runs one clippy over all its members; the
749
+ // packages owning crates validate through that verdict.
750
+ expect(outer['cargo-lint']?.options).toMatchObject({
751
+ cwd: '.',
752
+ commands: [
753
+ 'cargo fmt --all --check',
754
+ 'cargo --frozen clippy --workspace --all-targets --target-dir target/cargo-lint -- -D warnings',
755
+ ],
756
+ });
757
+ expect(outer['cargo-lint']?.inputs).toEqual(
758
+ expect.arrayContaining([
759
+ '{projectRoot}/packages/group/crates/alpha/**/*',
760
+ '{projectRoot}/packages/group/crates/beta/**/*',
761
+ ]),
762
+ );
763
+ expect(group['cargo-lint']?.dependsOn).toEqual([{ projects: ['outer-root'], target: 'cargo-lint' }]);
695
764
  expect(group.build?.dependsOn).toEqual([
696
765
  '^build',
697
766
  { projects: ['outer-root'], target: 'cargo-test-compile' },
698
767
  'tsc-js',
699
768
  ]);
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/**/*');
769
+ expect(outer['cargo-lint-host-core']).toBeUndefined();
770
+ expect(inner['cargo-lint']?.options).toMatchObject({ cwd: 'nested' });
771
+ expect(inner['cargo-lint']?.inputs).toContain('{projectRoot}/**/*');
772
+ expect(inner['cargo-lint']?.inputs).not.toContain('{workspaceRoot}/packages/group/crates/alpha/**/*');
773
+ expect(leaf['cargo-lint']?.dependsOn).toEqual([{ projects: ['inner-root'], target: 'cargo-lint' }]);
774
+ expect(leaf['cargo-lint-inner-leaf']).toBeUndefined();
718
775
  expect(leaf['cargo-test-inner-leaf']?.options?.cwd).toBe('nested');
719
776
  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',
777
+ expect(leaf['cargo-test-inner-leaf']?.dependsOn).toEqual([
778
+ { projects: ['inner-root'], target: 'cargo-fetch' },
779
+ { projects: ['inner-root'], target: 'cargo-test-archive' },
780
+ ]);
781
+ // The profile lives in the archive, so the runner's production
782
+ // configuration has nothing left to say.
783
+ expect(leaf['cargo-test-inner-leaf']?.configurations?.production).toEqual({});
784
+ expect(inner['cargo-test-archive']?.options?.cwd).toBe('nested');
785
+ expect(resolveDeclaredOverInferred(group, declared, 'cargo-lint')).toMatchObject({
786
+ executor: 'nx:noop',
723
787
  cache: true,
724
788
  outputs: [],
725
- dependsOn: [{ projects: ['outer-root'], target: 'cargo-fetch' }, 'prepare-check'],
789
+ dependsOn: [{ projects: ['outer-root'], target: 'cargo-lint' }, 'prepare-check'],
726
790
  });
727
- expect(resolveDeclaredOverInferred(group, declared, 'cargo-lint')?.dependsOn).toEqual(['cargo-lint-alpha-core']);
728
791
  expect(resolveDeclaredOverInferred(group, declared, 'lint')?.dependsOn).toEqual(['cargo-lint', 'custom-check']);
729
792
  } finally {
730
793
  await workspace.cleanup();
@@ -739,7 +802,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
739
802
  await workspace.write('crate/Cargo.toml', '[package]\nname = "cache-crate"\n');
740
803
  await workspace.write('cargo-home/config.toml', '[build]\njobs = 1\n');
741
804
  const targets = await inferProjectTargets(workspace, 'package.json');
742
- const runtimeCommands = (targets['cargo-lint-cache-crate']?.inputs ?? []).flatMap((input) =>
805
+ const runtimeCommands = (targets['cargo-lint']?.inputs ?? []).flatMap((input) =>
743
806
  typeof input !== 'string' && 'runtime' in input ? [input.runtime] : [],
744
807
  );
745
808
  const capture = async (extraEnv: Record<string, string>) =>
@@ -784,20 +847,20 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
784
847
 
785
848
  const targets = await inferProjectTargets(workspace, 'packages/ferris/package.json');
786
849
 
787
- // Scoped by filterset over a workspace build: one crate runs, and the
788
- // build stays the one cargo-test-compile already paid for.
850
+ // Scoped by filterset over one archived workspace build: exactly one
851
+ // crate runs, and no `-p` re-resolves its features.
789
852
  expect(cargoPackageSelection(String(targets['cargo-test-ferris-core']?.options?.command ?? ''))).toEqual({
790
- workspaceBuild: true,
853
+ archiveRun: true,
791
854
  packageFlags: [],
792
855
  filtered: ['ferris-core'],
793
856
  });
794
857
  expect(cargoPackageSelection(String(targets['cargo-test-ferris-wasm']?.options?.command ?? ''))).toEqual({
795
- workspaceBuild: true,
858
+ archiveRun: true,
796
859
  packageFlags: [],
797
860
  filtered: ['ferris-wasm'],
798
861
  });
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']);
862
+ expect(targets['cargo-test-ferris-core']?.dependsOn).toEqual(['cargo-fetch', 'cargo-test-archive']);
863
+ expect(targets['cargo-test-ferris-wasm']?.dependsOn).toEqual(['cargo-fetch', 'cargo-test-archive']);
801
864
  expect(targets['cargo-test']?.dependsOn).toEqual(['cargo-test-ferris-core', 'cargo-test-ferris-wasm']);
802
865
  } finally {
803
866
  await workspace.cleanup();
@@ -1083,12 +1146,17 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
1083
1146
  },
1084
1147
  });
1085
1148
  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']);
1149
+ // cargo-fetch survives the napi-debug edge: the per-crate runner is itself
1150
+ // a frozen cargo command, so its precondition is its own edge. It reads
1151
+ // the workspace archive and still waits for the debug cdylib its own
1152
+ // project builds, because its tests load that artifact from `target/`.
1153
+ expect(targets['cargo-test-cowshed-napi']?.dependsOn).toEqual([
1154
+ 'cargo-fetch',
1155
+ 'cargo-test-archive',
1156
+ 'napi-debug',
1157
+ ]);
1090
1158
  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 /,
1159
+ /^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
1160
  );
1093
1161
  expect(targets['napi-test']).toMatchObject({
1094
1162
  executor: '@smoothbricks/nx-plugin:bounded-exec',
@@ -1167,7 +1235,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
1167
1235
  // An unsharded crate keeps the bare name and takes no --partition, so
1168
1236
  // declaring nothing is exactly the old single-target behaviour.
1169
1237
  expect(targets['cargo-test-small']?.options?.command).toMatch(
1170
- /nextest run --workspace -E 'package\(small\)' --no-tests=pass --user-config-file none/,
1238
+ /nextest run --archive-file target\/nextest\/archive\.tar\.zst --workspace-remap \. -E 'package\(small\)' --no-tests=pass --user-config-file none/,
1171
1239
  );
1172
1240
  // The shards partition the crate MINUS the classes nextest.toml singles
1173
1241
  // out, i of N. Those are lifted out because a test-group only holds
@@ -1180,22 +1248,22 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
1180
1248
  }
1181
1249
  for (const index of [1, 2, 3]) {
1182
1250
  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`,
1251
+ `-E 'package(big) and not (${exceptional})' --partition hash:${index}/3 --no-tests=pass`,
1184
1252
  );
1185
1253
  expect(targets[`cargo-test-big-shard${index}`]?.options?.timeoutMs).toBe(BOUNDED_TEST_TIMEOUT_MS);
1186
1254
  }
1187
1255
  // Exact complement of the shards' filterset, so the union is the crate.
1188
1256
  expect(targets['cargo-test-big-exceptions']?.options?.command).toContain(
1189
- `--workspace -E 'package(big) and (${exceptional})' --no-tests=pass`,
1257
+ `-E 'package(big) and (${exceptional})' --no-tests=pass`,
1190
1258
  );
1191
1259
  expect(targets['cargo-test-big-exceptions']?.options?.command).not.toContain('--partition');
1192
1260
  expect(targets['cargo-test-big-exceptions']?.options?.timeoutMs).toBe(BOUNDED_TEST_TIMEOUT_MS);
1193
1261
  // An unsharded crate needs no pin: its whole suite is already one run.
1194
1262
  expect(targets['cargo-test-small-exceptions']).toBeUndefined();
1195
1263
  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.
1264
+ // Every piece reaches the aggregate, and they all hang off the one
1265
+ // archive: a run extracts binaries to its own temp directory and writes
1266
+ // nothing to cargo's flocked target/, so nothing is left to serialize.
1199
1267
  expect(targets['cargo-test']?.dependsOn).toEqual([
1200
1268
  'cargo-test-big-shard1',
1201
1269
  'cargo-test-big-shard2',
@@ -1203,11 +1271,15 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
1203
1271
  'cargo-test-big-exceptions',
1204
1272
  'cargo-test-small',
1205
1273
  ]);
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']);
1274
+ for (const name of [
1275
+ 'cargo-test-big-shard1',
1276
+ 'cargo-test-big-shard2',
1277
+ 'cargo-test-big-shard3',
1278
+ 'cargo-test-big-exceptions',
1279
+ 'cargo-test-small',
1280
+ ]) {
1281
+ expect(targets[name]?.dependsOn).toEqual(['cargo-fetch', 'cargo-test-archive']);
1282
+ }
1211
1283
  // Pieces of one crate share its inputs: they are one suite, split only to
1212
1284
  // fit the bound, so any change to the crate invalidates all of them.
1213
1285
  expect(targets['cargo-test-big-shard2']?.inputs).toEqual(targets['cargo-test-big-shard1']?.inputs);
@@ -1464,16 +1536,17 @@ function resolveDeclaredOverInferred(
1464
1536
  * How a cargo test command is scoped to one crate, split into the three facts
1465
1537
  * that can independently go wrong.
1466
1538
  *
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.
1539
+ * `--archive-file` must be present: the runner executes binaries one workspace
1540
+ * `cargo nextest archive --workspace` already built, so a per-crate run cannot
1541
+ * compile anything. Narrowing comes from the nextest filterset, which selects
1542
+ * what RUNS. `--package` narrows too, but it re-resolves that crate's features,
1543
+ * which is a build — 57.9s of a 120s bounded budget on a hosted 3-core macOS
1544
+ * runner when the runners still built — so its presence is a regression even
1545
+ * though it selects the same tests. nextest rejects it outright beside
1546
+ * `--archive-file`, and this assertion says so before cargo does.
1474
1547
  */
1475
1548
  function cargoPackageSelection(command: string): {
1476
- workspaceBuild: boolean;
1549
+ archiveRun: boolean;
1477
1550
  packageFlags: string[];
1478
1551
  filtered: string[];
1479
1552
  } {
@@ -1488,7 +1561,7 @@ function cargoPackageSelection(command: string): {
1488
1561
  }
1489
1562
  }
1490
1563
  return {
1491
- workspaceBuild: tokens.includes('--workspace'),
1564
+ archiveRun: tokens.includes('--archive-file'),
1492
1565
  packageFlags,
1493
1566
  filtered: [...command.matchAll(/\bpackage\(([^)]+)\)/g)].flatMap((match) =>
1494
1567
  match[1] === undefined ? [] : [match[1]],