Skip to content

Commit c015a00

Browse files
committed
test(new): Verify ../path behavior with workspaces
1 parent d0cb869 commit c015a00

File tree

9 files changed

+104
-0
lines changed

9 files changed

+104
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[workspace]
2+
3+
[package]
4+
name = "foo"
5+
version = "0.1.0"
6+
edition = "2021"
7+
8+
[dependencies]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fn main() {}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
use cargo_test_support::compare::assert_ui;
2+
use cargo_test_support::current_dir;
3+
use cargo_test_support::file;
4+
use cargo_test_support::prelude::*;
5+
use cargo_test_support::str;
6+
use cargo_test_support::CargoCommandExt;
7+
use cargo_test_support::Project;
8+
9+
#[cargo_test]
10+
fn case() {
11+
let project = Project::from_template(current_dir!().join("in"));
12+
let project_root = project.root();
13+
let cwd = &project_root.join("workspace");
14+
15+
snapbox::cmd::Command::cargo_ui()
16+
.arg("new")
17+
.args(["../out-of-workspace", "--lib"])
18+
.current_dir(cwd)
19+
.assert()
20+
.success()
21+
.stdout_eq(str![""])
22+
.stderr_eq(file!["stderr.term.svg"]);
23+
24+
assert_ui().subset_matches(current_dir!().join("out"), &project_root);
25+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[package]
2+
name = "out-of-workspace"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
pub fn add(left: u64, right: u64) -> u64 {
2+
left + right
3+
}
4+
5+
#[cfg(test)]
6+
mod tests {
7+
use super::*;
8+
9+
#[test]
10+
fn it_works() {
11+
let result = add(2, 2);
12+
assert_eq!(result, 4);
13+
}
14+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[workspace]
2+
members = ["../out-of-workspace"]
3+
4+
[package]
5+
name = "foo"
6+
version = "0.1.0"
7+
edition = "2021"
8+
9+
[dependencies]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fn main() {}
Lines changed: 39 additions & 0 deletions
Loading

tests/testsuite/cargo_new/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ mod add_members_to_workspace_with_members_glob;
88
mod add_members_to_workspace_without_members;
99
mod empty_name;
1010
mod help;
11+
mod ignore_current_dir_workspace;
1112
mod inherit_workspace_lints;
1213
mod inherit_workspace_package_table;
1314
mod inherit_workspace_package_table_with_edition;

0 commit comments

Comments
 (0)