Skip to content

Commit 6f6ba6f

Browse files
authored
test: execute steps using @yarnpkg/shell (#292)
### What changed? - Removed `2>&1` redirections from test commands as we can capture stdout/stderr stably. - Update snapshots with stdout/stderr interleaved. - Refactored the snap test runner to use `@yarnpkg/shell` ### Why make this change? To get prepared to run on Windows
1 parent 3cc727b commit 6f6ba6f

13 files changed

Lines changed: 270 additions & 70 deletions

File tree

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

mise.toml

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/cli/snap-tests/command-doc/snap.txt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,21 @@
22

33
vitepress v<semver>
44

5-
build complete in <variable>ms.
6-
7-
85
- building client + server bundles...
96
✓ building client + server bundles...
107
- rendering pages...
118
✓ rendering pages...
9+
build complete in <variable>ms.
10+
1211

1312
> vite doc build # build documentation again should hit the cache
1413
✓ cache hit, replaying
1514

1615
vitepress v<semver>
1716

18-
build complete in <variable>ms.
19-
20-
2117
- building client + server bundles...
2218
✓ building client + server bundles...
2319
- rendering pages...
2420
✓ rendering pages...
21+
build complete in <variable>ms.
22+

packages/cli/snap-tests/replay-logs-chronological-order/snap.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
> vite run build 2>&1 # initial run, create the cache
1+
> vite run build # initial run, create the cache
22
$ node build.js
33
[build.js] --------------------------------
44
[build.js] start
@@ -108,7 +108,7 @@ Task Details:
108108
→ Cache miss: no previous cache entry found
109109
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
110110

111-
> vite run build 2>&1 # should hit the cache
111+
> vite run build # should hit the cache
112112
$ node build.js (✓ cache hit, replaying)
113113
[build.js] --------------------------------
114114
[build.js] start
@@ -218,7 +218,7 @@ Task Details:
218218
→ Cache hit - output replayed - <variable>ms saved
219219
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
220220

221-
> vite run build 2>&1 # should hit the cache and make sure the replay order is chronological
221+
> vite run build # should hit the cache and make sure the replay order is chronological
222222
$ node build.js (✓ cache hit, replaying)
223223
[build.js] --------------------------------
224224
[build.js] start
@@ -328,7 +328,7 @@ Task Details:
328328
→ Cache hit - output replayed - <variable>ms saved
329329
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
330330

331-
> vite run build 2>&1 # should hit the cache and make sure the replay order is chronological again
331+
> vite run build # should hit the cache and make sure the replay order is chronological again
332332
$ node build.js (✓ cache hit, replaying)
333333
[build.js] --------------------------------
334334
[build.js] start
@@ -438,7 +438,7 @@ Task Details:
438438
→ Cache hit - output replayed - <variable>ms saved
439439
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
440440

441-
> vite run build 2>&1 # should hit the cache and make sure the replay order is chronological again
441+
> vite run build # should hit the cache and make sure the replay order is chronological again
442442
$ node build.js (✓ cache hit, replaying)
443443
[build.js] --------------------------------
444444
[build.js] start

packages/cli/snap-tests/replay-logs-chronological-order/steps.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"VITE_DISABLE_AUTO_INSTALL": "1"
44
},
55
"commands": [
6-
"vite run build 2>&1 # initial run, create the cache",
7-
"vite run build 2>&1 # should hit the cache",
8-
"vite run build 2>&1 # should hit the cache and make sure the replay order is chronological",
9-
"vite run build 2>&1 # should hit the cache and make sure the replay order is chronological again",
10-
"vite run build 2>&1 # should hit the cache and make sure the replay order is chronological again"
6+
"vite run build # initial run, create the cache",
7+
"vite run build # should hit the cache",
8+
"vite run build # should hit the cache and make sure the replay order is chronological",
9+
"vite run build # should hit the cache and make sure the replay order is chronological again",
10+
"vite run build # should hit the cache and make sure the replay order is chronological again"
1111
]
1212
}

packages/global/snap-tests/command-add-pnpm9-with-workspace/snap.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,12 @@ packages:
145145

146146
[1]> vp add --filter app test-vite-plus-package-optional --save-catalog-name v1 # should error because save-catalog-name is not supported at pnpm@9
147147
Running: pnpm --filter app add --save-catalog-name=v1 test-vite-plus-package-optional
148-
149148
 ERROR  Unknown option: 'save-catalog-name'
150149
Did you mean 'save-optional'? Use "--config.unknown=value" to force an unknown option.
151150
For help, run: pnpm help add
152151

153152
[1]> vp add --filter=./packages/utils test-vite-plus-package-optional -O --save-catalog v2 # should error because save-catalog is not supported at pnpm@9
154153
Running: pnpm --filter ./packages/utils add --save-optional --save-catalog test-vite-plus-package-optional v2
155-
156154
 ERROR  Unknown option: 'save-catalog'
157155
Did you mean 'save-exact', or 'save-prod'? Use "--config.unknown=value" to force an unknown option.
158156
For help, run: pnpm help add

packages/global/snap-tests/command-add-pnpm9/snap.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ Done in <variable>ms using pnpm v<semver>
7878

7979
[1]> vp add testnpm2 test-vite-plus-install --allow-build=test-vite-plus-install # should error because allow-build is not supported at pnpm@9
8080
Running: pnpm add --allow-build=test-vite-plus-install testnpm2 test-vite-plus-install
81-
8281
 ERROR  Unknown option: 'allow-build'
8382
For help, run: pnpm help add
8483

packages/global/snap-tests/command-update-npm10-with-workspace/snap.txt

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ up to date in <variable>ms
3232

3333
> vp up -D --filter app -- --no-audit && cat packages/app/package.json # should update dev dependencies in app
3434
Running: npm update --workspace app --include=dev --no-audit
35+
npm warn workspaces app in filter set, but no workspace folder present
3536

3637
up to date in <variable>ms
3738
{
@@ -45,10 +46,10 @@ up to date in <variable>ms
4546
}
4647
}
4748

48-
npm warn workspaces app in filter set, but no workspace folder present
49-
5049
> vp update --filter "*" -- --no-audit && cat packages/app/package.json packages/utils/package.json # should update in all packages
5150
Running: npm update --workspace * --no-audit
51+
npm warn workspaces app in filter set, but no workspace folder present
52+
npm warn workspaces @vite-plus-test/utils in filter set, but no workspace folder present
5253

5354
up to date in <variable>ms
5455
{
@@ -69,11 +70,10 @@ up to date in <variable>ms
6970
}
7071
}
7172

72-
npm warn workspaces app in filter set, but no workspace folder present
73-
npm warn workspaces @vite-plus-test/utils in filter set, but no workspace folder present
74-
7573
> vp update -r --no-save -- --no-audit && cat package.json packages/app/package.json # should update recursively without saving
7674
Running: npm update --include-workspace-root --workspaces --no-save --no-audit
75+
npm warn workspaces app in filter set, but no workspace folder present
76+
npm warn workspaces @vite-plus-test/utils in filter set, but no workspace folder present
7777

7878
up to date in <variable>ms
7979
{
@@ -98,9 +98,6 @@ up to date in <variable>ms
9898
}
9999
}
100100

101-
npm warn workspaces app in filter set, but no workspace folder present
102-
npm warn workspaces @vite-plus-test/utils in filter set, but no workspace folder present
103-
104101
> vp update --workspace --filter app @vite-plus-test/utils -- --no-audit && cat packages/app/package.json # should update workspace dependency
105102
Running: npm update --workspace app --no-audit @vite-plus-test/utils
106103

packages/global/snap-tests/command-update-npm10/snap.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ Running: npm install --save-optional --no-audit testnpm2@<semver>
8484
added 1 package in <variable>ms
8585
Warning: npm doesn't support --latest flag. Updating within semver range only.
8686
Running: npm update --no-optional --no-audit
87+
npm warn config optional Use `--omit=optional` to exclude optional dependencies, or
88+
npm warn config `--include=optional` to include them.
89+
npm warn config
90+
npm warn config Default value does install optional deps unless otherwise omitted.
8791

8892
changed 1 package in <variable>ms
8993
{
@@ -99,11 +103,6 @@ changed 1 package in <variable>ms
99103
}
100104
}
101105

102-
npm warn config optional Use `--omit=optional` to exclude optional dependencies, or
103-
npm warn config `--include=optional` to include them.
104-
npm warn config
105-
npm warn config Default value does install optional deps unless otherwise omitted.
106-
107106
> vp update -- --no-audit && cat package.json # should update all packages but won't change the package.json
108107
Running: npm update --no-audit
109108

packages/tools/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@
99
"devDependencies": {
1010
"@oxc-node/cli": "catalog:",
1111
"@oxc-node/core": "catalog:",
12-
"@types/semver": "catalog:",
1312
"@std/yaml": "catalog:",
13+
"@types/semver": "catalog:",
1414
"minimatch": "catalog:",
1515
"semver": "catalog:"
1616
},
1717
"scripts": {
1818
"snap-test": "tool snap-test"
19+
},
20+
"dependencies": {
21+
"@yarnpkg/fslib": "catalog:",
22+
"@yarnpkg/shell": "catalog:"
1923
}
2024
}

0 commit comments

Comments
 (0)