Fix tests with enoent error message on non-english systems.

This commit is contained in:
Eric Huss 2020-05-29 12:34:17 -07:00
parent 974fed9a71
commit 80e55c774b
3 changed files with 8 additions and 12 deletions

View File

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

View File

@ -3,7 +3,7 @@
use super::config::{
assert_error, assert_match, read_output, write_config, write_config_at, ConfigBuilder,
};
use cargo_test_support::{paths, NO_SUCH_FILE_ERR_MSG};
use cargo_test_support::{no_such_file_err_msg, paths};
use std::fs;
#[cargo_test]
@ -92,7 +92,7 @@ Caused by:
Caused by:
{}",
NO_SUCH_FILE_ERR_MSG
no_such_file_err_msg()
),
);
}
@ -179,7 +179,7 @@ Caused by:
Caused by:
{}",
NO_SUCH_FILE_ERR_MSG
no_such_file_err_msg()
),
);
}

View File

@ -11,7 +11,7 @@ use cargo_test_support::install::{
use cargo_test_support::paths;
use cargo_test_support::registry::Package;
use cargo_test_support::{
basic_manifest, cargo_process, project, symlink_supported, t, NO_SUCH_FILE_ERR_MSG,
basic_manifest, cargo_process, no_such_file_err_msg, project, symlink_supported, t,
};
fn pkg(name: &str, vers: &str) {
@ -845,7 +845,7 @@ fn uninstall_cwd_no_project() {
Caused by:
{err_msg}",
err_msg = NO_SUCH_FILE_ERR_MSG,
err_msg = no_such_file_err_msg(),
))
.run();
}