@@ -16,13 +16,16 @@ pub struct TestCase {
16
16
pub test_binaries : Vec < TestBinary > ,
17
17
}
18
18
19
+ fn path_to_test_name ( path : & Path ) -> String {
20
+ path. to_string_lossy ( )
21
+ . replace ( "/" , "::" )
22
+ . replace ( "\\ \\ " , "::" )
23
+ }
24
+
19
25
impl TestCase {
20
26
pub fn new_empty ( root : & Path , relative_path : & Path ) -> Self {
21
27
TestCase {
22
- name : format ! (
23
- "difftests::{}" ,
24
- relative_path. to_string_lossy( ) . replace( "/" , "::" )
25
- ) ,
28
+ name : format ! ( "difftests::{}" , path_to_test_name( relative_path) ) ,
26
29
absolute_path : root. join ( relative_path) ,
27
30
relative_path : relative_path. to_path_buf ( ) ,
28
31
test_binaries : Vec :: new ( ) ,
@@ -47,7 +50,7 @@ impl TestCase {
47
50
if path. is_dir ( ) && path. join ( "Cargo.toml" ) . exists ( ) {
48
51
debug ! ( "Found binary package candidate: {}" , path. display( ) ) ;
49
52
self . test_binaries
50
- . push ( TestBinary :: new ( self , PathBuf :: from ( entry. file_name ( ) ) ) ) ;
53
+ . push ( TestBinary :: new ( self , Path :: new ( & entry. file_name ( ) ) ) ) ;
51
54
}
52
55
}
53
56
Ok ( ( ) )
@@ -71,15 +74,15 @@ pub struct TestBinary {
71
74
}
72
75
73
76
impl TestBinary {
74
- pub fn new ( test_case : & TestCase , relative_to_test_case : PathBuf ) -> Self {
77
+ pub fn new ( test_case : & TestCase , relative_to_test_case : & Path ) -> Self {
75
78
Self {
76
79
name : format ! (
77
80
"{}::{}" ,
78
81
test_case. name,
79
- relative_to_test_case . to_string_lossy ( ) . replace ( "/" , "::" )
82
+ path_to_test_name ( relative_to_test_case )
80
83
) ,
81
- relative_path : test_case. relative_path . join ( & relative_to_test_case) ,
82
- absolute_path : test_case. absolute_path . join ( & relative_to_test_case) ,
84
+ relative_path : test_case. relative_path . join ( relative_to_test_case) ,
85
+ absolute_path : test_case. absolute_path . join ( relative_to_test_case) ,
83
86
}
84
87
}
85
88
}
@@ -128,7 +131,7 @@ mod tests {
128
131
TestCase :: new_empty ( Path :: new ( "/home/user/tests" ) , Path :: new ( "core/group1" ) ) ;
129
132
test_case
130
133
. test_binaries
131
- . push ( TestBinary :: new ( & test_case, PathBuf :: from ( "testcase1" ) ) ) ;
134
+ . push ( TestBinary :: new ( & test_case, Path :: new ( "testcase1" ) ) ) ;
132
135
assert_eq ! ( test_case. to_string( ) , "difftests::core::group1" ) ;
133
136
assert_eq ! (
134
137
test_case. test_binaries[ 0 ] . to_string( ) ,
@@ -161,13 +164,13 @@ mod tests {
161
164
. test_binaries
162
165
. sort_by ( |a, b| a. relative_path . cmp ( & b. relative_path ) ) ;
163
166
assert_eq ! (
164
- test_case. test_binaries[ 0 ] . relative_path. to_string_lossy ( ) ,
165
- "test_case/pkg1"
167
+ test_case. test_binaries[ 0 ] . relative_path,
168
+ Path :: new ( "test_case/pkg1" )
166
169
) ;
167
170
assert_eq ! ( test_case. test_binaries[ 0 ] . absolute_path, pkg1_dir) ;
168
171
assert_eq ! (
169
- test_case. test_binaries[ 1 ] . relative_path. to_string_lossy ( ) ,
170
- "test_case/pkg2"
172
+ test_case. test_binaries[ 1 ] . relative_path,
173
+ Path :: new ( "test_case/pkg2" )
171
174
) ;
172
175
assert_eq ! ( test_case. test_binaries[ 1 ] . absolute_path, pkg2_dir) ;
173
176
}
0 commit comments