From 89c6a6fcc03ece3c78a97f834dc2d4810c120b17 Mon Sep 17 00:00:00 2001 From: hi-rustin Date: Wed, 3 May 2023 13:01:36 +0800 Subject: [PATCH] Add tests for `inherit_workspace_package_table` Signed-off-by: hi-rustin --- .../Cargo.toml | 21 ++++++++++++++++++ .../README.md | 0 .../src/lib.rs | 14 ++++++++++++ .../inherit_workspace_package_table/in | 1 + .../inherit_workspace_package_table/mod.rs | 22 +++++++++++++++++++ .../out/Cargo.toml | 21 ++++++++++++++++++ .../out/crates/foo/Cargo.toml | 20 +++++++++++++++++ .../out/crates/foo/src/main.rs | 3 +++ .../out/src/lib.rs | 14 ++++++++++++ .../stderr.log | 1 + .../stdout.log | 0 .../in | 1 + .../mod.rs | 22 +++++++++++++++++++ .../out/Cargo.toml | 21 ++++++++++++++++++ .../out/crates/foo/Cargo.toml | 20 +++++++++++++++++ .../out/crates/foo/src/main.rs | 3 +++ .../out/src/lib.rs | 14 ++++++++++++ .../stderr.log | 1 + .../stdout.log | 0 .../in | 1 + .../mod.rs | 22 +++++++++++++++++++ .../out/Cargo.toml | 21 ++++++++++++++++++ .../out/crates/foo/Cargo.toml | 20 +++++++++++++++++ .../out/crates/foo/src/main.rs | 3 +++ .../out/src/lib.rs | 14 ++++++++++++ .../stderr.log | 1 + .../stdout.log | 0 .../in/Cargo.toml | 20 +++++++++++++++++ .../in/README.md | 0 .../in/src/lib.rs | 14 ++++++++++++ .../mod.rs | 22 +++++++++++++++++++ .../out/Cargo.toml | 20 +++++++++++++++++ .../out/crates/foo/Cargo.toml | 20 +++++++++++++++++ .../out/crates/foo/src/main.rs | 3 +++ .../out/src/lib.rs | 14 ++++++++++++ .../stderr.log | 1 + .../stdout.log | 0 tests/testsuite/cargo_new/mod.rs | 5 +++++ .../in/Cargo.toml | 15 +++++++++++++ .../in/README.md | 0 .../in/src/lib.rs | 14 ++++++++++++ .../mod.rs | 22 +++++++++++++++++++ .../out/Cargo.toml | 15 +++++++++++++ .../out/foo/Cargo.toml | 8 +++++++ .../out/foo/src/main.rs | 3 +++ .../out/src/lib.rs | 14 ++++++++++++ .../stderr.log | 9 ++++++++ .../stdout.log | 0 tests/testsuite/main.rs | 2 +- 49 files changed, 501 insertions(+), 1 deletion(-) create mode 100644 tests/testsuite/cargo_new/inherit_workspace_package_table.in/Cargo.toml create mode 100644 tests/testsuite/cargo_new/inherit_workspace_package_table.in/README.md create mode 100644 tests/testsuite/cargo_new/inherit_workspace_package_table.in/src/lib.rs create mode 120000 tests/testsuite/cargo_new/inherit_workspace_package_table/in create mode 100644 tests/testsuite/cargo_new/inherit_workspace_package_table/mod.rs create mode 100644 tests/testsuite/cargo_new/inherit_workspace_package_table/out/Cargo.toml create mode 100644 tests/testsuite/cargo_new/inherit_workspace_package_table/out/crates/foo/Cargo.toml create mode 100644 tests/testsuite/cargo_new/inherit_workspace_package_table/out/crates/foo/src/main.rs create mode 100644 tests/testsuite/cargo_new/inherit_workspace_package_table/out/src/lib.rs create mode 100644 tests/testsuite/cargo_new/inherit_workspace_package_table/stderr.log create mode 100644 tests/testsuite/cargo_new/inherit_workspace_package_table/stdout.log create mode 120000 tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/in create mode 100644 tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/mod.rs create mode 100644 tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/out/Cargo.toml create mode 100644 tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/out/crates/foo/Cargo.toml create mode 100644 tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/out/crates/foo/src/main.rs create mode 100644 tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/out/src/lib.rs create mode 100644 tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/stderr.log create mode 100644 tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/stdout.log create mode 120000 tests/testsuite/cargo_new/inherit_workspace_package_table_with_registry/in create mode 100644 tests/testsuite/cargo_new/inherit_workspace_package_table_with_registry/mod.rs create mode 100644 tests/testsuite/cargo_new/inherit_workspace_package_table_with_registry/out/Cargo.toml create mode 100644 tests/testsuite/cargo_new/inherit_workspace_package_table_with_registry/out/crates/foo/Cargo.toml create mode 100644 tests/testsuite/cargo_new/inherit_workspace_package_table_with_registry/out/crates/foo/src/main.rs create mode 100644 tests/testsuite/cargo_new/inherit_workspace_package_table_with_registry/out/src/lib.rs create mode 100644 tests/testsuite/cargo_new/inherit_workspace_package_table_with_registry/stderr.log create mode 100644 tests/testsuite/cargo_new/inherit_workspace_package_table_with_registry/stdout.log create mode 100644 tests/testsuite/cargo_new/inherit_workspace_package_table_without_version/in/Cargo.toml create mode 100644 tests/testsuite/cargo_new/inherit_workspace_package_table_without_version/in/README.md create mode 100644 tests/testsuite/cargo_new/inherit_workspace_package_table_without_version/in/src/lib.rs create mode 100644 tests/testsuite/cargo_new/inherit_workspace_package_table_without_version/mod.rs create mode 100644 tests/testsuite/cargo_new/inherit_workspace_package_table_without_version/out/Cargo.toml create mode 100644 tests/testsuite/cargo_new/inherit_workspace_package_table_without_version/out/crates/foo/Cargo.toml create mode 100644 tests/testsuite/cargo_new/inherit_workspace_package_table_without_version/out/crates/foo/src/main.rs create mode 100644 tests/testsuite/cargo_new/inherit_workspace_package_table_without_version/out/src/lib.rs create mode 100644 tests/testsuite/cargo_new/inherit_workspace_package_table_without_version/stderr.log create mode 100644 tests/testsuite/cargo_new/inherit_workspace_package_table_without_version/stdout.log create mode 100644 tests/testsuite/cargo_new/mod.rs create mode 100644 tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/in/Cargo.toml create mode 100644 tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/in/README.md create mode 100644 tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/in/src/lib.rs create mode 100644 tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/mod.rs create mode 100644 tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/out/Cargo.toml create mode 100644 tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/out/foo/Cargo.toml create mode 100644 tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/out/foo/src/main.rs create mode 100644 tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/out/src/lib.rs create mode 100644 tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/stderr.log create mode 100644 tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/stdout.log diff --git a/tests/testsuite/cargo_new/inherit_workspace_package_table.in/Cargo.toml b/tests/testsuite/cargo_new/inherit_workspace_package_table.in/Cargo.toml new file mode 100644 index 000000000000..b7a2e90363de --- /dev/null +++ b/tests/testsuite/cargo_new/inherit_workspace_package_table.in/Cargo.toml @@ -0,0 +1,21 @@ +[workspace] +members = [ + "crates/*", +] + +[workspace.package] +authors = ["Rustaceans"] +description = "foo" +edition = "2018" +homepage = "foo" +keywords = ["foo", "bar"] +readme = "README.md" +rust-version = "1.67.0" +categories = ["algorithms"] +documentation = "foo" +exclude = ["foo"] +include = ["foo"] +license = "MIT OR Apache-2.0" +publish = false +repository = "foo" +version = "1.2.3" diff --git a/tests/testsuite/cargo_new/inherit_workspace_package_table.in/README.md b/tests/testsuite/cargo_new/inherit_workspace_package_table.in/README.md new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/cargo_new/inherit_workspace_package_table.in/src/lib.rs b/tests/testsuite/cargo_new/inherit_workspace_package_table.in/src/lib.rs new file mode 100644 index 000000000000..7d12d9af8195 --- /dev/null +++ b/tests/testsuite/cargo_new/inherit_workspace_package_table.in/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/tests/testsuite/cargo_new/inherit_workspace_package_table/in b/tests/testsuite/cargo_new/inherit_workspace_package_table/in new file mode 120000 index 000000000000..aba551efe9a2 --- /dev/null +++ b/tests/testsuite/cargo_new/inherit_workspace_package_table/in @@ -0,0 +1 @@ +../inherit_workspace_package_table.in \ No newline at end of file diff --git a/tests/testsuite/cargo_new/inherit_workspace_package_table/mod.rs b/tests/testsuite/cargo_new/inherit_workspace_package_table/mod.rs new file mode 100644 index 000000000000..9b9642468464 --- /dev/null +++ b/tests/testsuite/cargo_new/inherit_workspace_package_table/mod.rs @@ -0,0 +1,22 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::curr_dir; +use cargo_test_support::CargoCommand; +use cargo_test_support::Project; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("new") + .args(["crates/foo"]) + .current_dir(cwd) + .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/tests/testsuite/cargo_new/inherit_workspace_package_table/out/Cargo.toml b/tests/testsuite/cargo_new/inherit_workspace_package_table/out/Cargo.toml new file mode 100644 index 000000000000..b7a2e90363de --- /dev/null +++ b/tests/testsuite/cargo_new/inherit_workspace_package_table/out/Cargo.toml @@ -0,0 +1,21 @@ +[workspace] +members = [ + "crates/*", +] + +[workspace.package] +authors = ["Rustaceans"] +description = "foo" +edition = "2018" +homepage = "foo" +keywords = ["foo", "bar"] +readme = "README.md" +rust-version = "1.67.0" +categories = ["algorithms"] +documentation = "foo" +exclude = ["foo"] +include = ["foo"] +license = "MIT OR Apache-2.0" +publish = false +repository = "foo" +version = "1.2.3" diff --git a/tests/testsuite/cargo_new/inherit_workspace_package_table/out/crates/foo/Cargo.toml b/tests/testsuite/cargo_new/inherit_workspace_package_table/out/crates/foo/Cargo.toml new file mode 100644 index 000000000000..32a220e8caad --- /dev/null +++ b/tests/testsuite/cargo_new/inherit_workspace_package_table/out/crates/foo/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "foo" +version.workspace = true +edition.workspace = true +publish.workspace = true +authors.workspace = true +categories.workspace = true +description.workspace = true +documentation.workspace = true +exclude.workspace = true +homepage.workspace = true +include.workspace = true +keywords.workspace = true +license.workspace = true +readme.workspace = true +repository.workspace = true +rust-version.workspace = true +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/tests/testsuite/cargo_new/inherit_workspace_package_table/out/crates/foo/src/main.rs b/tests/testsuite/cargo_new/inherit_workspace_package_table/out/crates/foo/src/main.rs new file mode 100644 index 000000000000..e7a11a969c03 --- /dev/null +++ b/tests/testsuite/cargo_new/inherit_workspace_package_table/out/crates/foo/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/tests/testsuite/cargo_new/inherit_workspace_package_table/out/src/lib.rs b/tests/testsuite/cargo_new/inherit_workspace_package_table/out/src/lib.rs new file mode 100644 index 000000000000..7d12d9af8195 --- /dev/null +++ b/tests/testsuite/cargo_new/inherit_workspace_package_table/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/tests/testsuite/cargo_new/inherit_workspace_package_table/stderr.log b/tests/testsuite/cargo_new/inherit_workspace_package_table/stderr.log new file mode 100644 index 000000000000..90150cdf5705 --- /dev/null +++ b/tests/testsuite/cargo_new/inherit_workspace_package_table/stderr.log @@ -0,0 +1 @@ + Created binary (application) `crates/foo` package diff --git a/tests/testsuite/cargo_new/inherit_workspace_package_table/stdout.log b/tests/testsuite/cargo_new/inherit_workspace_package_table/stdout.log new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/in b/tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/in new file mode 120000 index 000000000000..aba551efe9a2 --- /dev/null +++ b/tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/in @@ -0,0 +1 @@ +../inherit_workspace_package_table.in \ No newline at end of file diff --git a/tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/mod.rs b/tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/mod.rs new file mode 100644 index 000000000000..c3ac2d375275 --- /dev/null +++ b/tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/mod.rs @@ -0,0 +1,22 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::curr_dir; +use cargo_test_support::CargoCommand; +use cargo_test_support::Project; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("new") + .args(["crates/foo", "--edition", "2021"]) + .current_dir(cwd) + .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/tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/out/Cargo.toml b/tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/out/Cargo.toml new file mode 100644 index 000000000000..b7a2e90363de --- /dev/null +++ b/tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/out/Cargo.toml @@ -0,0 +1,21 @@ +[workspace] +members = [ + "crates/*", +] + +[workspace.package] +authors = ["Rustaceans"] +description = "foo" +edition = "2018" +homepage = "foo" +keywords = ["foo", "bar"] +readme = "README.md" +rust-version = "1.67.0" +categories = ["algorithms"] +documentation = "foo" +exclude = ["foo"] +include = ["foo"] +license = "MIT OR Apache-2.0" +publish = false +repository = "foo" +version = "1.2.3" diff --git a/tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/out/crates/foo/Cargo.toml b/tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/out/crates/foo/Cargo.toml new file mode 100644 index 000000000000..81ba57c664f0 --- /dev/null +++ b/tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/out/crates/foo/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "foo" +version.workspace = true +edition = "2021" +publish.workspace = true +authors.workspace = true +categories.workspace = true +description.workspace = true +documentation.workspace = true +exclude.workspace = true +homepage.workspace = true +include.workspace = true +keywords.workspace = true +license.workspace = true +readme.workspace = true +repository.workspace = true +rust-version.workspace = true +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/out/crates/foo/src/main.rs b/tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/out/crates/foo/src/main.rs new file mode 100644 index 000000000000..e7a11a969c03 --- /dev/null +++ b/tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/out/crates/foo/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/out/src/lib.rs b/tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/out/src/lib.rs new file mode 100644 index 000000000000..7d12d9af8195 --- /dev/null +++ b/tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/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/tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/stderr.log b/tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/stderr.log new file mode 100644 index 000000000000..90150cdf5705 --- /dev/null +++ b/tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/stderr.log @@ -0,0 +1 @@ + Created binary (application) `crates/foo` package diff --git a/tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/stdout.log b/tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/stdout.log new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/cargo_new/inherit_workspace_package_table_with_registry/in b/tests/testsuite/cargo_new/inherit_workspace_package_table_with_registry/in new file mode 120000 index 000000000000..aba551efe9a2 --- /dev/null +++ b/tests/testsuite/cargo_new/inherit_workspace_package_table_with_registry/in @@ -0,0 +1 @@ +../inherit_workspace_package_table.in \ No newline at end of file diff --git a/tests/testsuite/cargo_new/inherit_workspace_package_table_with_registry/mod.rs b/tests/testsuite/cargo_new/inherit_workspace_package_table_with_registry/mod.rs new file mode 100644 index 000000000000..16ec66ea216f --- /dev/null +++ b/tests/testsuite/cargo_new/inherit_workspace_package_table_with_registry/mod.rs @@ -0,0 +1,22 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::curr_dir; +use cargo_test_support::CargoCommand; +use cargo_test_support::Project; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("new") + .args(["crates/foo", "--registry", "foo"]) + .current_dir(cwd) + .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/tests/testsuite/cargo_new/inherit_workspace_package_table_with_registry/out/Cargo.toml b/tests/testsuite/cargo_new/inherit_workspace_package_table_with_registry/out/Cargo.toml new file mode 100644 index 000000000000..b7a2e90363de --- /dev/null +++ b/tests/testsuite/cargo_new/inherit_workspace_package_table_with_registry/out/Cargo.toml @@ -0,0 +1,21 @@ +[workspace] +members = [ + "crates/*", +] + +[workspace.package] +authors = ["Rustaceans"] +description = "foo" +edition = "2018" +homepage = "foo" +keywords = ["foo", "bar"] +readme = "README.md" +rust-version = "1.67.0" +categories = ["algorithms"] +documentation = "foo" +exclude = ["foo"] +include = ["foo"] +license = "MIT OR Apache-2.0" +publish = false +repository = "foo" +version = "1.2.3" diff --git a/tests/testsuite/cargo_new/inherit_workspace_package_table_with_registry/out/crates/foo/Cargo.toml b/tests/testsuite/cargo_new/inherit_workspace_package_table_with_registry/out/crates/foo/Cargo.toml new file mode 100644 index 000000000000..e2f3b68dd0f9 --- /dev/null +++ b/tests/testsuite/cargo_new/inherit_workspace_package_table_with_registry/out/crates/foo/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "foo" +version.workspace = true +edition.workspace = true +publish = ["foo"] +authors.workspace = true +categories.workspace = true +description.workspace = true +documentation.workspace = true +exclude.workspace = true +homepage.workspace = true +include.workspace = true +keywords.workspace = true +license.workspace = true +readme.workspace = true +repository.workspace = true +rust-version.workspace = true +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/tests/testsuite/cargo_new/inherit_workspace_package_table_with_registry/out/crates/foo/src/main.rs b/tests/testsuite/cargo_new/inherit_workspace_package_table_with_registry/out/crates/foo/src/main.rs new file mode 100644 index 000000000000..e7a11a969c03 --- /dev/null +++ b/tests/testsuite/cargo_new/inherit_workspace_package_table_with_registry/out/crates/foo/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/tests/testsuite/cargo_new/inherit_workspace_package_table_with_registry/out/src/lib.rs b/tests/testsuite/cargo_new/inherit_workspace_package_table_with_registry/out/src/lib.rs new file mode 100644 index 000000000000..7d12d9af8195 --- /dev/null +++ b/tests/testsuite/cargo_new/inherit_workspace_package_table_with_registry/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/tests/testsuite/cargo_new/inherit_workspace_package_table_with_registry/stderr.log b/tests/testsuite/cargo_new/inherit_workspace_package_table_with_registry/stderr.log new file mode 100644 index 000000000000..90150cdf5705 --- /dev/null +++ b/tests/testsuite/cargo_new/inherit_workspace_package_table_with_registry/stderr.log @@ -0,0 +1 @@ + Created binary (application) `crates/foo` package diff --git a/tests/testsuite/cargo_new/inherit_workspace_package_table_with_registry/stdout.log b/tests/testsuite/cargo_new/inherit_workspace_package_table_with_registry/stdout.log new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/cargo_new/inherit_workspace_package_table_without_version/in/Cargo.toml b/tests/testsuite/cargo_new/inherit_workspace_package_table_without_version/in/Cargo.toml new file mode 100644 index 000000000000..112fef55c0c8 --- /dev/null +++ b/tests/testsuite/cargo_new/inherit_workspace_package_table_without_version/in/Cargo.toml @@ -0,0 +1,20 @@ +[workspace] +members = [ + "crates/*", +] + +[workspace.package] +authors = ["Rustaceans"] +description = "foo" +edition = "2018" +homepage = "foo" +keywords = ["foo", "bar"] +readme = "README.md" +rust-version = "1.67.0" +categories = ["algorithms"] +documentation = "foo" +exclude = ["foo"] +include = ["foo"] +license = "MIT OR Apache-2.0" +publish = false +repository = "foo" diff --git a/tests/testsuite/cargo_new/inherit_workspace_package_table_without_version/in/README.md b/tests/testsuite/cargo_new/inherit_workspace_package_table_without_version/in/README.md new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/cargo_new/inherit_workspace_package_table_without_version/in/src/lib.rs b/tests/testsuite/cargo_new/inherit_workspace_package_table_without_version/in/src/lib.rs new file mode 100644 index 000000000000..7d12d9af8195 --- /dev/null +++ b/tests/testsuite/cargo_new/inherit_workspace_package_table_without_version/in/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/tests/testsuite/cargo_new/inherit_workspace_package_table_without_version/mod.rs b/tests/testsuite/cargo_new/inherit_workspace_package_table_without_version/mod.rs new file mode 100644 index 000000000000..c3ac2d375275 --- /dev/null +++ b/tests/testsuite/cargo_new/inherit_workspace_package_table_without_version/mod.rs @@ -0,0 +1,22 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::curr_dir; +use cargo_test_support::CargoCommand; +use cargo_test_support::Project; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("new") + .args(["crates/foo", "--edition", "2021"]) + .current_dir(cwd) + .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/tests/testsuite/cargo_new/inherit_workspace_package_table_without_version/out/Cargo.toml b/tests/testsuite/cargo_new/inherit_workspace_package_table_without_version/out/Cargo.toml new file mode 100644 index 000000000000..112fef55c0c8 --- /dev/null +++ b/tests/testsuite/cargo_new/inherit_workspace_package_table_without_version/out/Cargo.toml @@ -0,0 +1,20 @@ +[workspace] +members = [ + "crates/*", +] + +[workspace.package] +authors = ["Rustaceans"] +description = "foo" +edition = "2018" +homepage = "foo" +keywords = ["foo", "bar"] +readme = "README.md" +rust-version = "1.67.0" +categories = ["algorithms"] +documentation = "foo" +exclude = ["foo"] +include = ["foo"] +license = "MIT OR Apache-2.0" +publish = false +repository = "foo" diff --git a/tests/testsuite/cargo_new/inherit_workspace_package_table_without_version/out/crates/foo/Cargo.toml b/tests/testsuite/cargo_new/inherit_workspace_package_table_without_version/out/crates/foo/Cargo.toml new file mode 100644 index 000000000000..1febc7ca3664 --- /dev/null +++ b/tests/testsuite/cargo_new/inherit_workspace_package_table_without_version/out/crates/foo/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "foo" +version = "0.1.0" +edition = "2021" +publish.workspace = true +authors.workspace = true +categories.workspace = true +description.workspace = true +documentation.workspace = true +exclude.workspace = true +homepage.workspace = true +include.workspace = true +keywords.workspace = true +license.workspace = true +readme.workspace = true +repository.workspace = true +rust-version.workspace = true +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/tests/testsuite/cargo_new/inherit_workspace_package_table_without_version/out/crates/foo/src/main.rs b/tests/testsuite/cargo_new/inherit_workspace_package_table_without_version/out/crates/foo/src/main.rs new file mode 100644 index 000000000000..e7a11a969c03 --- /dev/null +++ b/tests/testsuite/cargo_new/inherit_workspace_package_table_without_version/out/crates/foo/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/tests/testsuite/cargo_new/inherit_workspace_package_table_without_version/out/src/lib.rs b/tests/testsuite/cargo_new/inherit_workspace_package_table_without_version/out/src/lib.rs new file mode 100644 index 000000000000..7d12d9af8195 --- /dev/null +++ b/tests/testsuite/cargo_new/inherit_workspace_package_table_without_version/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/tests/testsuite/cargo_new/inherit_workspace_package_table_without_version/stderr.log b/tests/testsuite/cargo_new/inherit_workspace_package_table_without_version/stderr.log new file mode 100644 index 000000000000..90150cdf5705 --- /dev/null +++ b/tests/testsuite/cargo_new/inherit_workspace_package_table_without_version/stderr.log @@ -0,0 +1 @@ + Created binary (application) `crates/foo` package diff --git a/tests/testsuite/cargo_new/inherit_workspace_package_table_without_version/stdout.log b/tests/testsuite/cargo_new/inherit_workspace_package_table_without_version/stdout.log new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/cargo_new/mod.rs b/tests/testsuite/cargo_new/mod.rs new file mode 100644 index 000000000000..762a70b34392 --- /dev/null +++ b/tests/testsuite/cargo_new/mod.rs @@ -0,0 +1,5 @@ +mod inherit_workspace_package_table; +mod inherit_workspace_package_table_with_edition; +mod inherit_workspace_package_table_with_registry; +mod inherit_workspace_package_table_without_version; +mod not_inherit_workspace_package_table_if_not_memebers; diff --git a/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/in/Cargo.toml b/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/in/Cargo.toml new file mode 100644 index 000000000000..2d204581cfcc --- /dev/null +++ b/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/in/Cargo.toml @@ -0,0 +1,15 @@ +[workspace.package] +authors = ["Rustaceans"] +description = "foo" +edition = "2018" +homepage = "foo" +keywords = ["foo", "bar"] +readme = "README.md" +rust-version = "1.67.0" +categories = ["algorithms"] +documentation = "foo" +exclude = ["foo"] +include = ["foo"] +license = "MIT OR Apache-2.0" +publish = false +repository = "foo" diff --git a/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/in/README.md b/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/in/README.md new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/in/src/lib.rs b/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/in/src/lib.rs new file mode 100644 index 000000000000..7d12d9af8195 --- /dev/null +++ b/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/in/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/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/mod.rs b/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/mod.rs new file mode 100644 index 000000000000..cdddf0e64fe7 --- /dev/null +++ b/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/mod.rs @@ -0,0 +1,22 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::curr_dir; +use cargo_test_support::CargoCommand; +use cargo_test_support::Project; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("new") + .args(["foo"]) + .current_dir(cwd) + .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/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/out/Cargo.toml b/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/out/Cargo.toml new file mode 100644 index 000000000000..2d204581cfcc --- /dev/null +++ b/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/out/Cargo.toml @@ -0,0 +1,15 @@ +[workspace.package] +authors = ["Rustaceans"] +description = "foo" +edition = "2018" +homepage = "foo" +keywords = ["foo", "bar"] +readme = "README.md" +rust-version = "1.67.0" +categories = ["algorithms"] +documentation = "foo" +exclude = ["foo"] +include = ["foo"] +license = "MIT OR Apache-2.0" +publish = false +repository = "foo" diff --git a/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/out/foo/Cargo.toml b/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/out/foo/Cargo.toml new file mode 100644 index 000000000000..1d9cfe3176c1 --- /dev/null +++ b/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/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/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/out/foo/src/main.rs b/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/out/foo/src/main.rs new file mode 100644 index 000000000000..e7a11a969c03 --- /dev/null +++ b/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/out/foo/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/out/src/lib.rs b/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/out/src/lib.rs new file mode 100644 index 000000000000..7d12d9af8195 --- /dev/null +++ b/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/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/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/stderr.log b/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/stderr.log new file mode 100644 index 000000000000..03b1ff6dbdad --- /dev/null +++ b/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/stderr.log @@ -0,0 +1,9 @@ +warning: compiling this new package may not work due to invalid workspace configuration + +current package believes it's in a workspace when it's not: +current: [ROOT]/case/foo/Cargo.toml +workspace: [ROOT]/case/Cargo.toml + +this may be fixable by adding `foo` to the `workspace.members` array of the manifest located at: [ROOT]/case/Cargo.toml +Alternatively, to keep it out of the workspace, add the package to the `workspace.exclude` array, or add an empty `[workspace]` table to the package's manifest. + Created binary (application) `foo` package diff --git a/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/stdout.log b/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/stdout.log new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/main.rs b/tests/testsuite/main.rs index a1e293acd817..0d8de9a5ab67 100644 --- a/tests/testsuite/main.rs +++ b/tests/testsuite/main.rs @@ -24,6 +24,7 @@ mod cargo_command; mod cargo_config; mod cargo_env_config; mod cargo_features; +mod cargo_new; mod cargo_remove; mod cargo_targets; mod cfg; @@ -138,7 +139,6 @@ mod warn_on_failure; mod weak_dep_features; mod workspaces; mod yank; - #[cargo_test] fn aaa_trigger_cross_compile_disabled_check() { // This triggers the cross compile disabled check to run ASAP, see #5141