Cleanup: Misc.

This commit is contained in:
Eric Huss 2019-03-26 19:06:08 -07:00
parent a91a12b4af
commit 0b2b10b73c
6 changed files with 16 additions and 25 deletions

View file

@ -61,10 +61,11 @@ fn simple_bin() {
fn simple_git_ignore_exists() {
// write a .gitignore file with one entry
fs::create_dir_all(paths::root().join("foo")).unwrap();
let mut ignore_file = File::create(paths::root().join("foo/.gitignore")).unwrap();
ignore_file
.write("/target\n**/some.file".as_bytes())
.unwrap();
fs::write(
paths::root().join("foo/.gitignore"),
"/target\n**/some.file",
)
.unwrap();
cargo_process("init --lib foo --edition 2015")
.env("USER", "foo")

View file

@ -1343,7 +1343,7 @@ fn install_global_cargo_config() {
pkg("bar", "0.0.1");
let config = cargo_home().join("config");
let mut toml = fs::read_to_string(&config).unwrap_or(String::new());
let mut toml = fs::read_to_string(&config).unwrap_or_default();
toml.push_str(
r#"

View file

@ -434,8 +434,7 @@ fn metabuild_metadata() {
.as_array()
.unwrap()
.iter()
.filter(|p| p["name"].as_str().unwrap() == "foo")
.next()
.find(|p| p["name"].as_str().unwrap() == "foo")
.unwrap()["metabuild"]
.as_array()
.unwrap()

View file

@ -112,10 +112,10 @@ proptest! {
let reg = registry(input.clone());
let mut removed_input = input.clone();
for (summery_idx, dep_idx) in indexes_to_remove {
if removed_input.len() > 0 {
if !removed_input.is_empty() {
let summery_idx = summery_idx.index(removed_input.len());
let deps = removed_input[summery_idx].dependencies();
if deps.len() > 0 {
if !deps.is_empty() {
let new = remove_dep(&removed_input[summery_idx], dep_idx.index(deps.len()));
removed_input[summery_idx] = new;
}

View file

@ -1084,10 +1084,7 @@ impl Execs {
// On Windows, we need to use a wildcard for the drive,
// because we don't actually know what it will be.
let replaced =
replaced.replace("[ROOT]", if cfg!(windows) { r#"[..]:\"# } else { "/" });
replaced
replaced.replace("[ROOT]", if cfg!(windows) { r#"[..]:\"# } else { "/" })
}
None => return Ok(()),
};

View file

@ -188,13 +188,11 @@ fn custom_runner_cfg() {
p.cargo("run -- --param")
.with_status(101)
.with_stderr_contains(&format!(
"\
.with_stderr_contains("\
[COMPILING] foo v0.0.1 ([CWD])
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
[RUNNING] `nonexistent-runner -r target/debug/foo[EXE] --param`
",
))
")
.run();
}
@ -222,13 +220,11 @@ fn custom_runner_cfg_precedence() {
p.cargo("run -- --param")
.with_status(101)
.with_stderr_contains(&format!(
"\
.with_stderr_contains("\
[COMPILING] foo v0.0.1 ([CWD])
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
[RUNNING] `nonexistent-runner -r target/debug/foo[EXE] --param`
",
))
")
.run();
}
@ -250,10 +246,8 @@ fn custom_runner_cfg_collision() {
p.cargo("run -- --param")
.with_status(101)
.with_stderr_contains(&format!(
"\
.with_stderr_contains("\
[ERROR] several matching instances of `target.'cfg(..)'.runner` in `.cargo/config`
",
))
")
.run();
}