@@ -31,13 +31,18 @@ fn cannot_read_files() -> Result<(), Box<dyn std::error::Error>> {
31
31
let nopath = nofile. into_temp_path ( ) ;
32
32
std:: fs:: remove_file ( & nopath) ?;
33
33
34
+ #[ cfg( not( windows) ) ]
35
+ let error_message = "No such file or directory" ;
36
+ #[ cfg( windows) ]
37
+ let error_message = "The system cannot find the file specified." ;
38
+
34
39
let mut cmd = Command :: cargo_bin ( "diffutils" ) ?;
35
40
cmd. arg ( & nopath) . arg ( file. path ( ) ) ;
36
41
cmd. assert ( )
37
42
. code ( predicate:: eq ( 2 ) )
38
43
. failure ( )
39
44
. stderr ( predicate:: str:: ends_with ( format ! (
40
- ": {}: No such file or directory \n " ,
45
+ ": {}: {error_message} \n " ,
41
46
& nopath. as_os_str( ) . to_string_lossy( )
42
47
) ) ) ;
43
48
@@ -47,15 +52,15 @@ fn cannot_read_files() -> Result<(), Box<dyn std::error::Error>> {
47
52
. code ( predicate:: eq ( 2 ) )
48
53
. failure ( )
49
54
. stderr ( predicate:: str:: ends_with ( format ! (
50
- ": {}: No such file or directory \n " ,
55
+ ": {}: {error_message} \n " ,
51
56
& nopath. as_os_str( ) . to_string_lossy( )
52
57
) ) ) ;
53
58
54
59
let mut cmd = Command :: cargo_bin ( "diffutils" ) ?;
55
60
cmd. arg ( & nopath) . arg ( & nopath) ;
56
61
cmd. assert ( ) . code ( predicate:: eq ( 2 ) ) . failure ( ) . stderr (
57
62
predicate:: str:: contains ( format ! (
58
- ": {}: No such file or directory \n " ,
63
+ ": {}: {error_message} \n " ,
59
64
& nopath. as_os_str( ) . to_string_lossy( )
60
65
) )
61
66
. count ( 2 ) ,
0 commit comments