Skip to content

Commit 80e55c7

Browse files
committed
Fix tests with enoent error message on non-english systems.
1 parent 974fed9 commit 80e55c7

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

crates/cargo-test-support/src/lib.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1841,10 +1841,6 @@ pub fn symlink_supported() -> bool {
18411841
}
18421842

18431843
/// The error message for ENOENT.
1844-
///
1845-
/// It's generally not good to match against OS error messages, but I think
1846-
/// this one is relatively stable.
1847-
#[cfg(windows)]
1848-
pub const NO_SUCH_FILE_ERR_MSG: &str = "The system cannot find the file specified. (os error 2)";
1849-
#[cfg(not(windows))]
1850-
pub const NO_SUCH_FILE_ERR_MSG: &str = "No such file or directory (os error 2)";
1844+
pub fn no_such_file_err_msg() -> String {
1845+
std::io::Error::from_raw_os_error(2).to_string()
1846+
}

tests/testsuite/config_include.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use super::config::{
44
assert_error, assert_match, read_output, write_config, write_config_at, ConfigBuilder,
55
};
6-
use cargo_test_support::{paths, NO_SUCH_FILE_ERR_MSG};
6+
use cargo_test_support::{no_such_file_err_msg, paths};
77
use std::fs;
88

99
#[cargo_test]
@@ -92,7 +92,7 @@ Caused by:
9292
9393
Caused by:
9494
{}",
95-
NO_SUCH_FILE_ERR_MSG
95+
no_such_file_err_msg()
9696
),
9797
);
9898
}
@@ -179,7 +179,7 @@ Caused by:
179179
180180
Caused by:
181181
{}",
182-
NO_SUCH_FILE_ERR_MSG
182+
no_such_file_err_msg()
183183
),
184184
);
185185
}

tests/testsuite/install.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use cargo_test_support::install::{
1111
use cargo_test_support::paths;
1212
use cargo_test_support::registry::Package;
1313
use cargo_test_support::{
14-
basic_manifest, cargo_process, project, symlink_supported, t, NO_SUCH_FILE_ERR_MSG,
14+
basic_manifest, cargo_process, no_such_file_err_msg, project, symlink_supported, t,
1515
};
1616

1717
fn pkg(name: &str, vers: &str) {
@@ -845,7 +845,7 @@ fn uninstall_cwd_no_project() {
845845
846846
Caused by:
847847
{err_msg}",
848-
err_msg = NO_SUCH_FILE_ERR_MSG,
848+
err_msg = no_such_file_err_msg(),
849849
))
850850
.run();
851851
}

0 commit comments

Comments
 (0)