Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions crates/cargo-test-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
6 changes: 3 additions & 3 deletions tests/testsuite/config_include.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -92,7 +92,7 @@ Caused by:

Caused by:
{}",
NO_SUCH_FILE_ERR_MSG
no_such_file_err_msg()
),
);
}
Expand Down Expand Up @@ -179,7 +179,7 @@ Caused by:

Caused by:
{}",
NO_SUCH_FILE_ERR_MSG
no_such_file_err_msg()
),
);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/testsuite/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
}
Expand Down