Skip to content

Commit 7a73700

Browse files
committed
test(snapshot): migrate cwd-flag and app-root snap tests to the PTY harness
Moves the four old-harness fixtures added by this PR (command-cwd-flag, command-app-root-listing, command-default-package, command-default-package-missing) into crates/vite_cli_snapshots: - cwd_flag: -C vs cd byte-identical for pack and run, missing-dir error, positional entry-semantics parity, with vpt list-dir/rm assertions - app_root_listing: non-TTY dev listing joins the build step - app_root_default_package: dist assertion plus a missing-directory case via a nested non-workspace root Real pass/fail assertions and recorded exit codes replace the regenerate-and-diff model for these cases.
1 parent afa48fc commit 7a73700

35 files changed

Lines changed: 308 additions & 163 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "name": "missing-default", "private": true }

packages/cli/snap-tests/command-default-package-missing/vite.config.ts renamed to crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/missing/vite.config.ts

File renamed without changes.

crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots.toml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,13 @@ defaultPackage in the root config acts as an implicit -C for bare app
66
commands, including at a root that is not a JS workspace; vp prints a note
77
line and runs in the configured directory (rfcs/cwd-flag.md).
88
"""
9-
steps = [["vp", "pack"]]
9+
steps = [
10+
["vp", "pack"],
11+
{ argv = ["vpt", "list-dir", "packages/ui/dist"], comment = "output lands in the configured package" },
12+
]
13+
14+
[[case]]
15+
name = "default_package_missing"
16+
vp = ["local", "global"]
17+
comment = "defaultPackage pointing at a missing directory errors before any workspace lookup."
18+
steps = [{ argv = ["vp", "build"], cwd = "missing" }]

crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package.global.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,11 @@ note: vp pack: using ./packages/ui (defaultPackage)
1616
ℹ 1 files, total: 0.10 kB
1717
✔ Build complete in <duration>
1818
```
19+
20+
## `vpt list-dir packages/ui/dist`
21+
22+
output lands in the configured package
23+
24+
```
25+
index.mjs
26+
```

crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_default_package/snapshots/default_package.local.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,11 @@ note: vp pack: using ./packages/ui (defaultPackage)
1414
ℹ 1 files, total: 0.10 kB
1515
✔ Build complete in <duration>
1616
```
17+
18+
## `vpt list-dir packages/ui/dist`
19+
20+
output lands in the configured package
21+
22+
```
23+
index.mjs
24+
```
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# default_package_missing
2+
3+
defaultPackage pointing at a missing directory errors before any workspace lookup.
4+
5+
## `cd missing && vp build`
6+
7+
**Exit code:** 1
8+
9+
```
10+
VITE+ - The Unified Toolchain for the Web
11+
12+
error: defaultPackage points to a missing directory: ./packages/nope
13+
```
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# default_package_missing
2+
3+
defaultPackage pointing at a missing directory errors before any workspace lookup.
4+
5+
## `cd missing && vp build`
6+
7+
**Exit code:** 1
8+
9+
```
10+
error: defaultPackage points to a missing directory: ./packages/nope
11+
```

crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_listing/snapshots.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ A bare app command at a workspace root without an interactive terminal prints
66
the ranked package listing with -C hints and exits 1 instead of building the
77
root (rfcs/cwd-flag.md).
88
"""
9-
steps = [{ argv = ["vp", "build"], tty = false }]
9+
steps = [
10+
{ argv = ["vp", "build"], tty = false },
11+
{ argv = ["vp", "dev"], tty = false, comment = "dev at the root no longer starts a server against the root" },
12+
]
1013

1114
[[case]]
1215
name = "picker_select"

crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_listing/snapshots/listing.global.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,21 @@ root (rfcs/cwd-flag.md).
1919
Pass a directory: vp -C apps/admin build
2020
Or run every package's build script: vp run -r build
2121
```
22+
23+
## `vp dev`
24+
25+
dev at the root no longer starts a server against the root
26+
27+
**Exit code:** 1
28+
29+
```
30+
error: `vp dev` at the workspace root needs a target package.
31+
32+
Packages in this workspace:
33+
admin apps/admin
34+
web apps/web
35+
ui packages/ui
36+
37+
Pass a directory: vp -C apps/admin dev
38+
Or run every package's dev script: vp run -r dev
39+
```

crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_listing/snapshots/listing.local.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,21 @@ root (rfcs/cwd-flag.md).
1919
Pass a directory: vp -C apps/admin build
2020
Or run every package's build script: vp run -r build
2121
```
22+
23+
## `vp dev`
24+
25+
dev at the root no longer starts a server against the root
26+
27+
**Exit code:** 1
28+
29+
```
30+
error: `vp dev` at the workspace root needs a target package.
31+
32+
Packages in this workspace:
33+
admin apps/admin
34+
web apps/web
35+
ui packages/ui
36+
37+
Pass a directory: vp -C apps/admin dev
38+
Or run every package's dev script: vp run -r dev
39+
```

0 commit comments

Comments
 (0)