-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #12069 - hi-rustin:rustin-patch-ws, r=epage
Automatically inherit workspace fields when running cargo new/init
- Loading branch information
Showing
62 changed files
with
730 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
tests/testsuite/cargo_new/inherit_workspace_package_table.in/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
Empty file.
14 changes: 14 additions & 0 deletions
14
tests/testsuite/cargo_new/inherit_workspace_package_table.in/src/lib.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../inherit_workspace_package_table.in |
22 changes: 22 additions & 0 deletions
22
tests/testsuite/cargo_new/inherit_workspace_package_table/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
21 changes: 21 additions & 0 deletions
21
tests/testsuite/cargo_new/inherit_workspace_package_table/out/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
21 changes: 21 additions & 0 deletions
21
tests/testsuite/cargo_new/inherit_workspace_package_table/out/crates/foo/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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] |
3 changes: 3 additions & 0 deletions
3
tests/testsuite/cargo_new/inherit_workspace_package_table/out/crates/foo/src/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fn main() { | ||
println!("Hello, world!"); | ||
} |
14 changes: 14 additions & 0 deletions
14
tests/testsuite/cargo_new/inherit_workspace_package_table/out/src/lib.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
tests/testsuite/cargo_new/inherit_workspace_package_table/stderr.log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Created binary (application) `crates/foo` package |
Empty file.
1 change: 1 addition & 0 deletions
1
tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../inherit_workspace_package_table.in |
22 changes: 22 additions & 0 deletions
22
tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
21 changes: 21 additions & 0 deletions
21
tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/out/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
21 changes: 21 additions & 0 deletions
21
...estsuite/cargo_new/inherit_workspace_package_table_with_edition/out/crates/foo/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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] |
3 changes: 3 additions & 0 deletions
3
...stsuite/cargo_new/inherit_workspace_package_table_with_edition/out/crates/foo/src/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fn main() { | ||
println!("Hello, world!"); | ||
} |
14 changes: 14 additions & 0 deletions
14
tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/out/src/lib.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/stderr.log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Created binary (application) `crates/foo` package |
Empty file.
1 change: 1 addition & 0 deletions
1
tests/testsuite/cargo_new/inherit_workspace_package_table_with_registry/in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../inherit_workspace_package_table.in |
Oops, something went wrong.