Skip to content

Commit ebfb5f1

Browse files
committed
update
1 parent af92bc3 commit ebfb5f1

File tree

9 files changed

+53
-36
lines changed

9 files changed

+53
-36
lines changed

Cargo.lock

Lines changed: 7 additions & 0 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
@@ -146,6 +146,7 @@ vite_task = { path = "crates/vite_task" }
146146
vite_task_bin = { path = "crates/vite_task_bin" }
147147
vite_task_graph = { path = "crates/vite_task_graph" }
148148
vite_task_plan = { path = "crates/vite_task_plan" }
149+
vite_task_tools = { path = "crates/vite_task_tools" }
149150
vite_workspace = { path = "crates/vite_workspace" }
150151
vt100 = "0.16.2"
151152
wax = "0.7.0"

crates/vite_task_bin/Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ rust-version.workspace = true
1010
name = "vt"
1111
path = "src/main.rs"
1212

13-
[[bin]]
14-
name = "vtt"
15-
path = "src/vtt.rs"
16-
1713
[dependencies]
1814
anyhow = { workspace = true }
1915
async-trait = { workspace = true }

crates/vite_task_bin/tests/e2e_snapshots/main.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ const STEP_TIMEOUT: Duration =
2626
const SCREEN_SIZE: ScreenSize = ScreenSize { rows: 500, cols: 500 };
2727

2828
const COMPILE_TIME_VT_PATH: &str = env!("CARGO_BIN_EXE_vt");
29-
/// Ensures the `vtt` binary is built before running e2e tests (vtt is in the same directory as vt).
30-
const _: &str = env!("CARGO_BIN_EXE_vtt");
3129
const COMPILE_TIME_MANIFEST_DIR: &str = env!("CARGO_MANIFEST_DIR");
3230

3331
/// Get the shell executable for running e2e test steps.
@@ -269,8 +267,8 @@ fn run_case_inner(tmpdir: &AbsolutePath, fixture_path: &std::path::Path, fixture
269267
// Get shell executable for running steps
270268
let shell_exe = get_shell_exe();
271269

272-
// Prepare PATH for e2e tests: include vt and vtt binary directories.
273-
// Both vt and vtt are in the same target directory.
270+
// Prepare PATH for e2e tests: include vt binary directory (vtt is in the same directory
271+
// since all workspace binaries are built into the same target/<profile>/ directory).
274272
let e2e_env_path = join_paths(
275273
std::iter::once({
276274
let vt_path = resolve_runtime_bin_path(COMPILE_TIME_VT_PATH);

crates/vite_task_plan/tests/plan_snapshots/main.rs

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,22 @@ use vite_task_graph::display::TaskDisplay;
2121
use vite_task_plan::{ExecutionGraph, ExecutionItemKind};
2222
use vite_workspace::find_workspace_root;
2323

24+
/// Resolve the directory containing workspace binaries (vt, vtt) at runtime.
25+
/// Test binaries are in `target/<profile>/deps/`, while workspace binaries
26+
/// are in `target/<profile>/`. Go up from `deps/` to find them.
27+
fn resolve_runtime_bin_dir() -> AbsolutePathBuf {
28+
let current_exe = std::env::current_exe().unwrap();
29+
let deps_dir = current_exe.parent().unwrap();
30+
let bin_dir = deps_dir.parent().unwrap();
31+
let vtt_name = if cfg!(windows) { "vtt.exe" } else { "vtt" };
32+
assert!(
33+
bin_dir.join(vtt_name).exists(),
34+
"vtt binary not found at {}. Build it first with: cargo build --bin vtt",
35+
bin_dir.join(vtt_name).display(),
36+
);
37+
AbsolutePathBuf::new(bin_dir.to_path_buf()).unwrap()
38+
}
39+
2440
/// Local parser wrapper for `BuiltInCommand`
2541
#[derive(Parser)]
2642
#[command(name = "vt")]
@@ -216,21 +232,10 @@ fn run_case_inner(
216232
Err(err) => panic!("Failed to read cases.toml for fixture {fixture_name}: {err}"),
217233
};
218234

219-
// Locate the vtt binary directory. Since both plan_snapshots test and vtt are built
220-
// into the same Cargo target directory, we can find vtt next to the current test executable.
235+
// Locate the directory containing vt and vtt binaries.
221236
let test_bin_path = {
222-
let current_exe = std::env::current_exe().unwrap();
223-
// Test binaries are in target/<profile>/deps/, but workspace binaries (vtt)
224-
// are in target/<profile>/. Go up from deps/ to find vtt.
225-
let deps_dir = current_exe.parent().unwrap();
226-
let bin_dir = deps_dir.parent().unwrap();
227-
let vtt_name = if cfg!(windows) { "vtt.exe" } else { "vtt" };
228-
assert!(
229-
bin_dir.join(vtt_name).exists(),
230-
"vtt binary not found at {}. Build it first with: cargo build --bin vtt",
231-
bin_dir.join(vtt_name).display(),
232-
);
233-
Arc::<OsStr>::from(bin_dir.as_os_str())
237+
let bin_dir = resolve_runtime_bin_dir();
238+
Arc::<OsStr>::from(bin_dir.as_path().as_os_str())
234239
};
235240

236241
// Add vtt binary directory to PATH so test programs (such as vtt print-file) in fixtures can be found.

crates/vite_task_plan/tests/plan_snapshots/redact.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,9 @@ fn redact_string(s: &mut String, redactions: &[(&str, &str)]) {
6262

6363
pub fn redact_snapshot(value: &impl Serialize, workspace_root: &str) -> serde_json::Value {
6464
let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
65-
// Get the vtt binary directory path — vtt is in target/<profile>/,
66-
// while the test binary is in target/<profile>/deps/.
67-
let tools_dir = {
68-
let current_exe = std::env::current_exe().unwrap();
69-
// Test binaries are in target/<profile>/deps/, but workspace binaries (vtt)
70-
// are in target/<profile>/. Go up from deps/ to find the tools directory.
71-
current_exe.parent().unwrap().parent().unwrap().to_owned()
72-
};
73-
let tools_dir_str = tools_dir.to_str().unwrap().to_owned();
65+
// Get the vtt binary directory path at runtime.
66+
let tools_dir = super::resolve_runtime_bin_dir();
67+
let tools_dir_str = tools_dir.as_path().to_str().unwrap().to_owned();
7468
let mut json_value = serde_json::to_value(value).unwrap();
7569

7670
// On Windows, paths might use either backslashes or forward slashes

crates/vite_task_tools/Cargo.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[package]
2+
name = "vite_task_tools"
3+
version = "0.1.0"
4+
authors.workspace = true
5+
edition.workspace = true
6+
license.workspace = true
7+
publish = false
8+
rust-version.workspace = true
9+
10+
[[bin]]
11+
name = "vtt"
12+
path = "src/main.rs"
13+
14+
[dependencies]
15+
serde_json = { workspace = true }
16+
17+
[lints]
18+
workspace = true

crates/vite_task_tools/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# vite_task_tools
2+
3+
`vtt` (Vite Task Tools) — a lightweight test utility binary with subcommands used by e2e and plan snapshot tests.
Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
//! `vtt` — Vite Task Tools
2-
//!
3-
//! A lightweight test utility binary with subcommands used by e2e and plan snapshot tests.
4-
//! Replaces the Node.js tools previously in `packages/tools`.
5-
61
// This is a standalone test utility binary that deliberately uses std types
72
// rather than the project's custom types (vite_str, vite_path, etc.).
83
#![expect(clippy::disallowed_types, reason = "standalone test utility uses std types")]

0 commit comments

Comments
 (0)