Skip to content

Commit 3ced295

Browse files
branchseerclaude
andcommitted
test: add e2e test for negative input globs in subpackages
Demonstrates a bug where negative input globs (like !dist/**) are matched against workspace-relative paths instead of package-relative paths, causing exclusions to fail for subpackages. The snapshot captures the buggy behavior (cache miss instead of expected hit). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 75c9a75 commit 3ced295

File tree

8 files changed

+77
-0
lines changed

8 files changed

+77
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "inputs-negative-glob-subpackage",
3+
"private": true
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "sub-pkg",
3+
"private": true
4+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const main = 'initial';
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"tasks": {
3+
"auto-with-negative": {
4+
"command": "print-file src/main.ts dist/output.js",
5+
"inputs": [{ "auto": true }, "!dist/**"],
6+
"cache": true
7+
}
8+
}
9+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
packages:
2+
- 'packages/*'
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Test that negative input globs work correctly for subpackages.
2+
# Bug: negative globs were matched against workspace-relative paths
3+
# instead of package-relative paths, so exclusions like !dist/**
4+
# failed for subpackages.
5+
6+
# Auto + negative in subpackage: inputs: [{ "auto": true }, "!dist/**"]
7+
# - dist/ should be excluded even though the package is a subpackage
8+
# - Modifying dist/output.js should be a cache hit
9+
[[e2e]]
10+
name = "subpackage auto with negative - hit on excluded inferred file"
11+
steps = [
12+
# First run - reads both src/main.ts and dist/output.js
13+
"vp run sub-pkg#auto-with-negative",
14+
# Modify file in excluded directory (dist/)
15+
"replace-file-content packages/sub-pkg/dist/output.js initial modified",
16+
# Cache hit: dist/ is excluded by negative glob
17+
"vp run sub-pkg#auto-with-negative",
18+
]
19+
20+
[[e2e]]
21+
name = "subpackage auto with negative - miss on non-excluded inferred file"
22+
steps = [
23+
# First run
24+
"vp run sub-pkg#auto-with-negative",
25+
# Modify file NOT in excluded directory
26+
"replace-file-content packages/sub-pkg/src/main.ts initial modified",
27+
# Cache miss: inferred input changed
28+
"vp run sub-pkg#auto-with-negative",
29+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
source: crates/vite_task_bin/tests/e2e_snapshots/main.rs
3+
expression: e2e_outputs
4+
---
5+
> vp run sub-pkg#auto-with-negative
6+
~/packages/sub-pkg$ print-file src/main.ts dist/output.js
7+
export const main = 'initial';
8+
// initial output
9+
> replace-file-content packages/sub-pkg/dist/output.js initial modified
10+
11+
> vp run sub-pkg#auto-with-negative
12+
~/packages/sub-pkg$ print-file src/main.ts dist/output.jscache miss: content of input 'packages/sub-pkg/dist/output.js' changed, executing
13+
export const main = 'initial';
14+
// modified output
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
source: crates/vite_task_bin/tests/e2e_snapshots/main.rs
3+
expression: e2e_outputs
4+
---
5+
> vp run sub-pkg#auto-with-negative
6+
~/packages/sub-pkg$ print-file src/main.ts dist/output.js
7+
export const main = 'initial';
8+
// initial output
9+
> replace-file-content packages/sub-pkg/src/main.ts initial modified
10+
11+
> vp run sub-pkg#auto-with-negative
12+
~/packages/sub-pkg$ print-file src/main.ts dist/output.jscache miss: content of input 'packages/sub-pkg/src/main.ts' changed, executing
13+
export const main = 'modified';
14+
// initial output

0 commit comments

Comments
 (0)