File tree 3 files changed +14
-3
lines changed
3 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,11 @@ fn main() {
22
22
// If there were no arguments, access stdin and test working dir.
23
23
if std:: env:: args ( ) . len ( ) <= 1 {
24
24
let env_dir = env:: current_dir ( ) . unwrap ( ) ;
25
+ // CWD should be crate root.
25
26
let crate_dir = PathBuf :: from ( env:: var_os ( "CARGO_MANIFEST_DIR" ) . unwrap ( ) ) ;
27
+ // We have to normalize slashes, as the env var might be set for a different target's conventions.
28
+ let env_dir = env_dir. to_string_lossy ( ) . replace ( "\\ " , "/" ) ;
29
+ let crate_dir = crate_dir. to_string_lossy ( ) . replace ( "\\ " , "/" ) ;
26
30
assert_eq ! ( env_dir, crate_dir) ;
27
31
28
32
#[ cfg( unix) ]
Original file line number Diff line number Diff line change @@ -5,7 +5,11 @@ fn main() {
5
5
println ! ( "subcrate running" ) ;
6
6
7
7
let env_dir = env:: current_dir ( ) . unwrap ( ) ;
8
- let crate_dir = PathBuf :: from ( env:: var_os ( "CARGO_MANIFEST_DIR" ) . unwrap ( ) ) ;
9
8
// CWD should be workspace root, i.e., one level up from crate root.
10
- assert_eq ! ( env_dir, crate_dir. parent( ) . unwrap( ) ) ;
9
+ let crate_dir = PathBuf :: from ( env:: var_os ( "CARGO_MANIFEST_DIR" ) . unwrap ( ) ) ;
10
+ let crate_dir = crate_dir. parent ( ) . unwrap ( ) ;
11
+ // We have to normalize slashes, as the env var might be set for a different target's conventions.
12
+ let env_dir = env_dir. to_string_lossy ( ) . replace ( "\\ " , "/" ) ;
13
+ let crate_dir = crate_dir. to_string_lossy ( ) . replace ( "\\ " , "/" ) ;
14
+ assert_eq ! ( env_dir, crate_dir) ;
11
15
}
Original file line number Diff line number Diff line change @@ -5,7 +5,10 @@ fn main() {
5
5
println ! ( "subcrate testing" ) ;
6
6
7
7
let env_dir = env:: current_dir ( ) . unwrap ( ) ;
8
- let crate_dir = PathBuf :: from ( env:: var_os ( "CARGO_MANIFEST_DIR" ) . unwrap ( ) ) ;
9
8
// CWD should be crate root.
9
+ let crate_dir = PathBuf :: from ( env:: var_os ( "CARGO_MANIFEST_DIR" ) . unwrap ( ) ) ;
10
+ // We have to normalize slashes, as the env var might be set for a different target's conventions.
11
+ let env_dir = env_dir. to_string_lossy ( ) . replace ( "\\ " , "/" ) ;
12
+ let crate_dir = crate_dir. to_string_lossy ( ) . replace ( "\\ " , "/" ) ;
10
13
assert_eq ! ( env_dir, crate_dir) ;
11
14
}
You can’t perform that action at this time.
0 commit comments