Add tests for inherit_workspace_package_table

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
This commit is contained in:
hi-rustin 2023-05-03 13:01:36 +08:00
parent e6dae8ee83
commit 5265b1d0ec
49 changed files with 518 additions and 0 deletions

View file

@ -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"

View file

@ -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);
}
}

View file

@ -0,0 +1 @@
../inherit_workspace_package_table.in

View file

@ -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);
}

View file

@ -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"

View file

@ -0,0 +1,21 @@
[package]
name = "foo"
authors.workspace = true
description.workspace = true
edition.workspace = true
homepage.workspace = true
keywords.workspace = true
readme.workspace = true
rust-version.workspace = true
categories.workspace = true
documentation.workspace = true
exclude.workspace = true
include.workspace = true
license.workspace = true
publish.workspace = true
repository.workspace = true
version.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

View file

@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}

View file

@ -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);
}
}

View file

@ -0,0 +1 @@
Created binary (application) `crates/foo` package

View file

@ -0,0 +1 @@
../inherit_workspace_package_table.in

View file

@ -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);
}

View file

@ -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"

View file

@ -0,0 +1,21 @@
[package]
name = "foo"
edition = "2021"
authors.workspace = true
description.workspace = true
homepage.workspace = true
keywords.workspace = true
readme.workspace = true
rust-version.workspace = true
categories.workspace = true
documentation.workspace = true
exclude.workspace = true
include.workspace = true
license.workspace = true
publish.workspace = true
repository.workspace = true
version.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

View file

@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}

View file

@ -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);
}
}

View file

@ -0,0 +1 @@
Created binary (application) `crates/foo` package

View file

@ -0,0 +1 @@
../inherit_workspace_package_table.in

View file

@ -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);
}

View file

@ -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"

View file

@ -0,0 +1,21 @@
[package]
name = "foo"
publish = ["foo"]
authors.workspace = true
description.workspace = true
edition.workspace = true
homepage.workspace = true
keywords.workspace = true
readme.workspace = true
rust-version.workspace = true
categories.workspace = true
documentation.workspace = true
exclude.workspace = true
include.workspace = true
license.workspace = true
repository.workspace = true
version.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

View file

@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}

View file

@ -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);
}
}

View file

@ -0,0 +1 @@
Created binary (application) `crates/foo` package

View file

@ -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"

View file

@ -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);
}
}

View file

@ -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);
}

View file

@ -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"

View file

@ -0,0 +1,21 @@
[package]
name = "foo"
version = "0.1.0"
authors.workspace = true
description.workspace = true
edition.workspace = true
homepage.workspace = true
keywords.workspace = true
readme.workspace = true
rust-version.workspace = true
categories.workspace = true
documentation.workspace = true
exclude.workspace = true
include.workspace = true
license.workspace = true
publish.workspace = true
repository.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

View file

@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}

View file

@ -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);
}
}

View file

@ -0,0 +1 @@
Created binary (application) `crates/foo` package

View file

@ -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;

View file

@ -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"

View file

@ -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);
}
}

View file

@ -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);
}

View file

@ -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"

View file

@ -0,0 +1,21 @@
[package]
name = "foo"
version = "0.1.0"
authors.workspace = true
description.workspace = true
edition.workspace = true
homepage.workspace = true
keywords.workspace = true
readme.workspace = true
rust-version.workspace = true
categories.workspace = true
documentation.workspace = true
exclude.workspace = true
include.workspace = true
license.workspace = true
publish.workspace = true
repository.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

View file

@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}

View file

@ -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);
}
}

View file

@ -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

View file

@ -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;