Skip to content

Commit

Permalink
Delete uses of the USER env var from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lf- authored and ehuss committed Mar 22, 2021
1 parent 96f8dbf commit de45c6f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 98 deletions.
80 changes: 23 additions & 57 deletions tests/testsuite/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ fn mercurial_available() -> bool {
#[cargo_test]
fn simple_lib() {
cargo_process("init --lib --vcs none --edition 2015")
.env("USER", "foo")
.with_stderr("[CREATED] library package")
.run();

Expand All @@ -42,7 +41,6 @@ fn simple_bin() {
let path = paths::root().join("foo");
fs::create_dir(&path).unwrap();
cargo_process("init --bin --vcs none --edition 2015")
.env("USER", "foo")
.cwd(&path)
.with_stderr("[CREATED] binary (application) package")
.run();
Expand All @@ -66,9 +64,7 @@ fn simple_git_ignore_exists() {
)
.unwrap();

cargo_process("init --lib foo --edition 2015")
.env("USER", "foo")
.run();
cargo_process("init --lib foo --edition 2015").run();

assert!(paths::root().is_dir());
assert!(paths::root().join("foo/Cargo.toml").is_file());
Expand Down Expand Up @@ -99,9 +95,7 @@ fn git_ignore_exists_no_conflicting_entries() {
fs::create_dir_all(paths::root().join("foo")).unwrap();
fs::write(paths::root().join("foo/.gitignore"), "**/some.file").unwrap();

cargo_process("init --lib foo --edition 2015")
.env("USER", "foo")
.run();
cargo_process("init --lib foo --edition 2015").run();

let fp = paths::root().join("foo/.gitignore");
let contents = fs::read_to_string(&fp).unwrap();
Expand All @@ -118,7 +112,6 @@ fn git_ignore_exists_no_conflicting_entries() {
#[cargo_test]
fn both_lib_and_bin() {
cargo_process("init --lib --bin")
.env("USER", "foo")
.with_status(101)
.with_stderr("[ERROR] can't specify both lib and binary outputs")
.run();
Expand All @@ -139,15 +132,9 @@ fn bin_already_exists(explicit: bool, rellocation: &str) {
fs::write(&sourcefile_path, content).unwrap();

if explicit {
cargo_process("init --bin --vcs none")
.env("USER", "foo")
.cwd(&path)
.run();
cargo_process("init --bin --vcs none").cwd(&path).run();
} else {
cargo_process("init --vcs none")
.env("USER", "foo")
.cwd(&path)
.run();
cargo_process("init --vcs none").cwd(&path).run();
}

assert!(paths::root().join("foo/Cargo.toml").is_file());
Expand Down Expand Up @@ -200,7 +187,6 @@ fn confused_by_multiple_lib_files() {
fs::write(path2, r#" fn qqq () { println!("Hello, world 3!"); }"#).unwrap();

cargo_process("init --vcs none")
.env("USER", "foo")
.cwd(&path)
.with_status(101)
.with_stderr(
Expand All @@ -224,7 +210,6 @@ fn multibin_project_name_clash() {
fs::write(path2, r#"fn main () { println!("Hello, world 3!"); }"#).unwrap();

cargo_process("init --lib --vcs none")
.env("USER", "foo")
.cwd(&path)
.with_status(101)
.with_stderr(
Expand All @@ -249,10 +234,7 @@ fn lib_already_exists(rellocation: &str) {
let content = "pub fn qqq() {}";
fs::write(&sourcefile_path, content).unwrap();

cargo_process("init --vcs none")
.env("USER", "foo")
.cwd(&path)
.run();
cargo_process("init --vcs none").cwd(&path).run();

assert!(paths::root().join("foo/Cargo.toml").is_file());
assert!(!paths::root().join("foo/src/main.rs").is_file());
Expand All @@ -274,9 +256,7 @@ fn lib_already_exists_nosrc() {

#[cargo_test]
fn simple_git() {
cargo_process("init --lib --vcs git")
.env("USER", "foo")
.run();
cargo_process("init --lib --vcs git").run();

assert!(paths::root().join("Cargo.toml").is_file());
assert!(paths::root().join("src/lib.rs").is_file());
Expand All @@ -286,7 +266,7 @@ fn simple_git() {

#[cargo_test]
fn auto_git() {
cargo_process("init --lib").env("USER", "foo").run();
cargo_process("init --lib").run();

assert!(paths::root().join("Cargo.toml").is_file());
assert!(paths::root().join("src/lib.rs").is_file());
Expand All @@ -300,7 +280,6 @@ fn invalid_dir_name() {
fs::create_dir_all(&foo).unwrap();
cargo_process("init")
.cwd(foo.clone())
.env("USER", "foo")
.with_status(101)
.with_stderr(
"\
Expand Down Expand Up @@ -328,7 +307,6 @@ fn reserved_name() {
fs::create_dir_all(&test).unwrap();
cargo_process("init")
.cwd(test.clone())
.env("USER", "foo")
.with_status(101)
.with_stderr(
"\
Expand All @@ -354,7 +332,7 @@ or change the name in Cargo.toml with:
fn git_autodetect() {
fs::create_dir(&paths::root().join(".git")).unwrap();

cargo_process("init --lib").env("USER", "foo").run();
cargo_process("init --lib").run();

assert!(paths::root().join("Cargo.toml").is_file());
assert!(paths::root().join("src/lib.rs").is_file());
Expand All @@ -366,7 +344,7 @@ fn git_autodetect() {
fn mercurial_autodetect() {
fs::create_dir(&paths::root().join(".hg")).unwrap();

cargo_process("init --lib").env("USER", "foo").run();
cargo_process("init --lib").run();

assert!(paths::root().join("Cargo.toml").is_file());
assert!(paths::root().join("src/lib.rs").is_file());
Expand All @@ -380,7 +358,7 @@ fn gitignore_appended_not_replaced() {

fs::write(&paths::root().join(".gitignore"), "qqqqqq\n").unwrap();

cargo_process("init --lib").env("USER", "foo").run();
cargo_process("init --lib").run();

assert!(paths::root().join("Cargo.toml").is_file());
assert!(paths::root().join("src/lib.rs").is_file());
Expand All @@ -397,7 +375,7 @@ fn gitignore_added_newline_in_existing() {

fs::write(&paths::root().join(".gitignore"), "first").unwrap();

cargo_process("init --lib").env("USER", "foo").run();
cargo_process("init --lib").run();

assert!(paths::root().join(".gitignore").is_file());

Expand All @@ -409,7 +387,7 @@ fn gitignore_added_newline_in_existing() {
fn gitignore_no_newline_in_new() {
fs::create_dir(&paths::root().join(".git")).unwrap();

cargo_process("init --lib").env("USER", "foo").run();
cargo_process("init --lib").run();

assert!(paths::root().join(".gitignore").is_file());

Expand All @@ -423,7 +401,7 @@ fn mercurial_added_newline_in_existing() {

fs::write(&paths::root().join(".hgignore"), "first").unwrap();

cargo_process("init --lib").env("USER", "foo").run();
cargo_process("init --lib").run();

assert!(paths::root().join(".hgignore").is_file());

Expand All @@ -435,7 +413,7 @@ fn mercurial_added_newline_in_existing() {
fn mercurial_no_newline_in_new() {
fs::create_dir(&paths::root().join(".hg")).unwrap();

cargo_process("init --lib").env("USER", "foo").run();
cargo_process("init --lib").run();

assert!(paths::root().join(".hgignore").is_file());

Expand All @@ -445,9 +423,7 @@ fn mercurial_no_newline_in_new() {

#[cargo_test]
fn terminating_newline_in_new_git_ignore() {
cargo_process("init --vcs git --lib")
.env("USER", "foo")
.run();
cargo_process("init --vcs git --lib").run();

let content = fs::read_to_string(&paths::root().join(".gitignore")).unwrap();

Expand All @@ -461,9 +437,7 @@ fn terminating_newline_in_new_mercurial_ignore() {
if !mercurial_available() {
return;
}
cargo_process("init --vcs hg --lib")
.env("USER", "foo")
.run();
cargo_process("init --vcs hg --lib").run();

let content = fs::read_to_string(&paths::root().join(".hgignore")).unwrap();

Expand All @@ -477,7 +451,7 @@ fn terminating_newline_in_existing_git_ignore() {
fs::create_dir(&paths::root().join(".git")).unwrap();
fs::write(&paths::root().join(".gitignore"), b"first").unwrap();

cargo_process("init --lib").env("USER", "foo").run();
cargo_process("init --lib").run();

let content = fs::read_to_string(&paths::root().join(".gitignore")).unwrap();

Expand All @@ -491,7 +465,7 @@ fn terminating_newline_in_existing_mercurial_ignore() {
fs::create_dir(&paths::root().join(".hg")).unwrap();
fs::write(&paths::root().join(".hgignore"), b"first").unwrap();

cargo_process("init --lib").env("USER", "foo").run();
cargo_process("init --lib").run();

let content = fs::read_to_string(&paths::root().join(".hgignore")).unwrap();

Expand All @@ -504,9 +478,7 @@ fn terminating_newline_in_existing_mercurial_ignore() {
fn cargo_lock_gitignored_if_lib1() {
fs::create_dir(&paths::root().join(".git")).unwrap();

cargo_process("init --lib --vcs git")
.env("USER", "foo")
.run();
cargo_process("init --lib --vcs git").run();

assert!(paths::root().join(".gitignore").is_file());

Expand All @@ -520,7 +492,7 @@ fn cargo_lock_gitignored_if_lib2() {

fs::write(&paths::root().join("lib.rs"), "").unwrap();

cargo_process("init --vcs git").env("USER", "foo").run();
cargo_process("init --vcs git").run();

assert!(paths::root().join(".gitignore").is_file());

Expand All @@ -532,9 +504,7 @@ fn cargo_lock_gitignored_if_lib2() {
fn cargo_lock_not_gitignored_if_bin1() {
fs::create_dir(&paths::root().join(".git")).unwrap();

cargo_process("init --vcs git --bin")
.env("USER", "foo")
.run();
cargo_process("init --vcs git --bin").run();

assert!(paths::root().join(".gitignore").is_file());

Expand All @@ -548,7 +518,7 @@ fn cargo_lock_not_gitignored_if_bin2() {

fs::write(&paths::root().join("main.rs"), "").unwrap();

cargo_process("init --vcs git").env("USER", "foo").run();
cargo_process("init --vcs git").run();

assert!(paths::root().join(".gitignore").is_file());

Expand All @@ -558,9 +528,7 @@ fn cargo_lock_not_gitignored_if_bin2() {

#[cargo_test]
fn with_argument() {
cargo_process("init foo --vcs none")
.env("USER", "foo")
.run();
cargo_process("init foo --vcs none").run();
assert!(paths::root().join("foo/Cargo.toml").is_file());
}

Expand Down Expand Up @@ -595,7 +563,6 @@ fn formats_source() {
fs::write(&paths::root().join("rustfmt.toml"), "tab_spaces = 2").unwrap();

cargo_process("init --lib")
.env("USER", "foo")
.with_stderr("[CREATED] library package")
.run();

Expand All @@ -615,7 +582,6 @@ mod tests {
#[cargo_test]
fn ignores_failure_to_format_source() {
cargo_process("init --lib")
.env("USER", "foo")
.env("PATH", "") // pretend that `rustfmt` is missing
.with_stderr("[CREATED] library package")
.run();
Expand Down
Loading

0 comments on commit de45c6f

Please sign in to comment.