diff options
Diffstat (limited to 'src/tools/cargo/tests/testsuite/init')
219 files changed, 1518 insertions, 0 deletions
diff --git a/src/tools/cargo/tests/testsuite/init/auto_git/in b/src/tools/cargo/tests/testsuite/init/auto_git/in new file mode 120000 index 000000000..1202506b6 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/auto_git/in @@ -0,0 +1 @@ +../empty_dir
\ No newline at end of file diff --git a/src/tools/cargo/tests/testsuite/init/auto_git/mod.rs b/src/tools/cargo/tests/testsuite/init/auto_git/mod.rs new file mode 100644 index 000000000..68c217520 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/auto_git/mod.rs @@ -0,0 +1,22 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::prelude::*; +use cargo_test_support::Project; + +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = &project.root(); + + snapbox::cmd::Command::cargo_ui() + .arg_line("init --lib") + .current_dir(project_root) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), &project_root); + assert!(project_root.join(".git").is_dir()); +} diff --git a/src/tools/cargo/tests/testsuite/init/auto_git/out/Cargo.toml b/src/tools/cargo/tests/testsuite/init/auto_git/out/Cargo.toml new file mode 100644 index 000000000..dcdb8da2c --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/auto_git/out/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "case" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/tools/cargo/tests/testsuite/init/auto_git/out/src/lib.rs b/src/tools/cargo/tests/testsuite/init/auto_git/out/src/lib.rs new file mode 100644 index 000000000..7d12d9af8 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/auto_git/out/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +} diff --git a/src/tools/cargo/tests/testsuite/init/auto_git/stderr.log b/src/tools/cargo/tests/testsuite/init/auto_git/stderr.log new file mode 100644 index 000000000..f459bf226 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/auto_git/stderr.log @@ -0,0 +1 @@ + Created library package diff --git a/src/tools/cargo/tests/testsuite/init/auto_git/stdout.log b/src/tools/cargo/tests/testsuite/init/auto_git/stdout.log new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/auto_git/stdout.log diff --git a/src/tools/cargo/tests/testsuite/init/bin_already_exists_explicit/in/src/main.rs b/src/tools/cargo/tests/testsuite/init/bin_already_exists_explicit/in/src/main.rs new file mode 100644 index 000000000..65fdcf8da --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/bin_already_exists_explicit/in/src/main.rs @@ -0,0 +1,4 @@ +fn main() { + println!("Check that our file is not overwritten") +} + diff --git a/src/tools/cargo/tests/testsuite/init/bin_already_exists_explicit/mod.rs b/src/tools/cargo/tests/testsuite/init/bin_already_exists_explicit/mod.rs new file mode 100644 index 000000000..326bd218a --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/bin_already_exists_explicit/mod.rs @@ -0,0 +1,21 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::prelude::*; +use cargo_test_support::Project; + +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = &project.root(); + + snapbox::cmd::Command::cargo_ui() + .arg_line("init --bin --vcs none") + .current_dir(project_root) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), project_root); +} diff --git a/src/tools/cargo/tests/testsuite/init/bin_already_exists_explicit/out/Cargo.toml b/src/tools/cargo/tests/testsuite/init/bin_already_exists_explicit/out/Cargo.toml new file mode 100644 index 000000000..dcdb8da2c --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/bin_already_exists_explicit/out/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "case" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/tools/cargo/tests/testsuite/init/bin_already_exists_explicit/out/src/main.rs b/src/tools/cargo/tests/testsuite/init/bin_already_exists_explicit/out/src/main.rs new file mode 100644 index 000000000..65fdcf8da --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/bin_already_exists_explicit/out/src/main.rs @@ -0,0 +1,4 @@ +fn main() { + println!("Check that our file is not overwritten") +} + diff --git a/src/tools/cargo/tests/testsuite/init/bin_already_exists_explicit/stderr.log b/src/tools/cargo/tests/testsuite/init/bin_already_exists_explicit/stderr.log new file mode 100644 index 000000000..3847e4e4a --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/bin_already_exists_explicit/stderr.log @@ -0,0 +1 @@ + Created binary (application) package diff --git a/src/tools/cargo/tests/testsuite/init/bin_already_exists_explicit/stdout.log b/src/tools/cargo/tests/testsuite/init/bin_already_exists_explicit/stdout.log new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/bin_already_exists_explicit/stdout.log diff --git a/src/tools/cargo/tests/testsuite/init/bin_already_exists_explicit_nosrc/in/main.rs b/src/tools/cargo/tests/testsuite/init/bin_already_exists_explicit_nosrc/in/main.rs new file mode 100644 index 000000000..65fdcf8da --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/bin_already_exists_explicit_nosrc/in/main.rs @@ -0,0 +1,4 @@ +fn main() { + println!("Check that our file is not overwritten") +} + diff --git a/src/tools/cargo/tests/testsuite/init/bin_already_exists_explicit_nosrc/mod.rs b/src/tools/cargo/tests/testsuite/init/bin_already_exists_explicit_nosrc/mod.rs new file mode 100644 index 000000000..1f16fb659 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/bin_already_exists_explicit_nosrc/mod.rs @@ -0,0 +1,22 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::prelude::*; +use cargo_test_support::Project; + +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = &project.root(); + + snapbox::cmd::Command::cargo_ui() + .arg_line("init --bin --vcs none") + .current_dir(project_root) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), project_root); + assert!(!project_root.join("src").is_dir()); +} diff --git a/src/tools/cargo/tests/testsuite/init/bin_already_exists_explicit_nosrc/out/Cargo.toml b/src/tools/cargo/tests/testsuite/init/bin_already_exists_explicit_nosrc/out/Cargo.toml new file mode 100644 index 000000000..5c6c9158c --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/bin_already_exists_explicit_nosrc/out/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "case" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] + +[[bin]] +name = "case" +path = "main.rs" diff --git a/src/tools/cargo/tests/testsuite/init/bin_already_exists_explicit_nosrc/out/main.rs b/src/tools/cargo/tests/testsuite/init/bin_already_exists_explicit_nosrc/out/main.rs new file mode 100644 index 000000000..65fdcf8da --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/bin_already_exists_explicit_nosrc/out/main.rs @@ -0,0 +1,4 @@ +fn main() { + println!("Check that our file is not overwritten") +} + diff --git a/src/tools/cargo/tests/testsuite/init/bin_already_exists_explicit_nosrc/stderr.log b/src/tools/cargo/tests/testsuite/init/bin_already_exists_explicit_nosrc/stderr.log new file mode 100644 index 000000000..3847e4e4a --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/bin_already_exists_explicit_nosrc/stderr.log @@ -0,0 +1 @@ + Created binary (application) package diff --git a/src/tools/cargo/tests/testsuite/init/bin_already_exists_explicit_nosrc/stdout.log b/src/tools/cargo/tests/testsuite/init/bin_already_exists_explicit_nosrc/stdout.log new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/bin_already_exists_explicit_nosrc/stdout.log diff --git a/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit/in/src/main.rs b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit/in/src/main.rs new file mode 100644 index 000000000..65fdcf8da --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit/in/src/main.rs @@ -0,0 +1,4 @@ +fn main() { + println!("Check that our file is not overwritten") +} + diff --git a/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit/mod.rs b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit/mod.rs new file mode 100644 index 000000000..12349a09b --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit/mod.rs @@ -0,0 +1,21 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::prelude::*; +use cargo_test_support::Project; + +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = &project.root(); + + snapbox::cmd::Command::cargo_ui() + .arg_line("init --vcs none") + .current_dir(project_root) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), project_root); +} diff --git a/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit/out/Cargo.toml b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit/out/Cargo.toml new file mode 100644 index 000000000..dcdb8da2c --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit/out/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "case" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit/out/src/main.rs b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit/out/src/main.rs new file mode 100644 index 000000000..65fdcf8da --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit/out/src/main.rs @@ -0,0 +1,4 @@ +fn main() { + println!("Check that our file is not overwritten") +} + diff --git a/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit/stderr.log b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit/stderr.log new file mode 100644 index 000000000..3847e4e4a --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit/stderr.log @@ -0,0 +1 @@ + Created binary (application) package diff --git a/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit/stdout.log b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit/stdout.log new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit/stdout.log diff --git a/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_namenosrc/in/case.rs b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_namenosrc/in/case.rs new file mode 100644 index 000000000..65fdcf8da --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_namenosrc/in/case.rs @@ -0,0 +1,4 @@ +fn main() { + println!("Check that our file is not overwritten") +} + diff --git a/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_namenosrc/mod.rs b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_namenosrc/mod.rs new file mode 100644 index 000000000..fe65940db --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_namenosrc/mod.rs @@ -0,0 +1,22 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::prelude::*; +use cargo_test_support::Project; + +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = &project.root(); + + snapbox::cmd::Command::cargo_ui() + .arg_line("init --vcs none") + .current_dir(project_root) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), project_root); + assert!(!project_root.join("src").is_dir()); +} diff --git a/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_namenosrc/out/Cargo.toml b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_namenosrc/out/Cargo.toml new file mode 100644 index 000000000..8da5fe778 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_namenosrc/out/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "case" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] + +[[bin]] +name = "case" +path = "case.rs" diff --git a/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_namenosrc/out/case.rs b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_namenosrc/out/case.rs new file mode 100644 index 000000000..65fdcf8da --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_namenosrc/out/case.rs @@ -0,0 +1,4 @@ +fn main() { + println!("Check that our file is not overwritten") +} + diff --git a/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_namenosrc/stderr.log b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_namenosrc/stderr.log new file mode 100644 index 000000000..3847e4e4a --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_namenosrc/stderr.log @@ -0,0 +1 @@ + Created binary (application) package diff --git a/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_namenosrc/stdout.log b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_namenosrc/stdout.log new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_namenosrc/stdout.log diff --git a/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_namesrc/in/src/case.rs b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_namesrc/in/src/case.rs new file mode 100644 index 000000000..65fdcf8da --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_namesrc/in/src/case.rs @@ -0,0 +1,4 @@ +fn main() { + println!("Check that our file is not overwritten") +} + diff --git a/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_namesrc/mod.rs b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_namesrc/mod.rs new file mode 100644 index 000000000..d3e8e66df --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_namesrc/mod.rs @@ -0,0 +1,22 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::prelude::*; +use cargo_test_support::Project; + +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = &project.root(); + + snapbox::cmd::Command::cargo_ui() + .arg_line("init --vcs none") + .current_dir(project_root) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), project_root); + assert!(!project_root.join("src/main.rs").is_file()); +} diff --git a/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_namesrc/out/Cargo.toml b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_namesrc/out/Cargo.toml new file mode 100644 index 000000000..dec0aaea9 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_namesrc/out/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "case" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] + +[[bin]] +name = "case" +path = "src/case.rs" diff --git a/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_namesrc/out/src/case.rs b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_namesrc/out/src/case.rs new file mode 100644 index 000000000..65fdcf8da --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_namesrc/out/src/case.rs @@ -0,0 +1,4 @@ +fn main() { + println!("Check that our file is not overwritten") +} + diff --git a/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_namesrc/stderr.log b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_namesrc/stderr.log new file mode 100644 index 000000000..3847e4e4a --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_namesrc/stderr.log @@ -0,0 +1 @@ + Created binary (application) package diff --git a/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_namesrc/stdout.log b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_namesrc/stdout.log new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_namesrc/stdout.log diff --git a/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_nosrc/in/main.rs b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_nosrc/in/main.rs new file mode 100644 index 000000000..65fdcf8da --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_nosrc/in/main.rs @@ -0,0 +1,4 @@ +fn main() { + println!("Check that our file is not overwritten") +} + diff --git a/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_nosrc/mod.rs b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_nosrc/mod.rs new file mode 100644 index 000000000..fe65940db --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_nosrc/mod.rs @@ -0,0 +1,22 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::prelude::*; +use cargo_test_support::Project; + +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = &project.root(); + + snapbox::cmd::Command::cargo_ui() + .arg_line("init --vcs none") + .current_dir(project_root) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), project_root); + assert!(!project_root.join("src").is_dir()); +} diff --git a/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_nosrc/out/Cargo.toml b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_nosrc/out/Cargo.toml new file mode 100644 index 000000000..5c6c9158c --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_nosrc/out/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "case" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] + +[[bin]] +name = "case" +path = "main.rs" diff --git a/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_nosrc/out/main.rs b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_nosrc/out/main.rs new file mode 100644 index 000000000..65fdcf8da --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_nosrc/out/main.rs @@ -0,0 +1,4 @@ +fn main() { + println!("Check that our file is not overwritten") +} + diff --git a/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_nosrc/stderr.log b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_nosrc/stderr.log new file mode 100644 index 000000000..3847e4e4a --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_nosrc/stderr.log @@ -0,0 +1 @@ + Created binary (application) package diff --git a/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_nosrc/stdout.log b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_nosrc/stdout.log new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/bin_already_exists_implicit_nosrc/stdout.log diff --git a/src/tools/cargo/tests/testsuite/init/both_lib_and_bin/mod.rs b/src/tools/cargo/tests/testsuite/init/both_lib_and_bin/mod.rs new file mode 100644 index 000000000..c9232320a --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/both_lib_and_bin/mod.rs @@ -0,0 +1,19 @@ +use cargo_test_support::paths; +use cargo_test_support::prelude::*; + +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + let cwd = paths::root(); + + snapbox::cmd::Command::cargo_ui() + .arg_line("init --lib --bin") + .current_dir(&cwd) + .assert() + .code(101) + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert!(!cwd.join("Cargo.toml").is_file()); +} diff --git a/src/tools/cargo/tests/testsuite/init/both_lib_and_bin/stderr.log b/src/tools/cargo/tests/testsuite/init/both_lib_and_bin/stderr.log new file mode 100644 index 000000000..9d635a427 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/both_lib_and_bin/stderr.log @@ -0,0 +1 @@ +error: can't specify both lib and binary outputs diff --git a/src/tools/cargo/tests/testsuite/init/both_lib_and_bin/stdout.log b/src/tools/cargo/tests/testsuite/init/both_lib_and_bin/stdout.log new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/both_lib_and_bin/stdout.log diff --git a/src/tools/cargo/tests/testsuite/init/cant_create_library_when_both_binlib_present/in/case.rs b/src/tools/cargo/tests/testsuite/init/cant_create_library_when_both_binlib_present/in/case.rs new file mode 100644 index 000000000..f328e4d9d --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/cant_create_library_when_both_binlib_present/in/case.rs @@ -0,0 +1 @@ +fn main() {} diff --git a/src/tools/cargo/tests/testsuite/init/cant_create_library_when_both_binlib_present/in/lib.rs b/src/tools/cargo/tests/testsuite/init/cant_create_library_when_both_binlib_present/in/lib.rs new file mode 100644 index 000000000..59760b549 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/cant_create_library_when_both_binlib_present/in/lib.rs @@ -0,0 +1 @@ +fn f() {} diff --git a/src/tools/cargo/tests/testsuite/init/cant_create_library_when_both_binlib_present/mod.rs b/src/tools/cargo/tests/testsuite/init/cant_create_library_when_both_binlib_present/mod.rs new file mode 100644 index 000000000..5e9e1b94c --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/cant_create_library_when_both_binlib_present/mod.rs @@ -0,0 +1,18 @@ +use cargo_test_support::prelude::*; +use cargo_test_support::Project; + +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = &project.root(); + + snapbox::cmd::Command::cargo_ui() + .arg_line("init --lib") + .current_dir(project_root) + .assert() + .code(101) + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); +} diff --git a/src/tools/cargo/tests/testsuite/init/cant_create_library_when_both_binlib_present/stderr.log b/src/tools/cargo/tests/testsuite/init/cant_create_library_when_both_binlib_present/stderr.log new file mode 100644 index 000000000..c08dce96b --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/cant_create_library_when_both_binlib_present/stderr.log @@ -0,0 +1 @@ +error: cannot have a package with multiple libraries, found both `case.rs` and `lib.rs` diff --git a/src/tools/cargo/tests/testsuite/init/cant_create_library_when_both_binlib_present/stdout.log b/src/tools/cargo/tests/testsuite/init/cant_create_library_when_both_binlib_present/stdout.log new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/cant_create_library_when_both_binlib_present/stdout.log diff --git a/src/tools/cargo/tests/testsuite/init/confused_by_multiple_lib_files/in/lib.rs b/src/tools/cargo/tests/testsuite/init/confused_by_multiple_lib_files/in/lib.rs new file mode 100644 index 000000000..321163744 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/confused_by_multiple_lib_files/in/lib.rs @@ -0,0 +1 @@ +fn f() { println!("lib.rs"); } diff --git a/src/tools/cargo/tests/testsuite/init/confused_by_multiple_lib_files/in/src/lib.rs b/src/tools/cargo/tests/testsuite/init/confused_by_multiple_lib_files/in/src/lib.rs new file mode 100644 index 000000000..f71455a1a --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/confused_by_multiple_lib_files/in/src/lib.rs @@ -0,0 +1 @@ +fn f() { println!("src/lib.rs"); } diff --git a/src/tools/cargo/tests/testsuite/init/confused_by_multiple_lib_files/mod.rs b/src/tools/cargo/tests/testsuite/init/confused_by_multiple_lib_files/mod.rs new file mode 100644 index 000000000..d1cba2ff7 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/confused_by_multiple_lib_files/mod.rs @@ -0,0 +1,22 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::prelude::*; +use cargo_test_support::Project; + +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = &project.root(); + + snapbox::cmd::Command::cargo_ui() + .arg_line("init --vcs none") + .current_dir(project_root) + .assert() + .code(101) + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), project_root); + assert!(!project_root.join("Cargo.toml").is_file()); +} diff --git a/src/tools/cargo/tests/testsuite/init/confused_by_multiple_lib_files/out/lib.rs b/src/tools/cargo/tests/testsuite/init/confused_by_multiple_lib_files/out/lib.rs new file mode 100644 index 000000000..321163744 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/confused_by_multiple_lib_files/out/lib.rs @@ -0,0 +1 @@ +fn f() { println!("lib.rs"); } diff --git a/src/tools/cargo/tests/testsuite/init/confused_by_multiple_lib_files/out/src/lib.rs b/src/tools/cargo/tests/testsuite/init/confused_by_multiple_lib_files/out/src/lib.rs new file mode 100644 index 000000000..f71455a1a --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/confused_by_multiple_lib_files/out/src/lib.rs @@ -0,0 +1 @@ +fn f() { println!("src/lib.rs"); } diff --git a/src/tools/cargo/tests/testsuite/init/confused_by_multiple_lib_files/stderr.log b/src/tools/cargo/tests/testsuite/init/confused_by_multiple_lib_files/stderr.log new file mode 100644 index 000000000..8dbd2aaf0 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/confused_by_multiple_lib_files/stderr.log @@ -0,0 +1 @@ +error: cannot have a package with multiple libraries, found both `src/lib.rs` and `lib.rs` diff --git a/src/tools/cargo/tests/testsuite/init/confused_by_multiple_lib_files/stdout.log b/src/tools/cargo/tests/testsuite/init/confused_by_multiple_lib_files/stdout.log new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/confused_by_multiple_lib_files/stdout.log diff --git a/src/tools/cargo/tests/testsuite/init/creates_binary_when_both_binlib_present/in/case.rs b/src/tools/cargo/tests/testsuite/init/creates_binary_when_both_binlib_present/in/case.rs new file mode 100644 index 000000000..f328e4d9d --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/creates_binary_when_both_binlib_present/in/case.rs @@ -0,0 +1 @@ +fn main() {} diff --git a/src/tools/cargo/tests/testsuite/init/creates_binary_when_both_binlib_present/in/lib.rs b/src/tools/cargo/tests/testsuite/init/creates_binary_when_both_binlib_present/in/lib.rs new file mode 100644 index 000000000..59760b549 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/creates_binary_when_both_binlib_present/in/lib.rs @@ -0,0 +1 @@ +fn f() {} diff --git a/src/tools/cargo/tests/testsuite/init/creates_binary_when_both_binlib_present/mod.rs b/src/tools/cargo/tests/testsuite/init/creates_binary_when_both_binlib_present/mod.rs new file mode 100644 index 000000000..326bd218a --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/creates_binary_when_both_binlib_present/mod.rs @@ -0,0 +1,21 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::prelude::*; +use cargo_test_support::Project; + +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = &project.root(); + + snapbox::cmd::Command::cargo_ui() + .arg_line("init --bin --vcs none") + .current_dir(project_root) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), project_root); +} diff --git a/src/tools/cargo/tests/testsuite/init/creates_binary_when_both_binlib_present/out/Cargo.toml b/src/tools/cargo/tests/testsuite/init/creates_binary_when_both_binlib_present/out/Cargo.toml new file mode 100644 index 000000000..675c888a5 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/creates_binary_when_both_binlib_present/out/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "case" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] + +[[bin]] +name = "case" +path = "case.rs" + +[lib] +name = "case" +path = "lib.rs" diff --git a/src/tools/cargo/tests/testsuite/init/creates_binary_when_both_binlib_present/out/case.rs b/src/tools/cargo/tests/testsuite/init/creates_binary_when_both_binlib_present/out/case.rs new file mode 100644 index 000000000..f328e4d9d --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/creates_binary_when_both_binlib_present/out/case.rs @@ -0,0 +1 @@ +fn main() {} diff --git a/src/tools/cargo/tests/testsuite/init/creates_binary_when_both_binlib_present/out/lib.rs b/src/tools/cargo/tests/testsuite/init/creates_binary_when_both_binlib_present/out/lib.rs new file mode 100644 index 000000000..59760b549 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/creates_binary_when_both_binlib_present/out/lib.rs @@ -0,0 +1 @@ +fn f() {} diff --git a/src/tools/cargo/tests/testsuite/init/creates_binary_when_both_binlib_present/stderr.log b/src/tools/cargo/tests/testsuite/init/creates_binary_when_both_binlib_present/stderr.log new file mode 100644 index 000000000..3847e4e4a --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/creates_binary_when_both_binlib_present/stderr.log @@ -0,0 +1 @@ + Created binary (application) package diff --git a/src/tools/cargo/tests/testsuite/init/creates_binary_when_both_binlib_present/stdout.log b/src/tools/cargo/tests/testsuite/init/creates_binary_when_both_binlib_present/stdout.log new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/creates_binary_when_both_binlib_present/stdout.log diff --git a/src/tools/cargo/tests/testsuite/init/creates_binary_when_instructed_and_has_lib_file/in/case.rs b/src/tools/cargo/tests/testsuite/init/creates_binary_when_instructed_and_has_lib_file/in/case.rs new file mode 100644 index 000000000..59760b549 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/creates_binary_when_instructed_and_has_lib_file/in/case.rs @@ -0,0 +1 @@ +fn f() {} diff --git a/src/tools/cargo/tests/testsuite/init/creates_binary_when_instructed_and_has_lib_file/mod.rs b/src/tools/cargo/tests/testsuite/init/creates_binary_when_instructed_and_has_lib_file/mod.rs new file mode 100644 index 000000000..326bd218a --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/creates_binary_when_instructed_and_has_lib_file/mod.rs @@ -0,0 +1,21 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::prelude::*; +use cargo_test_support::Project; + +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = &project.root(); + + snapbox::cmd::Command::cargo_ui() + .arg_line("init --bin --vcs none") + .current_dir(project_root) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), project_root); +} diff --git a/src/tools/cargo/tests/testsuite/init/creates_binary_when_instructed_and_has_lib_file/out/Cargo.toml b/src/tools/cargo/tests/testsuite/init/creates_binary_when_instructed_and_has_lib_file/out/Cargo.toml new file mode 100644 index 000000000..8da5fe778 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/creates_binary_when_instructed_and_has_lib_file/out/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "case" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] + +[[bin]] +name = "case" +path = "case.rs" diff --git a/src/tools/cargo/tests/testsuite/init/creates_binary_when_instructed_and_has_lib_file/out/case.rs b/src/tools/cargo/tests/testsuite/init/creates_binary_when_instructed_and_has_lib_file/out/case.rs new file mode 100644 index 000000000..59760b549 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/creates_binary_when_instructed_and_has_lib_file/out/case.rs @@ -0,0 +1 @@ +fn f() {} diff --git a/src/tools/cargo/tests/testsuite/init/creates_binary_when_instructed_and_has_lib_file/stderr.log b/src/tools/cargo/tests/testsuite/init/creates_binary_when_instructed_and_has_lib_file/stderr.log new file mode 100644 index 000000000..ec428f31c --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/creates_binary_when_instructed_and_has_lib_file/stderr.log @@ -0,0 +1,2 @@ +warning: file `case.rs` seems to be a library file + Created binary (application) package diff --git a/src/tools/cargo/tests/testsuite/init/creates_binary_when_instructed_and_has_lib_file/stdout.log b/src/tools/cargo/tests/testsuite/init/creates_binary_when_instructed_and_has_lib_file/stdout.log new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/creates_binary_when_instructed_and_has_lib_file/stdout.log diff --git a/src/tools/cargo/tests/testsuite/init/creates_library_when_instructed_and_has_bin_file/in/case.rs b/src/tools/cargo/tests/testsuite/init/creates_library_when_instructed_and_has_bin_file/in/case.rs new file mode 100644 index 000000000..f328e4d9d --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/creates_library_when_instructed_and_has_bin_file/in/case.rs @@ -0,0 +1 @@ +fn main() {} diff --git a/src/tools/cargo/tests/testsuite/init/creates_library_when_instructed_and_has_bin_file/mod.rs b/src/tools/cargo/tests/testsuite/init/creates_library_when_instructed_and_has_bin_file/mod.rs new file mode 100644 index 000000000..59c192cb9 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/creates_library_when_instructed_and_has_bin_file/mod.rs @@ -0,0 +1,21 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::prelude::*; +use cargo_test_support::Project; + +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = &project.root(); + + snapbox::cmd::Command::cargo_ui() + .arg_line("init --lib --vcs none") + .current_dir(project_root) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), project_root); +} diff --git a/src/tools/cargo/tests/testsuite/init/creates_library_when_instructed_and_has_bin_file/out/Cargo.toml b/src/tools/cargo/tests/testsuite/init/creates_library_when_instructed_and_has_bin_file/out/Cargo.toml new file mode 100644 index 000000000..2c0464468 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/creates_library_when_instructed_and_has_bin_file/out/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "case" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] + +[lib] +name = "case" +path = "case.rs" diff --git a/src/tools/cargo/tests/testsuite/init/creates_library_when_instructed_and_has_bin_file/out/case.rs b/src/tools/cargo/tests/testsuite/init/creates_library_when_instructed_and_has_bin_file/out/case.rs new file mode 100644 index 000000000..f328e4d9d --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/creates_library_when_instructed_and_has_bin_file/out/case.rs @@ -0,0 +1 @@ +fn main() {} diff --git a/src/tools/cargo/tests/testsuite/init/creates_library_when_instructed_and_has_bin_file/stderr.log b/src/tools/cargo/tests/testsuite/init/creates_library_when_instructed_and_has_bin_file/stderr.log new file mode 100644 index 000000000..bf070e2da --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/creates_library_when_instructed_and_has_bin_file/stderr.log @@ -0,0 +1,2 @@ +warning: file `case.rs` seems to be a binary (application) file + Created library package diff --git a/src/tools/cargo/tests/testsuite/init/creates_library_when_instructed_and_has_bin_file/stdout.log b/src/tools/cargo/tests/testsuite/init/creates_library_when_instructed_and_has_bin_file/stdout.log new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/creates_library_when_instructed_and_has_bin_file/stdout.log diff --git a/src/tools/cargo/tests/testsuite/init/empty_dir/.keep b/src/tools/cargo/tests/testsuite/init/empty_dir/.keep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/empty_dir/.keep diff --git a/src/tools/cargo/tests/testsuite/init/empty_dir/mod.rs b/src/tools/cargo/tests/testsuite/init/empty_dir/mod.rs new file mode 100644 index 000000000..074954f01 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/empty_dir/mod.rs @@ -0,0 +1,7 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::prelude::*; +use cargo_test_support::{command_is_available, paths, Project}; +use std::fs; +use std::process::Command; + +use crate::test_root; diff --git a/src/tools/cargo/tests/testsuite/init/explicit_bin_with_git/in b/src/tools/cargo/tests/testsuite/init/explicit_bin_with_git/in new file mode 120000 index 000000000..1202506b6 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/explicit_bin_with_git/in @@ -0,0 +1 @@ +../empty_dir
\ No newline at end of file diff --git a/src/tools/cargo/tests/testsuite/init/explicit_bin_with_git/mod.rs b/src/tools/cargo/tests/testsuite/init/explicit_bin_with_git/mod.rs new file mode 100644 index 000000000..7314e955c --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/explicit_bin_with_git/mod.rs @@ -0,0 +1,21 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::prelude::*; +use cargo_test_support::Project; + +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = &project.root(); + + snapbox::cmd::Command::cargo_ui() + .arg_line("init --vcs git --bin") + .current_dir(project_root) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), project_root); +} diff --git a/src/tools/cargo/tests/testsuite/init/explicit_bin_with_git/out/Cargo.toml b/src/tools/cargo/tests/testsuite/init/explicit_bin_with_git/out/Cargo.toml new file mode 100644 index 000000000..dcdb8da2c --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/explicit_bin_with_git/out/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "case" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/tools/cargo/tests/testsuite/init/explicit_bin_with_git/out/src/main.rs b/src/tools/cargo/tests/testsuite/init/explicit_bin_with_git/out/src/main.rs new file mode 100644 index 000000000..e7a11a969 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/explicit_bin_with_git/out/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/src/tools/cargo/tests/testsuite/init/explicit_bin_with_git/stderr.log b/src/tools/cargo/tests/testsuite/init/explicit_bin_with_git/stderr.log new file mode 100644 index 000000000..3847e4e4a --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/explicit_bin_with_git/stderr.log @@ -0,0 +1 @@ + Created binary (application) package diff --git a/src/tools/cargo/tests/testsuite/init/explicit_bin_with_git/stdout.log b/src/tools/cargo/tests/testsuite/init/explicit_bin_with_git/stdout.log new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/explicit_bin_with_git/stdout.log diff --git a/src/tools/cargo/tests/testsuite/init/formats_source/in/rustfmt.toml b/src/tools/cargo/tests/testsuite/init/formats_source/in/rustfmt.toml new file mode 100644 index 000000000..b196eaa2d --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/formats_source/in/rustfmt.toml @@ -0,0 +1 @@ +tab_spaces = 2 diff --git a/src/tools/cargo/tests/testsuite/init/formats_source/mod.rs b/src/tools/cargo/tests/testsuite/init/formats_source/mod.rs new file mode 100644 index 000000000..ac1fb6271 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/formats_source/mod.rs @@ -0,0 +1,29 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::prelude::*; +use cargo_test_support::{process, Project}; + +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + // This cannot use `requires_rustfmt` because rustfmt is not available in + // the rust-lang/rust environment. Additionally, if running cargo without + // rustup (but with rustup installed), this test also fails due to HOME + // preventing the proxy from choosing a toolchain. + if let Err(e) = process("rustfmt").arg("-V").exec_with_output() { + eprintln!("skipping test, rustfmt not available:\n{e:?}"); + return; + } + let project = Project::from_template(curr_dir!().join("in")); + let project_root = &project.root(); + + snapbox::cmd::Command::cargo_ui() + .arg_line("init --lib --vcs none") + .current_dir(project_root) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), project_root); +} diff --git a/src/tools/cargo/tests/testsuite/init/formats_source/out/Cargo.toml b/src/tools/cargo/tests/testsuite/init/formats_source/out/Cargo.toml new file mode 100644 index 000000000..dcdb8da2c --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/formats_source/out/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "case" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/tools/cargo/tests/testsuite/init/formats_source/out/rustfmt.toml b/src/tools/cargo/tests/testsuite/init/formats_source/out/rustfmt.toml new file mode 100644 index 000000000..b196eaa2d --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/formats_source/out/rustfmt.toml @@ -0,0 +1 @@ +tab_spaces = 2 diff --git a/src/tools/cargo/tests/testsuite/init/formats_source/out/src/lib.rs b/src/tools/cargo/tests/testsuite/init/formats_source/out/src/lib.rs new file mode 100644 index 000000000..3b9acffd5 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/formats_source/out/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +} diff --git a/src/tools/cargo/tests/testsuite/init/formats_source/stderr.log b/src/tools/cargo/tests/testsuite/init/formats_source/stderr.log new file mode 100644 index 000000000..f459bf226 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/formats_source/stderr.log @@ -0,0 +1 @@ + Created library package diff --git a/src/tools/cargo/tests/testsuite/init/formats_source/stdout.log b/src/tools/cargo/tests/testsuite/init/formats_source/stdout.log new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/formats_source/stdout.log diff --git a/src/tools/cargo/tests/testsuite/init/fossil_autodetect/in/.fossil/.keep b/src/tools/cargo/tests/testsuite/init/fossil_autodetect/in/.fossil/.keep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/fossil_autodetect/in/.fossil/.keep diff --git a/src/tools/cargo/tests/testsuite/init/fossil_autodetect/mod.rs b/src/tools/cargo/tests/testsuite/init/fossil_autodetect/mod.rs new file mode 100644 index 000000000..d45ba868a --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/fossil_autodetect/mod.rs @@ -0,0 +1,22 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::prelude::*; +use cargo_test_support::Project; + +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = &project.root(); + + snapbox::cmd::Command::cargo_ui() + .arg_line("init --lib") + .current_dir(project_root) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), project_root); + assert!(!project_root.join(".git").is_dir()); +} diff --git a/src/tools/cargo/tests/testsuite/init/fossil_autodetect/out/.fossil-settings/clean-glob b/src/tools/cargo/tests/testsuite/init/fossil_autodetect/out/.fossil-settings/clean-glob new file mode 100644 index 000000000..a9d37c560 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/fossil_autodetect/out/.fossil-settings/clean-glob @@ -0,0 +1,2 @@ +target +Cargo.lock diff --git a/src/tools/cargo/tests/testsuite/init/fossil_autodetect/out/.fossil-settings/ignore-glob b/src/tools/cargo/tests/testsuite/init/fossil_autodetect/out/.fossil-settings/ignore-glob new file mode 100644 index 000000000..a9d37c560 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/fossil_autodetect/out/.fossil-settings/ignore-glob @@ -0,0 +1,2 @@ +target +Cargo.lock diff --git a/src/tools/cargo/tests/testsuite/init/fossil_autodetect/out/Cargo.toml b/src/tools/cargo/tests/testsuite/init/fossil_autodetect/out/Cargo.toml new file mode 100644 index 000000000..dcdb8da2c --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/fossil_autodetect/out/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "case" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/tools/cargo/tests/testsuite/init/fossil_autodetect/out/src/lib.rs b/src/tools/cargo/tests/testsuite/init/fossil_autodetect/out/src/lib.rs new file mode 100644 index 000000000..7d12d9af8 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/fossil_autodetect/out/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +} diff --git a/src/tools/cargo/tests/testsuite/init/fossil_autodetect/stderr.log b/src/tools/cargo/tests/testsuite/init/fossil_autodetect/stderr.log new file mode 100644 index 000000000..f459bf226 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/fossil_autodetect/stderr.log @@ -0,0 +1 @@ + Created library package diff --git a/src/tools/cargo/tests/testsuite/init/fossil_autodetect/stdout.log b/src/tools/cargo/tests/testsuite/init/fossil_autodetect/stdout.log new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/fossil_autodetect/stdout.log diff --git a/src/tools/cargo/tests/testsuite/init/git_autodetect/mod.rs b/src/tools/cargo/tests/testsuite/init/git_autodetect/mod.rs new file mode 100644 index 000000000..aef47bc7d --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/git_autodetect/mod.rs @@ -0,0 +1,24 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::paths; +use cargo_test_support::prelude::*; +use std::fs; + +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + let project_root = &paths::root().join("foo"); + // Need to create `.git` dir manually because it cannot be tracked under a git repo + fs::create_dir_all(project_root.join(".git")).unwrap(); + + snapbox::cmd::Command::cargo_ui() + .arg_line("init --lib") + .current_dir(project_root) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), project_root); + assert!(project_root.join(".git").is_dir()); +} diff --git a/src/tools/cargo/tests/testsuite/init/git_autodetect/out/Cargo.toml b/src/tools/cargo/tests/testsuite/init/git_autodetect/out/Cargo.toml new file mode 100644 index 000000000..1d9cfe317 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/git_autodetect/out/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "foo" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/tools/cargo/tests/testsuite/init/git_autodetect/out/src/lib.rs b/src/tools/cargo/tests/testsuite/init/git_autodetect/out/src/lib.rs new file mode 100644 index 000000000..7d12d9af8 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/git_autodetect/out/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +} diff --git a/src/tools/cargo/tests/testsuite/init/git_autodetect/stderr.log b/src/tools/cargo/tests/testsuite/init/git_autodetect/stderr.log new file mode 100644 index 000000000..f459bf226 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/git_autodetect/stderr.log @@ -0,0 +1 @@ + Created library package diff --git a/src/tools/cargo/tests/testsuite/init/git_autodetect/stdout.log b/src/tools/cargo/tests/testsuite/init/git_autodetect/stdout.log new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/git_autodetect/stdout.log diff --git a/src/tools/cargo/tests/testsuite/init/git_ignore_exists_no_conflicting_entries/mod.rs b/src/tools/cargo/tests/testsuite/init/git_ignore_exists_no_conflicting_entries/mod.rs new file mode 100644 index 000000000..cd4437c65 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/git_ignore_exists_no_conflicting_entries/mod.rs @@ -0,0 +1,22 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::prelude::*; +use cargo_test_support::Project; + +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = &project.root(); + + snapbox::cmd::Command::cargo_ui() + .arg_line("init --lib --edition 2015") + .current_dir(project_root) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), project_root); + assert!(project_root.join(".git").is_dir()); +} diff --git a/src/tools/cargo/tests/testsuite/init/git_ignore_exists_no_conflicting_entries/out/Cargo.toml b/src/tools/cargo/tests/testsuite/init/git_ignore_exists_no_conflicting_entries/out/Cargo.toml new file mode 100644 index 000000000..a6269fdcd --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/git_ignore_exists_no_conflicting_entries/out/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "case" +version = "0.1.0" +edition = "2015" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/tools/cargo/tests/testsuite/init/git_ignore_exists_no_conflicting_entries/out/src/lib.rs b/src/tools/cargo/tests/testsuite/init/git_ignore_exists_no_conflicting_entries/out/src/lib.rs new file mode 100644 index 000000000..7d12d9af8 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/git_ignore_exists_no_conflicting_entries/out/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +} diff --git a/src/tools/cargo/tests/testsuite/init/git_ignore_exists_no_conflicting_entries/stderr.log b/src/tools/cargo/tests/testsuite/init/git_ignore_exists_no_conflicting_entries/stderr.log new file mode 100644 index 000000000..f459bf226 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/git_ignore_exists_no_conflicting_entries/stderr.log @@ -0,0 +1 @@ + Created library package diff --git a/src/tools/cargo/tests/testsuite/init/git_ignore_exists_no_conflicting_entries/stdout.log b/src/tools/cargo/tests/testsuite/init/git_ignore_exists_no_conflicting_entries/stdout.log new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/git_ignore_exists_no_conflicting_entries/stdout.log diff --git a/src/tools/cargo/tests/testsuite/init/ignores_failure_to_format_source/in/rustfmt.toml b/src/tools/cargo/tests/testsuite/init/ignores_failure_to_format_source/in/rustfmt.toml new file mode 100644 index 000000000..b196eaa2d --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/ignores_failure_to_format_source/in/rustfmt.toml @@ -0,0 +1 @@ +tab_spaces = 2 diff --git a/src/tools/cargo/tests/testsuite/init/ignores_failure_to_format_source/mod.rs b/src/tools/cargo/tests/testsuite/init/ignores_failure_to_format_source/mod.rs new file mode 100644 index 000000000..fd9394049 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/ignores_failure_to_format_source/mod.rs @@ -0,0 +1,22 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::prelude::*; +use cargo_test_support::Project; + +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = &project.root(); + + snapbox::cmd::Command::cargo_ui() + .arg_line("init --lib --vcs none") + .env("PATH", "") // pretend that `rustfmt` is missing + .current_dir(project_root) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), project_root); +} diff --git a/src/tools/cargo/tests/testsuite/init/ignores_failure_to_format_source/out/Cargo.toml b/src/tools/cargo/tests/testsuite/init/ignores_failure_to_format_source/out/Cargo.toml new file mode 100644 index 000000000..dcdb8da2c --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/ignores_failure_to_format_source/out/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "case" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/tools/cargo/tests/testsuite/init/ignores_failure_to_format_source/out/rustfmt.toml b/src/tools/cargo/tests/testsuite/init/ignores_failure_to_format_source/out/rustfmt.toml new file mode 100644 index 000000000..b196eaa2d --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/ignores_failure_to_format_source/out/rustfmt.toml @@ -0,0 +1 @@ +tab_spaces = 2 diff --git a/src/tools/cargo/tests/testsuite/init/ignores_failure_to_format_source/out/src/lib.rs b/src/tools/cargo/tests/testsuite/init/ignores_failure_to_format_source/out/src/lib.rs new file mode 100644 index 000000000..7d12d9af8 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/ignores_failure_to_format_source/out/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +} diff --git a/src/tools/cargo/tests/testsuite/init/ignores_failure_to_format_source/stderr.log b/src/tools/cargo/tests/testsuite/init/ignores_failure_to_format_source/stderr.log new file mode 100644 index 000000000..f459bf226 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/ignores_failure_to_format_source/stderr.log @@ -0,0 +1 @@ + Created library package diff --git a/src/tools/cargo/tests/testsuite/init/ignores_failure_to_format_source/stdout.log b/src/tools/cargo/tests/testsuite/init/ignores_failure_to_format_source/stdout.log new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/ignores_failure_to_format_source/stdout.log diff --git a/src/tools/cargo/tests/testsuite/init/inferred_bin_with_git/in/main.rs b/src/tools/cargo/tests/testsuite/init/inferred_bin_with_git/in/main.rs new file mode 100644 index 000000000..f328e4d9d --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/inferred_bin_with_git/in/main.rs @@ -0,0 +1 @@ +fn main() {} diff --git a/src/tools/cargo/tests/testsuite/init/inferred_bin_with_git/mod.rs b/src/tools/cargo/tests/testsuite/init/inferred_bin_with_git/mod.rs new file mode 100644 index 000000000..80bec8893 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/inferred_bin_with_git/mod.rs @@ -0,0 +1,21 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::prelude::*; +use cargo_test_support::Project; + +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = &project.root(); + + snapbox::cmd::Command::cargo_ui() + .arg_line("init --vcs git") + .current_dir(project_root) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), project_root); +} diff --git a/src/tools/cargo/tests/testsuite/init/inferred_bin_with_git/out/Cargo.toml b/src/tools/cargo/tests/testsuite/init/inferred_bin_with_git/out/Cargo.toml new file mode 100644 index 000000000..5c6c9158c --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/inferred_bin_with_git/out/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "case" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] + +[[bin]] +name = "case" +path = "main.rs" diff --git a/src/tools/cargo/tests/testsuite/init/inferred_bin_with_git/out/main.rs b/src/tools/cargo/tests/testsuite/init/inferred_bin_with_git/out/main.rs new file mode 100644 index 000000000..f328e4d9d --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/inferred_bin_with_git/out/main.rs @@ -0,0 +1 @@ +fn main() {} diff --git a/src/tools/cargo/tests/testsuite/init/inferred_bin_with_git/stderr.log b/src/tools/cargo/tests/testsuite/init/inferred_bin_with_git/stderr.log new file mode 100644 index 000000000..3847e4e4a --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/inferred_bin_with_git/stderr.log @@ -0,0 +1 @@ + Created binary (application) package diff --git a/src/tools/cargo/tests/testsuite/init/inferred_bin_with_git/stdout.log b/src/tools/cargo/tests/testsuite/init/inferred_bin_with_git/stdout.log new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/inferred_bin_with_git/stdout.log diff --git a/src/tools/cargo/tests/testsuite/init/inferred_lib_with_git/in/lib.rs b/src/tools/cargo/tests/testsuite/init/inferred_lib_with_git/in/lib.rs new file mode 100644 index 000000000..59760b549 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/inferred_lib_with_git/in/lib.rs @@ -0,0 +1 @@ +fn f() {} diff --git a/src/tools/cargo/tests/testsuite/init/inferred_lib_with_git/mod.rs b/src/tools/cargo/tests/testsuite/init/inferred_lib_with_git/mod.rs new file mode 100644 index 000000000..80bec8893 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/inferred_lib_with_git/mod.rs @@ -0,0 +1,21 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::prelude::*; +use cargo_test_support::Project; + +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = &project.root(); + + snapbox::cmd::Command::cargo_ui() + .arg_line("init --vcs git") + .current_dir(project_root) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), project_root); +} diff --git a/src/tools/cargo/tests/testsuite/init/inferred_lib_with_git/out/Cargo.toml b/src/tools/cargo/tests/testsuite/init/inferred_lib_with_git/out/Cargo.toml new file mode 100644 index 000000000..39e95fe94 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/inferred_lib_with_git/out/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "case" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] + +[lib] +name = "case" +path = "lib.rs" diff --git a/src/tools/cargo/tests/testsuite/init/inferred_lib_with_git/out/lib.rs b/src/tools/cargo/tests/testsuite/init/inferred_lib_with_git/out/lib.rs new file mode 100644 index 000000000..59760b549 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/inferred_lib_with_git/out/lib.rs @@ -0,0 +1 @@ +fn f() {} diff --git a/src/tools/cargo/tests/testsuite/init/inferred_lib_with_git/stderr.log b/src/tools/cargo/tests/testsuite/init/inferred_lib_with_git/stderr.log new file mode 100644 index 000000000..f459bf226 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/inferred_lib_with_git/stderr.log @@ -0,0 +1 @@ + Created library package diff --git a/src/tools/cargo/tests/testsuite/init/inferred_lib_with_git/stdout.log b/src/tools/cargo/tests/testsuite/init/inferred_lib_with_git/stdout.log new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/inferred_lib_with_git/stdout.log diff --git a/src/tools/cargo/tests/testsuite/init/invalid_dir_name/mod.rs b/src/tools/cargo/tests/testsuite/init/invalid_dir_name/mod.rs new file mode 100644 index 000000000..2b1be9022 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/invalid_dir_name/mod.rs @@ -0,0 +1,21 @@ +use cargo_test_support::paths; +use cargo_test_support::prelude::*; +use std::fs; + +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + let foo = &paths::root().join("foo.bar"); + fs::create_dir_all(foo).unwrap(); + + snapbox::cmd::Command::cargo_ui() + .arg_line("init") + .current_dir(foo) + .assert() + .code(101) + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert!(!foo.join("Cargo.toml").is_file()); +} diff --git a/src/tools/cargo/tests/testsuite/init/invalid_dir_name/stderr.log b/src/tools/cargo/tests/testsuite/init/invalid_dir_name/stderr.log new file mode 100644 index 000000000..86d2c665f --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/invalid_dir_name/stderr.log @@ -0,0 +1,8 @@ +error: invalid character `.` in package name: `foo.bar`, characters must be Unicode XID characters (numbers, `-`, `_`, or most letters) +If you need a package name to not match the directory name, consider using --name flag. +If you need a binary with the name "foo.bar", use a valid package name, and set the binary name to be different from the package. This can be done by setting the binary filename to `src/bin/foo.bar.rs` or change the name in Cargo.toml with: + + [[bin]] + name = "foo.bar" + path = "src/main.rs" + diff --git a/src/tools/cargo/tests/testsuite/init/invalid_dir_name/stdout.log b/src/tools/cargo/tests/testsuite/init/invalid_dir_name/stdout.log new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/invalid_dir_name/stdout.log diff --git a/src/tools/cargo/tests/testsuite/init/lib_already_exists_nosrc/in/lib.rs b/src/tools/cargo/tests/testsuite/init/lib_already_exists_nosrc/in/lib.rs new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/lib_already_exists_nosrc/in/lib.rs diff --git a/src/tools/cargo/tests/testsuite/init/lib_already_exists_nosrc/mod.rs b/src/tools/cargo/tests/testsuite/init/lib_already_exists_nosrc/mod.rs new file mode 100644 index 000000000..d3e8e66df --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/lib_already_exists_nosrc/mod.rs @@ -0,0 +1,22 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::prelude::*; +use cargo_test_support::Project; + +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = &project.root(); + + snapbox::cmd::Command::cargo_ui() + .arg_line("init --vcs none") + .current_dir(project_root) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), project_root); + assert!(!project_root.join("src/main.rs").is_file()); +} diff --git a/src/tools/cargo/tests/testsuite/init/lib_already_exists_nosrc/out/Cargo.toml b/src/tools/cargo/tests/testsuite/init/lib_already_exists_nosrc/out/Cargo.toml new file mode 100644 index 000000000..39e95fe94 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/lib_already_exists_nosrc/out/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "case" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] + +[lib] +name = "case" +path = "lib.rs" diff --git a/src/tools/cargo/tests/testsuite/init/lib_already_exists_nosrc/out/lib.rs b/src/tools/cargo/tests/testsuite/init/lib_already_exists_nosrc/out/lib.rs new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/lib_already_exists_nosrc/out/lib.rs diff --git a/src/tools/cargo/tests/testsuite/init/lib_already_exists_nosrc/stderr.log b/src/tools/cargo/tests/testsuite/init/lib_already_exists_nosrc/stderr.log new file mode 100644 index 000000000..f459bf226 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/lib_already_exists_nosrc/stderr.log @@ -0,0 +1 @@ + Created library package diff --git a/src/tools/cargo/tests/testsuite/init/lib_already_exists_nosrc/stdout.log b/src/tools/cargo/tests/testsuite/init/lib_already_exists_nosrc/stdout.log new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/lib_already_exists_nosrc/stdout.log diff --git a/src/tools/cargo/tests/testsuite/init/lib_already_exists_src/in/src/lib.rs b/src/tools/cargo/tests/testsuite/init/lib_already_exists_src/in/src/lib.rs new file mode 100644 index 000000000..59760b549 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/lib_already_exists_src/in/src/lib.rs @@ -0,0 +1 @@ +fn f() {} diff --git a/src/tools/cargo/tests/testsuite/init/lib_already_exists_src/mod.rs b/src/tools/cargo/tests/testsuite/init/lib_already_exists_src/mod.rs new file mode 100644 index 000000000..d3e8e66df --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/lib_already_exists_src/mod.rs @@ -0,0 +1,22 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::prelude::*; +use cargo_test_support::Project; + +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = &project.root(); + + snapbox::cmd::Command::cargo_ui() + .arg_line("init --vcs none") + .current_dir(project_root) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), project_root); + assert!(!project_root.join("src/main.rs").is_file()); +} diff --git a/src/tools/cargo/tests/testsuite/init/lib_already_exists_src/out/Cargo.toml b/src/tools/cargo/tests/testsuite/init/lib_already_exists_src/out/Cargo.toml new file mode 100644 index 000000000..dcdb8da2c --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/lib_already_exists_src/out/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "case" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/tools/cargo/tests/testsuite/init/lib_already_exists_src/out/src/lib.rs b/src/tools/cargo/tests/testsuite/init/lib_already_exists_src/out/src/lib.rs new file mode 100644 index 000000000..59760b549 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/lib_already_exists_src/out/src/lib.rs @@ -0,0 +1 @@ +fn f() {} diff --git a/src/tools/cargo/tests/testsuite/init/lib_already_exists_src/stderr.log b/src/tools/cargo/tests/testsuite/init/lib_already_exists_src/stderr.log new file mode 100644 index 000000000..f459bf226 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/lib_already_exists_src/stderr.log @@ -0,0 +1 @@ + Created library package diff --git a/src/tools/cargo/tests/testsuite/init/lib_already_exists_src/stdout.log b/src/tools/cargo/tests/testsuite/init/lib_already_exists_src/stdout.log new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/lib_already_exists_src/stdout.log diff --git a/src/tools/cargo/tests/testsuite/init/mercurial_autodetect/mod.rs b/src/tools/cargo/tests/testsuite/init/mercurial_autodetect/mod.rs new file mode 100644 index 000000000..d45ba868a --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/mercurial_autodetect/mod.rs @@ -0,0 +1,22 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::prelude::*; +use cargo_test_support::Project; + +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = &project.root(); + + snapbox::cmd::Command::cargo_ui() + .arg_line("init --lib") + .current_dir(project_root) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), project_root); + assert!(!project_root.join(".git").is_dir()); +} diff --git a/src/tools/cargo/tests/testsuite/init/mercurial_autodetect/out/Cargo.toml b/src/tools/cargo/tests/testsuite/init/mercurial_autodetect/out/Cargo.toml new file mode 100644 index 000000000..dcdb8da2c --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/mercurial_autodetect/out/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "case" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/tools/cargo/tests/testsuite/init/mercurial_autodetect/out/src/lib.rs b/src/tools/cargo/tests/testsuite/init/mercurial_autodetect/out/src/lib.rs new file mode 100644 index 000000000..7d12d9af8 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/mercurial_autodetect/out/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +} diff --git a/src/tools/cargo/tests/testsuite/init/mercurial_autodetect/stderr.log b/src/tools/cargo/tests/testsuite/init/mercurial_autodetect/stderr.log new file mode 100644 index 000000000..f459bf226 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/mercurial_autodetect/stderr.log @@ -0,0 +1 @@ + Created library package diff --git a/src/tools/cargo/tests/testsuite/init/mercurial_autodetect/stdout.log b/src/tools/cargo/tests/testsuite/init/mercurial_autodetect/stdout.log new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/mercurial_autodetect/stdout.log diff --git a/src/tools/cargo/tests/testsuite/init/mod.rs b/src/tools/cargo/tests/testsuite/init/mod.rs new file mode 100644 index 000000000..99df9d39d --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/mod.rs @@ -0,0 +1,42 @@ +//! Tests for the `cargo init` command. + +mod auto_git; +mod bin_already_exists_explicit; +mod bin_already_exists_explicit_nosrc; +mod bin_already_exists_implicit; +mod bin_already_exists_implicit_namenosrc; +mod bin_already_exists_implicit_namesrc; +mod bin_already_exists_implicit_nosrc; +mod both_lib_and_bin; +mod cant_create_library_when_both_binlib_present; +mod confused_by_multiple_lib_files; +mod creates_binary_when_both_binlib_present; +mod creates_binary_when_instructed_and_has_lib_file; +mod creates_library_when_instructed_and_has_bin_file; +mod explicit_bin_with_git; +mod formats_source; +mod fossil_autodetect; +mod git_autodetect; +mod git_ignore_exists_no_conflicting_entries; +mod ignores_failure_to_format_source; +mod inferred_bin_with_git; +mod inferred_lib_with_git; +mod invalid_dir_name; +mod lib_already_exists_nosrc; +mod lib_already_exists_src; +mod mercurial_autodetect; +mod multibin_project_name_clash; +#[cfg(not(windows))] +mod no_filename; +#[cfg(unix)] +mod path_contains_separator; +mod pijul_autodetect; +mod reserved_name; +mod simple_bin; +mod simple_git; +mod simple_git_ignore_exists; +mod simple_hg; +mod simple_hg_ignore_exists; +mod simple_lib; +mod unknown_flags; +mod with_argument; diff --git a/src/tools/cargo/tests/testsuite/init/multibin_project_name_clash/in/case.rs b/src/tools/cargo/tests/testsuite/init/multibin_project_name_clash/in/case.rs new file mode 100644 index 000000000..b31221118 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/multibin_project_name_clash/in/case.rs @@ -0,0 +1 @@ +fn main() { println!("foo.rs"); } diff --git a/src/tools/cargo/tests/testsuite/init/multibin_project_name_clash/in/main.rs b/src/tools/cargo/tests/testsuite/init/multibin_project_name_clash/in/main.rs new file mode 100644 index 000000000..7937627b9 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/multibin_project_name_clash/in/main.rs @@ -0,0 +1 @@ +fn main() { println!("main.rs"); } diff --git a/src/tools/cargo/tests/testsuite/init/multibin_project_name_clash/mod.rs b/src/tools/cargo/tests/testsuite/init/multibin_project_name_clash/mod.rs new file mode 100644 index 000000000..fdd4476d9 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/multibin_project_name_clash/mod.rs @@ -0,0 +1,22 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::prelude::*; +use cargo_test_support::Project; + +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = &project.root(); + + snapbox::cmd::Command::cargo_ui() + .arg_line("init --lib --vcs none") + .current_dir(project_root) + .assert() + .code(101) + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), project_root); + assert!(!project_root.join("Cargo.toml").is_file()); +} diff --git a/src/tools/cargo/tests/testsuite/init/multibin_project_name_clash/out/case.rs b/src/tools/cargo/tests/testsuite/init/multibin_project_name_clash/out/case.rs new file mode 100644 index 000000000..b31221118 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/multibin_project_name_clash/out/case.rs @@ -0,0 +1 @@ +fn main() { println!("foo.rs"); } diff --git a/src/tools/cargo/tests/testsuite/init/multibin_project_name_clash/out/main.rs b/src/tools/cargo/tests/testsuite/init/multibin_project_name_clash/out/main.rs new file mode 100644 index 000000000..7937627b9 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/multibin_project_name_clash/out/main.rs @@ -0,0 +1 @@ +fn main() { println!("main.rs"); } diff --git a/src/tools/cargo/tests/testsuite/init/multibin_project_name_clash/stderr.log b/src/tools/cargo/tests/testsuite/init/multibin_project_name_clash/stderr.log new file mode 100644 index 000000000..21a1dabee --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/multibin_project_name_clash/stderr.log @@ -0,0 +1,4 @@ +error: multiple possible binary sources found: + main.rs + case.rs +cannot automatically generate Cargo.toml as the main target would be ambiguous diff --git a/src/tools/cargo/tests/testsuite/init/multibin_project_name_clash/stdout.log b/src/tools/cargo/tests/testsuite/init/multibin_project_name_clash/stdout.log new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/multibin_project_name_clash/stdout.log diff --git a/src/tools/cargo/tests/testsuite/init/no_filename/mod.rs b/src/tools/cargo/tests/testsuite/init/no_filename/mod.rs new file mode 100644 index 000000000..8edfd2823 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/no_filename/mod.rs @@ -0,0 +1,16 @@ +use cargo_test_support::paths; +use cargo_test_support::prelude::*; + +use cargo_test_support::curr_dir; + +#[cfg(not(windows))] +#[cargo_test] +fn case() { + snapbox::cmd::Command::cargo_ui() + .arg_line("init /") + .current_dir(paths::root()) + .assert() + .code(101) + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); +} diff --git a/src/tools/cargo/tests/testsuite/init/no_filename/stderr.log b/src/tools/cargo/tests/testsuite/init/no_filename/stderr.log new file mode 100644 index 000000000..bd087ec90 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/no_filename/stderr.log @@ -0,0 +1 @@ +error: cannot auto-detect package name from path "/" ; use --name to override diff --git a/src/tools/cargo/tests/testsuite/init/no_filename/stdout.log b/src/tools/cargo/tests/testsuite/init/no_filename/stdout.log new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/no_filename/stdout.log diff --git a/src/tools/cargo/tests/testsuite/init/path_contains_separator/in/.keep b/src/tools/cargo/tests/testsuite/init/path_contains_separator/in/.keep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/path_contains_separator/in/.keep diff --git a/src/tools/cargo/tests/testsuite/init/path_contains_separator/mod.rs b/src/tools/cargo/tests/testsuite/init/path_contains_separator/mod.rs new file mode 100644 index 000000000..0a12f4269 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/path_contains_separator/mod.rs @@ -0,0 +1,26 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::prelude::*; +use cargo_test_support::{t, Project}; + +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = &project.root().join("test:ing"); + + if !project_root.exists() { + t!(std::fs::create_dir(&project_root)); + } + + snapbox::cmd::Command::cargo_ui() + .arg_line("init --bin --vcs none --edition 2015 --name testing") + .current_dir(project_root) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), project_root); + assert!(!project_root.join(".gitignore").is_file()); +} diff --git a/src/tools/cargo/tests/testsuite/init/path_contains_separator/out/Cargo.toml b/src/tools/cargo/tests/testsuite/init/path_contains_separator/out/Cargo.toml new file mode 100644 index 000000000..11465f1fc --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/path_contains_separator/out/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "testing" +version = "0.1.0" +edition = "2015" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/tools/cargo/tests/testsuite/init/path_contains_separator/out/src/main.rs b/src/tools/cargo/tests/testsuite/init/path_contains_separator/out/src/main.rs new file mode 100644 index 000000000..e7a11a969 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/path_contains_separator/out/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/src/tools/cargo/tests/testsuite/init/path_contains_separator/stderr.log b/src/tools/cargo/tests/testsuite/init/path_contains_separator/stderr.log new file mode 100644 index 000000000..d7947aea2 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/path_contains_separator/stderr.log @@ -0,0 +1,3 @@ +warning: the path `[ROOT]/case/test:ing/.` contains invalid PATH characters (usually `:`, `;`, or `"`) +It is recommended to use a different name to avoid problems. + Created binary (application) package diff --git a/src/tools/cargo/tests/testsuite/init/path_contains_separator/stdout.log b/src/tools/cargo/tests/testsuite/init/path_contains_separator/stdout.log new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/path_contains_separator/stdout.log diff --git a/src/tools/cargo/tests/testsuite/init/pijul_autodetect/in/.pijul/.keep b/src/tools/cargo/tests/testsuite/init/pijul_autodetect/in/.pijul/.keep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/pijul_autodetect/in/.pijul/.keep diff --git a/src/tools/cargo/tests/testsuite/init/pijul_autodetect/mod.rs b/src/tools/cargo/tests/testsuite/init/pijul_autodetect/mod.rs new file mode 100644 index 000000000..d45ba868a --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/pijul_autodetect/mod.rs @@ -0,0 +1,22 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::prelude::*; +use cargo_test_support::Project; + +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = &project.root(); + + snapbox::cmd::Command::cargo_ui() + .arg_line("init --lib") + .current_dir(project_root) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), project_root); + assert!(!project_root.join(".git").is_dir()); +} diff --git a/src/tools/cargo/tests/testsuite/init/pijul_autodetect/out/.ignore b/src/tools/cargo/tests/testsuite/init/pijul_autodetect/out/.ignore new file mode 100644 index 000000000..4fffb2f89 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/pijul_autodetect/out/.ignore @@ -0,0 +1,2 @@ +/target +/Cargo.lock diff --git a/src/tools/cargo/tests/testsuite/init/pijul_autodetect/out/Cargo.toml b/src/tools/cargo/tests/testsuite/init/pijul_autodetect/out/Cargo.toml new file mode 100644 index 000000000..dcdb8da2c --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/pijul_autodetect/out/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "case" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/tools/cargo/tests/testsuite/init/pijul_autodetect/out/src/lib.rs b/src/tools/cargo/tests/testsuite/init/pijul_autodetect/out/src/lib.rs new file mode 100644 index 000000000..7d12d9af8 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/pijul_autodetect/out/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +} diff --git a/src/tools/cargo/tests/testsuite/init/pijul_autodetect/stderr.log b/src/tools/cargo/tests/testsuite/init/pijul_autodetect/stderr.log new file mode 100644 index 000000000..f459bf226 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/pijul_autodetect/stderr.log @@ -0,0 +1 @@ + Created library package diff --git a/src/tools/cargo/tests/testsuite/init/pijul_autodetect/stdout.log b/src/tools/cargo/tests/testsuite/init/pijul_autodetect/stdout.log new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/pijul_autodetect/stdout.log diff --git a/src/tools/cargo/tests/testsuite/init/reserved_name/mod.rs b/src/tools/cargo/tests/testsuite/init/reserved_name/mod.rs new file mode 100644 index 000000000..cc65fd0a1 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/reserved_name/mod.rs @@ -0,0 +1,21 @@ +use cargo_test_support::paths; +use cargo_test_support::prelude::*; +use std::fs; + +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + let project_root = &paths::root().join("test"); + fs::create_dir_all(project_root).unwrap(); + + snapbox::cmd::Command::cargo_ui() + .arg_line("init") + .current_dir(project_root) + .assert() + .code(101) + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert!(!project_root.join("Cargo.toml").is_file()); +} diff --git a/src/tools/cargo/tests/testsuite/init/reserved_name/stderr.log b/src/tools/cargo/tests/testsuite/init/reserved_name/stderr.log new file mode 100644 index 000000000..748971bdf --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/reserved_name/stderr.log @@ -0,0 +1,8 @@ +error: the name `test` cannot be used as a package name, it conflicts with Rust's built-in test library +If you need a package name to not match the directory name, consider using --name flag. +If you need a binary with the name "test", use a valid package name, and set the binary name to be different from the package. This can be done by setting the binary filename to `src/bin/test.rs` or change the name in Cargo.toml with: + + [[bin]] + name = "test" + path = "src/main.rs" + diff --git a/src/tools/cargo/tests/testsuite/init/reserved_name/stdout.log b/src/tools/cargo/tests/testsuite/init/reserved_name/stdout.log new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/reserved_name/stdout.log diff --git a/src/tools/cargo/tests/testsuite/init/simple_bin/in b/src/tools/cargo/tests/testsuite/init/simple_bin/in new file mode 120000 index 000000000..1202506b6 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/simple_bin/in @@ -0,0 +1 @@ +../empty_dir
\ No newline at end of file diff --git a/src/tools/cargo/tests/testsuite/init/simple_bin/mod.rs b/src/tools/cargo/tests/testsuite/init/simple_bin/mod.rs new file mode 100644 index 000000000..eaf0955f9 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/simple_bin/mod.rs @@ -0,0 +1,29 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::prelude::*; +use cargo_test_support::Project; + +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = &project.root(); + + snapbox::cmd::Command::cargo_ui() + .arg_line("init --bin --vcs none --edition 2015") + .current_dir(project_root) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), project_root); + assert!(!project_root.join(".gitignore").is_file()); + + snapbox::cmd::Command::cargo_ui() + .current_dir(project_root) + .arg("build") + .assert() + .success(); + assert!(project.bin("case").is_file()); +} diff --git a/src/tools/cargo/tests/testsuite/init/simple_bin/out/Cargo.toml b/src/tools/cargo/tests/testsuite/init/simple_bin/out/Cargo.toml new file mode 100644 index 000000000..a6269fdcd --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/simple_bin/out/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "case" +version = "0.1.0" +edition = "2015" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/tools/cargo/tests/testsuite/init/simple_bin/out/src/main.rs b/src/tools/cargo/tests/testsuite/init/simple_bin/out/src/main.rs new file mode 100644 index 000000000..e7a11a969 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/simple_bin/out/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/src/tools/cargo/tests/testsuite/init/simple_bin/stderr.log b/src/tools/cargo/tests/testsuite/init/simple_bin/stderr.log new file mode 100644 index 000000000..3847e4e4a --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/simple_bin/stderr.log @@ -0,0 +1 @@ + Created binary (application) package diff --git a/src/tools/cargo/tests/testsuite/init/simple_bin/stdout.log b/src/tools/cargo/tests/testsuite/init/simple_bin/stdout.log new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/simple_bin/stdout.log diff --git a/src/tools/cargo/tests/testsuite/init/simple_git/in b/src/tools/cargo/tests/testsuite/init/simple_git/in new file mode 120000 index 000000000..1202506b6 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/simple_git/in @@ -0,0 +1 @@ +../empty_dir
\ No newline at end of file diff --git a/src/tools/cargo/tests/testsuite/init/simple_git/mod.rs b/src/tools/cargo/tests/testsuite/init/simple_git/mod.rs new file mode 100644 index 000000000..c373fe2a2 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/simple_git/mod.rs @@ -0,0 +1,22 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::prelude::*; +use cargo_test_support::Project; + +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = &project.root(); + + snapbox::cmd::Command::cargo_ui() + .arg_line("init --lib --vcs git") + .current_dir(project_root) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), project_root); + assert!(project_root.join(".git").is_dir()); +} diff --git a/src/tools/cargo/tests/testsuite/init/simple_git/out/Cargo.toml b/src/tools/cargo/tests/testsuite/init/simple_git/out/Cargo.toml new file mode 100644 index 000000000..dcdb8da2c --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/simple_git/out/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "case" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/tools/cargo/tests/testsuite/init/simple_git/out/src/lib.rs b/src/tools/cargo/tests/testsuite/init/simple_git/out/src/lib.rs new file mode 100644 index 000000000..7d12d9af8 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/simple_git/out/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +} diff --git a/src/tools/cargo/tests/testsuite/init/simple_git/stderr.log b/src/tools/cargo/tests/testsuite/init/simple_git/stderr.log new file mode 100644 index 000000000..f459bf226 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/simple_git/stderr.log @@ -0,0 +1 @@ + Created library package diff --git a/src/tools/cargo/tests/testsuite/init/simple_git/stdout.log b/src/tools/cargo/tests/testsuite/init/simple_git/stdout.log new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/simple_git/stdout.log diff --git a/src/tools/cargo/tests/testsuite/init/simple_git_ignore_exists/mod.rs b/src/tools/cargo/tests/testsuite/init/simple_git_ignore_exists/mod.rs new file mode 100644 index 000000000..142e86efd --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/simple_git_ignore_exists/mod.rs @@ -0,0 +1,28 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::prelude::*; +use cargo_test_support::Project; + +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = &project.root(); + + snapbox::cmd::Command::cargo_ui() + .arg_line("init --lib --edition 2015") + .current_dir(project_root) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), project_root); + assert!(project_root.join(".git").is_dir()); + + snapbox::cmd::Command::cargo_ui() + .current_dir(project_root) + .arg("build") + .assert() + .success(); +} diff --git a/src/tools/cargo/tests/testsuite/init/simple_git_ignore_exists/out/Cargo.toml b/src/tools/cargo/tests/testsuite/init/simple_git_ignore_exists/out/Cargo.toml new file mode 100644 index 000000000..a6269fdcd --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/simple_git_ignore_exists/out/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "case" +version = "0.1.0" +edition = "2015" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/tools/cargo/tests/testsuite/init/simple_git_ignore_exists/out/src/lib.rs b/src/tools/cargo/tests/testsuite/init/simple_git_ignore_exists/out/src/lib.rs new file mode 100644 index 000000000..7d12d9af8 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/simple_git_ignore_exists/out/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +} diff --git a/src/tools/cargo/tests/testsuite/init/simple_git_ignore_exists/stderr.log b/src/tools/cargo/tests/testsuite/init/simple_git_ignore_exists/stderr.log new file mode 100644 index 000000000..f459bf226 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/simple_git_ignore_exists/stderr.log @@ -0,0 +1 @@ + Created library package diff --git a/src/tools/cargo/tests/testsuite/init/simple_git_ignore_exists/stdout.log b/src/tools/cargo/tests/testsuite/init/simple_git_ignore_exists/stdout.log new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/simple_git_ignore_exists/stdout.log diff --git a/src/tools/cargo/tests/testsuite/init/simple_hg/in b/src/tools/cargo/tests/testsuite/init/simple_hg/in new file mode 120000 index 000000000..1202506b6 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/simple_hg/in @@ -0,0 +1 @@ +../empty_dir
\ No newline at end of file diff --git a/src/tools/cargo/tests/testsuite/init/simple_hg/mod.rs b/src/tools/cargo/tests/testsuite/init/simple_hg/mod.rs new file mode 100644 index 000000000..1d6765453 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/simple_hg/mod.rs @@ -0,0 +1,22 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::prelude::*; +use cargo_test_support::Project; + +use cargo_test_support::curr_dir; + +#[cargo_test(requires_hg)] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = &project.root(); + + snapbox::cmd::Command::cargo_ui() + .arg_line("init --lib --vcs hg") + .current_dir(project_root) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), project_root); + assert!(!project_root.join(".git").is_dir()); +} diff --git a/src/tools/cargo/tests/testsuite/init/simple_hg/out/Cargo.toml b/src/tools/cargo/tests/testsuite/init/simple_hg/out/Cargo.toml new file mode 100644 index 000000000..dcdb8da2c --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/simple_hg/out/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "case" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/tools/cargo/tests/testsuite/init/simple_hg/out/src/lib.rs b/src/tools/cargo/tests/testsuite/init/simple_hg/out/src/lib.rs new file mode 100644 index 000000000..7d12d9af8 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/simple_hg/out/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +} diff --git a/src/tools/cargo/tests/testsuite/init/simple_hg/stderr.log b/src/tools/cargo/tests/testsuite/init/simple_hg/stderr.log new file mode 100644 index 000000000..f459bf226 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/simple_hg/stderr.log @@ -0,0 +1 @@ + Created library package diff --git a/src/tools/cargo/tests/testsuite/init/simple_hg/stdout.log b/src/tools/cargo/tests/testsuite/init/simple_hg/stdout.log new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/simple_hg/stdout.log diff --git a/src/tools/cargo/tests/testsuite/init/simple_hg_ignore_exists/mod.rs b/src/tools/cargo/tests/testsuite/init/simple_hg_ignore_exists/mod.rs new file mode 100644 index 000000000..d45ba868a --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/simple_hg_ignore_exists/mod.rs @@ -0,0 +1,22 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::prelude::*; +use cargo_test_support::Project; + +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = &project.root(); + + snapbox::cmd::Command::cargo_ui() + .arg_line("init --lib") + .current_dir(project_root) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), project_root); + assert!(!project_root.join(".git").is_dir()); +} diff --git a/src/tools/cargo/tests/testsuite/init/simple_hg_ignore_exists/out/Cargo.toml b/src/tools/cargo/tests/testsuite/init/simple_hg_ignore_exists/out/Cargo.toml new file mode 100644 index 000000000..dcdb8da2c --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/simple_hg_ignore_exists/out/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "case" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/tools/cargo/tests/testsuite/init/simple_hg_ignore_exists/out/src/lib.rs b/src/tools/cargo/tests/testsuite/init/simple_hg_ignore_exists/out/src/lib.rs new file mode 100644 index 000000000..7d12d9af8 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/simple_hg_ignore_exists/out/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +} diff --git a/src/tools/cargo/tests/testsuite/init/simple_hg_ignore_exists/stderr.log b/src/tools/cargo/tests/testsuite/init/simple_hg_ignore_exists/stderr.log new file mode 100644 index 000000000..f459bf226 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/simple_hg_ignore_exists/stderr.log @@ -0,0 +1 @@ + Created library package diff --git a/src/tools/cargo/tests/testsuite/init/simple_hg_ignore_exists/stdout.log b/src/tools/cargo/tests/testsuite/init/simple_hg_ignore_exists/stdout.log new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/simple_hg_ignore_exists/stdout.log diff --git a/src/tools/cargo/tests/testsuite/init/simple_lib/in b/src/tools/cargo/tests/testsuite/init/simple_lib/in new file mode 120000 index 000000000..1202506b6 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/simple_lib/in @@ -0,0 +1 @@ +../empty_dir
\ No newline at end of file diff --git a/src/tools/cargo/tests/testsuite/init/simple_lib/mod.rs b/src/tools/cargo/tests/testsuite/init/simple_lib/mod.rs new file mode 100644 index 000000000..d6bae5167 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/simple_lib/mod.rs @@ -0,0 +1,29 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::prelude::*; +use cargo_test_support::Project; + +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = &project.root(); + + snapbox::cmd::Command::cargo_ui() + .arg_line("init --lib --vcs none --edition 2015") + .current_dir(project_root) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), project_root); + assert!(!project_root.join(".gitignore").is_file()); + + snapbox::cmd::Command::cargo_ui() + .current_dir(project_root) + .arg("build") + .assert() + .success(); + assert!(!project.bin("foo").is_file()); +} diff --git a/src/tools/cargo/tests/testsuite/init/simple_lib/out/Cargo.toml b/src/tools/cargo/tests/testsuite/init/simple_lib/out/Cargo.toml new file mode 100644 index 000000000..a6269fdcd --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/simple_lib/out/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "case" +version = "0.1.0" +edition = "2015" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/tools/cargo/tests/testsuite/init/simple_lib/out/src/lib.rs b/src/tools/cargo/tests/testsuite/init/simple_lib/out/src/lib.rs new file mode 100644 index 000000000..7d12d9af8 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/simple_lib/out/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +} diff --git a/src/tools/cargo/tests/testsuite/init/simple_lib/stderr.log b/src/tools/cargo/tests/testsuite/init/simple_lib/stderr.log new file mode 100644 index 000000000..f459bf226 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/simple_lib/stderr.log @@ -0,0 +1 @@ + Created library package diff --git a/src/tools/cargo/tests/testsuite/init/simple_lib/stdout.log b/src/tools/cargo/tests/testsuite/init/simple_lib/stdout.log new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/simple_lib/stdout.log diff --git a/src/tools/cargo/tests/testsuite/init/unknown_flags/mod.rs b/src/tools/cargo/tests/testsuite/init/unknown_flags/mod.rs new file mode 100644 index 000000000..4289b4b9e --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/unknown_flags/mod.rs @@ -0,0 +1,15 @@ +use cargo_test_support::paths; +use cargo_test_support::prelude::*; + +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + snapbox::cmd::Command::cargo_ui() + .arg_line("init foo --flag") + .current_dir(paths::root()) + .assert() + .code(1) + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); +} diff --git a/src/tools/cargo/tests/testsuite/init/unknown_flags/stderr.log b/src/tools/cargo/tests/testsuite/init/unknown_flags/stderr.log new file mode 100644 index 000000000..980e8acd8 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/unknown_flags/stderr.log @@ -0,0 +1,7 @@ +error: unexpected argument '--flag' found + + tip: to pass '--flag' as a value, use '-- --flag' + +Usage: cargo[EXE] init <path> + +For more information, try '--help'. diff --git a/src/tools/cargo/tests/testsuite/init/unknown_flags/stdout.log b/src/tools/cargo/tests/testsuite/init/unknown_flags/stdout.log new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/unknown_flags/stdout.log diff --git a/src/tools/cargo/tests/testsuite/init/with_argument/in/foo/.keep b/src/tools/cargo/tests/testsuite/init/with_argument/in/foo/.keep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/with_argument/in/foo/.keep diff --git a/src/tools/cargo/tests/testsuite/init/with_argument/mod.rs b/src/tools/cargo/tests/testsuite/init/with_argument/mod.rs new file mode 100644 index 000000000..0b5e342a1 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/with_argument/mod.rs @@ -0,0 +1,21 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::prelude::*; +use cargo_test_support::Project; + +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = &project.root(); + + snapbox::cmd::Command::cargo_ui() + .arg_line("init foo --vcs none") + .current_dir(project_root) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), project_root); +} diff --git a/src/tools/cargo/tests/testsuite/init/with_argument/out/foo/Cargo.toml b/src/tools/cargo/tests/testsuite/init/with_argument/out/foo/Cargo.toml new file mode 100644 index 000000000..1d9cfe317 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/with_argument/out/foo/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "foo" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/tools/cargo/tests/testsuite/init/with_argument/out/foo/src/main.rs b/src/tools/cargo/tests/testsuite/init/with_argument/out/foo/src/main.rs new file mode 100644 index 000000000..e7a11a969 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/with_argument/out/foo/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/src/tools/cargo/tests/testsuite/init/with_argument/stderr.log b/src/tools/cargo/tests/testsuite/init/with_argument/stderr.log new file mode 100644 index 000000000..3847e4e4a --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/with_argument/stderr.log @@ -0,0 +1 @@ + Created binary (application) package diff --git a/src/tools/cargo/tests/testsuite/init/with_argument/stdout.log b/src/tools/cargo/tests/testsuite/init/with_argument/stdout.log new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/cargo/tests/testsuite/init/with_argument/stdout.log |