@@ -21,6 +21,22 @@ use vite_task_graph::display::TaskDisplay;
2121use vite_task_plan:: { ExecutionGraph , ExecutionItemKind } ;
2222use 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.
0 commit comments