1
1
use std:: { fs, io, path:: Path } ;
2
2
3
+ use normalize_path:: NormalizePath ;
4
+
3
5
use crate :: { ResolveOptions , Resolver } ;
4
6
5
7
#[ derive( Debug , Clone , Copy ) ]
@@ -21,8 +23,10 @@ fn symlink<P: AsRef<Path>, Q: AsRef<Path>>(
21
23
22
24
#[ cfg( target_family = "windows" ) ]
23
25
match file_type {
24
- FileType :: File => std:: os:: windows:: fs:: symlink_file ( original, link) ,
25
- FileType :: Dir => std:: os:: windows:: fs:: symlink_dir ( original, link) ,
26
+ // NOTE: original path should use `\` instead of `/` for relative paths
27
+ // otherwise the symlink will be broken and the test will fail with InvalidFilename error
28
+ FileType :: File => std:: os:: windows:: fs:: symlink_file ( original. as_ref ( ) . normalize ( ) , link) ,
29
+ FileType :: Dir => std:: os:: windows:: fs:: symlink_dir ( original. as_ref ( ) . normalize ( ) , link) ,
26
30
}
27
31
}
28
32
@@ -33,9 +37,7 @@ fn init(dirname: &Path, temp_path: &Path) -> io::Result<()> {
33
37
fs:: create_dir ( temp_path) ?;
34
38
symlink ( dirname. join ( "../lib/index.js" ) , temp_path. join ( "test" ) , FileType :: File ) ?;
35
39
symlink ( dirname. join ( "../lib" ) , temp_path. join ( "test2" ) , FileType :: Dir ) ?;
36
- fs:: remove_file ( temp_path. join ( "test" ) ) ?;
37
- fs:: remove_file ( temp_path. join ( "test2" ) ) ?;
38
- fs:: remove_dir ( temp_path)
40
+ fs:: remove_dir_all ( temp_path)
39
41
}
40
42
41
43
fn create_symlinks ( dirname : & Path , temp_path : & Path ) -> io:: Result < ( ) > {
0 commit comments