-
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 #14505 - epage:new, r=weihanglo
fix(new): Add to workspace relative to manifest, not current-dir ### What does this PR try to resolve? We were correctly doing this for cases like `cargo new foo` or `cargo new deeper/than/this/directory/foo` but not `cargo new ../foo`. This came up when discussing #14501 ### How should we test and review this PR? ### Additional information
- Loading branch information
Showing
10 changed files
with
96 additions
and
2 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
8 changes: 8 additions & 0 deletions
8
tests/testsuite/cargo_new/ignore_current_dir_workspace/in/workspace/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,8 @@ | ||
[workspace] | ||
|
||
[package] | ||
name = "foo" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] |
1 change: 1 addition & 0 deletions
1
tests/testsuite/cargo_new/ignore_current_dir_workspace/in/workspace/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 @@ | ||
fn main() {} |
25 changes: 25 additions & 0 deletions
25
tests/testsuite/cargo_new/ignore_current_dir_workspace/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,25 @@ | ||
use cargo_test_support::compare::assert_ui; | ||
use cargo_test_support::current_dir; | ||
use cargo_test_support::file; | ||
use cargo_test_support::prelude::*; | ||
use cargo_test_support::str; | ||
use cargo_test_support::CargoCommandExt; | ||
use cargo_test_support::Project; | ||
|
||
#[cargo_test] | ||
fn case() { | ||
let project = Project::from_template(current_dir!().join("in")); | ||
let project_root = project.root(); | ||
let cwd = &project_root.join("workspace"); | ||
|
||
snapbox::cmd::Command::cargo_ui() | ||
.arg("new") | ||
.args(["../out-of-workspace", "--lib"]) | ||
.current_dir(cwd) | ||
.assert() | ||
.success() | ||
.stdout_eq(str![""]) | ||
.stderr_eq(file!["stderr.term.svg"]); | ||
|
||
assert_ui().subset_matches(current_dir!().join("out"), &project_root); | ||
} |
6 changes: 6 additions & 0 deletions
6
tests/testsuite/cargo_new/ignore_current_dir_workspace/out/out-of-workspace/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,6 @@ | ||
[package] | ||
name = "out-of-workspace" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] |
14 changes: 14 additions & 0 deletions
14
tests/testsuite/cargo_new/ignore_current_dir_workspace/out/out-of-workspace/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: u64, right: u64) -> u64 { | ||
left + right | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn it_works() { | ||
let result = add(2, 2); | ||
assert_eq!(result, 4); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
tests/testsuite/cargo_new/ignore_current_dir_workspace/out/workspace/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,8 @@ | ||
[workspace] | ||
|
||
[package] | ||
name = "foo" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] |
1 change: 1 addition & 0 deletions
1
tests/testsuite/cargo_new/ignore_current_dir_workspace/out/workspace/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 @@ | ||
fn main() {} |
30 changes: 30 additions & 0 deletions
30
tests/testsuite/cargo_new/ignore_current_dir_workspace/stderr.term.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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