Skip to content
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

Config enhancements. #7649

Merged
merged 9 commits into from
Dec 19, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fixes for some test errors on Windows.
  • Loading branch information
ehuss committed Dec 19, 2019
commit 00a47302dd32b8303a8d5be7646b41bb5e9d5056
9 changes: 9 additions & 0 deletions crates/cargo-test-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1846,3 +1846,12 @@ pub fn symlink_supported() -> bool {
pub fn symlink_supported() -> bool {
true
}

/// 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)";
3 changes: 3 additions & 0 deletions tests/testsuite/advanced_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
use cargo_test_support::{paths, project, registry::Package};

#[cargo_test]
// I don't know why, but `Command` forces all env keys to be upper case on
// Windows. Seems questionable, since I think Windows is case-preserving.
#[cfg_attr(windows, ignore)]
fn source_config_env() {
// Try to define [source] with environment variables.
let p = project()
Expand Down
15 changes: 11 additions & 4 deletions tests/testsuite/config_include.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use super::config::{
assert_error, assert_match, read_output, write_config, write_config_at, ConfigBuilder,
};
use cargo_test_support::NO_SUCH_FILE_ERR_MSG;

#[cargo_test]
fn gated() {
Expand Down Expand Up @@ -78,7 +79,8 @@ fn missing_file() {
let config = ConfigBuilder::new().unstable_flag("config-include").build();
assert_error(
config.get::<i32>("whatever").unwrap_err(),
"\
&format!(
"\
could not load Cargo configuration

Caused by:
Expand All @@ -88,7 +90,9 @@ Caused by:
failed to read configuration file `[..]/.cargo/missing`

Caused by:
No such file or directory (os error 2)",
{}",
NO_SUCH_FILE_ERR_MSG
),
);
}

Expand Down Expand Up @@ -162,11 +166,14 @@ fn cli_include_failed() {
.build_err();
assert_error(
config.unwrap_err(),
"\
&format!(
"\
failed to load --config include
failed to load config include `foobar` from `--config cli option`
failed to read configuration file `[..]/foobar`
No such file or directory (os error 2)",
{}",
NO_SUCH_FILE_ERR_MSG
),
);
}

Expand Down
11 changes: 3 additions & 8 deletions tests/testsuite/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,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};
use cargo_test_support::{basic_manifest, cargo_process, project, NO_SUCH_FILE_ERR_MSG};

fn pkg(name: &str, vers: &str) {
Package::new(name, vers)
Expand Down Expand Up @@ -824,11 +824,6 @@ fn uninstall_cwd_not_installed() {

#[cargo_test]
fn uninstall_cwd_no_project() {
let err_msg = if cfg!(windows) {
"The system cannot find the file specified."
} else {
"No such file or directory"
};
cargo_process("uninstall")
.with_status(101)
.with_stdout("")
Expand All @@ -837,8 +832,8 @@ fn uninstall_cwd_no_project() {
[ERROR] failed to read `[CWD]/Cargo.toml`

Caused by:
{err_msg} (os error 2)",
err_msg = err_msg,
{err_msg}",
err_msg = NO_SUCH_FILE_ERR_MSG,
))
.run();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/tool_paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ fn custom_runner_env() {
p.cargo("run")
.env(&key, "nonexistent-runner --foo")
.with_status(101)
.with_stderr_contains("[RUNNING] `nonexistent-runner --foo target/debug/foo`")
.with_stderr_contains("[RUNNING] `nonexistent-runner --foo target/debug/foo[EXE]`")
.run();
}

Expand Down