Skip to content

Commit 19c3b1f

Browse files
branchseerclaude
andcommitted
Make vite_task_tools a library crate with vtt binary in vite_task_bin
vtt needs to be built alongside vt for tests, so keep the [[bin]] entry in vite_task_bin with a thin wrapper that calls vite_task_tools::main(). This ensures CARGO_BIN_EXE_vtt is available in e2e tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f99ac17 commit 19c3b1f

File tree

7 files changed

+13
-18
lines changed

7 files changed

+13
-18
lines changed

Cargo.lock

Lines changed: 1 addition & 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
@@ -147,6 +147,7 @@ vite_task = { path = "crates/vite_task" }
147147
vite_task_bin = { path = "crates/vite_task_bin" }
148148
vite_task_graph = { path = "crates/vite_task_graph" }
149149
vite_task_plan = { path = "crates/vite_task_plan" }
150+
vite_task_tools = { path = "crates/vite_task_tools" }
150151
vite_workspace = { path = "crates/vite_workspace" }
151152
vt100 = "0.16.2"
152153
wax = "0.7.0"

crates/vite_task_bin/Cargo.toml

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

13+
[[bin]]
14+
name = "vtt"
15+
path = "src/vtt.rs"
16+
1317
[dependencies]
1418
anyhow = { workspace = true }
1519
async-trait = { workspace = true }
@@ -21,6 +25,7 @@ tokio = { workspace = true, features = ["full"] }
2125
vite_path = { workspace = true }
2226
vite_str = { workspace = true }
2327
vite_task = { workspace = true }
28+
vite_task_tools = { workspace = true }
2429
which = { workspace = true }
2530

2631
[dev-dependencies]

crates/vite_task_bin/src/vtt.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
vite_task_tools::main();
3+
}

crates/vite_task_bin/tests/e2e_snapshots/main.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ 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+
const COMPILE_TIME_VTT_PATH: &str = env!("CARGO_BIN_EXE_vtt");
2930
const COMPILE_TIME_MANIFEST_DIR: &str = env!("CARGO_MANIFEST_DIR");
3031

3132
/// Get the shell executable for running e2e test steps.
@@ -92,18 +93,6 @@ fn resolve_runtime_bin_path(compile_time_bin_path: &str) -> AbsolutePathBuf {
9293
AbsolutePathBuf::new(runtime_bin).unwrap()
9394
}
9495

95-
/// Derive the compile-time path of `vtt` from the compile-time path of `vt`.
96-
/// Both binaries are workspace binaries built into the same target directory.
97-
#[expect(
98-
clippy::disallowed_types,
99-
reason = "Path/String required for compile-time binary path derivation"
100-
)]
101-
fn compile_time_vtt_path() -> std::string::String {
102-
let vt = std::path::Path::new(COMPILE_TIME_VT_PATH);
103-
let vtt_name = if cfg!(windows) { "vtt.exe" } else { "vtt" };
104-
vt.with_file_name(vtt_name).to_str().unwrap().to_owned()
105-
}
106-
10796
#[derive(serde::Deserialize, Debug)]
10897
#[serde(untagged)]
10998
enum Step {
@@ -282,7 +271,7 @@ fn run_case_inner(tmpdir: &AbsolutePath, fixture_path: &std::path::Path, fixture
282271
let shell_exe = get_shell_exe();
283272

284273
// Prepare PATH for e2e tests: include vt and vtt binary directories.
285-
let bin_dirs: [Arc<OsStr>; 2] = [COMPILE_TIME_VT_PATH, &compile_time_vtt_path()].map(|p| {
274+
let bin_dirs: [Arc<OsStr>; 2] = [COMPILE_TIME_VT_PATH, COMPILE_TIME_VTT_PATH].map(|p| {
286275
let bin = resolve_runtime_bin_path(p);
287276
Arc::<OsStr>::from(bin.parent().unwrap().as_path().as_os_str())
288277
});

crates/vite_task_tools/Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ license.workspace = true
77
publish = false
88
rust-version.workspace = true
99

10-
[[bin]]
11-
name = "vtt"
12-
path = "src/main.rs"
13-
1410
[dependencies]
1511
json-patch = { workspace = true }
1612
serde_json = { workspace = true }
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#![expect(clippy::print_stderr, reason = "CLI tool error output")]
66
#![expect(clippy::print_stdout, reason = "CLI tool output")]
77

8-
fn main() {
8+
pub fn main() {
99
let args: Vec<String> = std::env::args().collect();
1010
if args.len() < 2 {
1111
eprintln!("Usage: vtt <subcommand> [args...]");

0 commit comments

Comments
 (0)