@@ -22,7 +22,6 @@ const STEP_TIMEOUT: Duration = Duration::from_secs(20);
2222/// Screen size for the PTY terminal. Large enough to avoid line wrapping.
2323const SCREEN_SIZE : ScreenSize = ScreenSize { rows : 500 , cols : 500 } ;
2424
25- const COMPILE_TIME_CARGO_BIN_EXE_VP : & str = env ! ( "CARGO_BIN_EXE_vp" ) ;
2625const COMPILE_TIME_CARGO_MANIFEST_DIR : & str = env ! ( "CARGO_MANIFEST_DIR" ) ;
2726
2827/// Get the shell executable for running e2e test steps.
@@ -60,60 +59,39 @@ fn get_shell_exe() -> std::path::PathBuf {
6059 reason = "Path types required for runtime path remapping between compile and runtime roots"
6160) ]
6261fn runtime_manifest_dir ( ) -> std:: path:: PathBuf {
63- std:: env:: var_os ( "CARGO_MANIFEST_DIR" ) . map_or_else (
62+ let manifest_dir = std:: env:: var_os ( "CARGO_MANIFEST_DIR" ) . map_or_else (
6463 || std:: path:: PathBuf :: from ( COMPILE_TIME_CARGO_MANIFEST_DIR ) ,
6564 std:: path:: PathBuf :: from,
66- )
67- }
68-
69- #[ expect(
70- clippy:: disallowed_types,
71- reason = "Path types required for runtime path remapping between compile and runtime roots"
72- ) ]
73- fn relative_path_from ( path : & std:: path:: Path , base : & std:: path:: Path ) -> std:: path:: PathBuf {
74- use std:: path:: { Component , PathBuf } ;
75-
76- let path_components = path. components ( ) . collect :: < Vec < _ > > ( ) ;
77- let base_components = base. components ( ) . collect :: < Vec < _ > > ( ) ;
78-
79- let common_prefix_len = path_components
80- . iter ( )
81- . zip ( base_components. iter ( ) )
82- . take_while ( |( path_comp, base_comp) | path_comp == base_comp)
83- . count ( ) ;
84-
85- let mut relative_path = PathBuf :: new ( ) ;
65+ ) ;
8666
87- for base_comp in & base_components[ common_prefix_len..] {
88- match base_comp {
89- Component :: Normal ( _) | Component :: CurDir | Component :: ParentDir => {
90- relative_path. push ( ".." ) ;
67+ #[ cfg( windows) ]
68+ {
69+ // In cargo-xtest with a Windows target executed via wine on Unix hosts,
70+ // runtime CARGO_MANIFEST_DIR can be Unix-style (e.g. "/Volumes/...").
71+ // Map it to wine's Z: drive for Windows-native path resolution.
72+ if manifest_dir. to_string_lossy ( ) . starts_with ( '/' ) {
73+ let mut mapped = std:: path:: PathBuf :: from ( r"Z:\" ) ;
74+ for segment in manifest_dir. to_string_lossy ( ) . trim_start_matches ( '/' ) . split ( '/' ) {
75+ if !segment. is_empty ( ) {
76+ mapped. push ( segment) ;
77+ }
9178 }
92- Component :: RootDir | Component :: Prefix ( _ ) => { }
79+ return mapped ;
9380 }
9481 }
9582
96- for path_comp in & path_components[ common_prefix_len..] {
97- relative_path. push ( path_comp. as_os_str ( ) ) ;
98- }
99-
100- relative_path
83+ manifest_dir
10184}
10285
103- #[ expect(
104- clippy:: disallowed_types,
105- reason = "Path types required for runtime path remapping between compile and runtime roots"
106- ) ]
10786fn resolve_runtime_vp_path ( ) -> AbsolutePathBuf {
108- let compile_time_vp = std:: path:: Path :: new ( COMPILE_TIME_CARGO_BIN_EXE_VP ) ;
109- let compile_time_manifest = std:: path:: Path :: new ( COMPILE_TIME_CARGO_MANIFEST_DIR ) ;
110- let vp_relative_path = relative_path_from ( compile_time_vp, compile_time_manifest) ;
111-
112- let runtime_manifest = runtime_manifest_dir ( ) ;
113- let runtime_vp = runtime_manifest. join ( vp_relative_path) ;
114- let resolved_vp = if runtime_vp. exists ( ) { runtime_vp } else { compile_time_vp. to_path_buf ( ) } ;
115- let resolved_vp = resolved_vp. canonicalize ( ) . unwrap_or ( resolved_vp) ;
116- AbsolutePathBuf :: new ( resolved_vp) . unwrap ( )
87+ // Locate `vp` next to the test binary's debug directory.
88+ // tests/<name>.exe is in target/<triple>/debug/deps/, and vp(.exe) is in target/<triple>/debug/.
89+ let current_exe = std:: env:: current_exe ( ) . unwrap ( ) ;
90+ let current_exe = current_exe. canonicalize ( ) . unwrap_or ( current_exe) ;
91+ let debug_dir = current_exe. parent ( ) . unwrap ( ) . parent ( ) . unwrap ( ) ;
92+ let runtime_vp = debug_dir. join ( if cfg ! ( windows) { "vp.exe" } else { "vp" } ) ;
93+ let runtime_vp = runtime_vp. canonicalize ( ) . unwrap_or ( runtime_vp) ;
94+ AbsolutePathBuf :: new ( runtime_vp) . unwrap ( )
11795}
11896
11997const fn default_true ( ) -> bool {
0 commit comments