Skip to content

Commit 0492491

Browse files
authored
refactor(tests): split and improve snapshot test infrastructure (#99)
## Summary - Split `test_snapshots` into separate `plan_snapshots` (vite_task_plan) and `e2e_snapshots` (vite_task_bin) test suites - Move snapshots to per-fixture directories for better organization - Remove redundant task graph snapshots from e2e tests (now only in plan tests) - Rename test directories for clarity (`test_snapshots` → `e2e_snapshots`, `test_plan_snapshots` → `plan_snapshots`) - Disable libtest harness for both test suites (using custom `main()`) - Add stdin support for e2e test steps (allows `{ cmd = "...", stdin = "..." }` syntax) - Add CLI filter argument for running specific fixtures (`cargo test --test e2e_snapshots -- stdin`) ## Test plan - [x] `cargo test -p vite_task_bin --test e2e_snapshots` passes - [x] `cargo test -p vite_task_plan --test plan_snapshots` passes - [x] Filter argument works: `cargo test -p vite_task_bin --test e2e_snapshots -- stdin` 🤖 Generated with [Claude Code](https://claude.com/claude-code)
1 parent c9750b2 commit 0492491

File tree

155 files changed

+537
-1023
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

155 files changed

+537
-1023
lines changed

Cargo.lock

Lines changed: 10 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ vite_path = { path = "crates/vite_path" }
125125
vite_shell = { path = "crates/vite_shell" }
126126
vite_str = { path = "crates/vite_str" }
127127
vite_task = { path = "crates/vite_task" }
128+
vite_task_bin = { path = "crates/vite_task_bin" }
128129
vite_task_graph = { path = "crates/vite_task_graph" }
129130
vite_task_plan = { path = "crates/vite_task_plan" }
130131
vite_workspace = { path = "crates/vite_workspace" }

crates/fspy/tests/oxlint.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,38 @@ use std::{env::vars_os, ffi::OsString};
55
use fspy::{AccessMode, PathAccessIterable};
66
use test_log::test;
77

8-
/// Get the test_bins/.bin directory path
9-
fn test_bins_bin_dir() -> std::path::PathBuf {
8+
/// Get the packages/tools/.bin directory path
9+
fn tools_bin_dir() -> std::path::PathBuf {
1010
std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
1111
.parent()
1212
.unwrap()
13-
.join("vite_task_bin")
14-
.join("test_bins")
13+
.parent()
14+
.unwrap()
15+
.join("packages")
16+
.join("tools")
1517
.join("node_modules")
1618
.join(".bin")
1719
}
1820

19-
/// Find the oxlint executable in test_bins
21+
/// Find the oxlint executable in packages/tools
2022
fn find_oxlint() -> std::path::PathBuf {
21-
let test_bins_dir = test_bins_bin_dir();
22-
which::which_in("oxlint", Some(&test_bins_dir), std::env::current_dir().unwrap())
23-
.expect("oxlint not found in test_bins/node_modules/.bin")
23+
let tools_dir = tools_bin_dir();
24+
which::which_in("oxlint", Some(&tools_dir), std::env::current_dir().unwrap())
25+
.expect("oxlint not found in packages/tools/node_modules/.bin")
2426
}
2527

2628
async fn track_oxlint(dir: &std::path::Path, args: &[&str]) -> anyhow::Result<PathAccessIterable> {
2729
let oxlint_path = find_oxlint();
2830
let mut command = fspy::Command::new(&oxlint_path);
2931

30-
// Build PATH with test_bins/.bin prepended so oxlint can find tsgolint
31-
let test_bins_dir = test_bins_bin_dir();
32+
// Build PATH with packages/tools/.bin prepended so oxlint can find tsgolint
33+
let tools_dir = tools_bin_dir();
3234
let new_path = if let Some(existing_path) = std::env::var_os("PATH") {
33-
let mut paths = vec![test_bins_dir.as_os_str().to_owned()];
35+
let mut paths = vec![tools_dir.as_os_str().to_owned()];
3436
paths.extend(std::env::split_paths(&existing_path).map(|p| p.into_os_string()));
3537
std::env::join_paths(paths)?
3638
} else {
37-
OsString::from(&test_bins_dir)
39+
OsString::from(&tools_dir)
3840
};
3941

4042
command

crates/vite_task_bin/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ cow-utils = { workspace = true }
2727
insta = { workspace = true, features = ["glob", "json", "redactions", "filters", "ron"] }
2828
regex = { workspace = true }
2929
serde = { workspace = true, features = ["derive", "rc"] }
30-
serde_json = { workspace = true }
3130
tempfile = { workspace = true }
3231
toml = { workspace = true }
33-
vite_graph_ser = { workspace = true }
3432
vite_path = { workspace = true, features = ["absolute-redaction"] }
35-
vite_task_graph = { workspace = true }
3633
vite_workspace = { workspace = true }
37-
which = { workspace = true }
3834

3935
[lints]
4036
workspace = true
37+
38+
[[test]]
39+
name = "e2e_snapshots"
40+
harness = false

crates/vite_task_bin/test_bins/README.md

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 38 additions & 0 deletions

crates/vite_task_bin/tests/test_snapshots/fixtures/cache-disabled/package.json renamed to crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-disabled/package.json

File renamed without changes.

crates/vite_task_bin/tests/test_snapshots/fixtures/cache-disabled/snapshots.toml renamed to crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-disabled/snapshots.toml

File renamed without changes.

crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task with cache disabled@cache-disabled.snap renamed to crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-disabled/snapshots/task with cache disabled.snap

File renamed without changes.

crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task with cache enabled@cache-disabled.snap renamed to crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-disabled/snapshots/task with cache enabled.snap

File renamed without changes.

0 commit comments

Comments
 (0)