mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
test: Add library package into non-workspace package
This commit is contained in:
parent
8c96a1a748
commit
3a4fdba907
@ -0,0 +1,6 @@
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
@ -0,0 +1 @@
|
||||
fn main() {}
|
@ -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(["bar", "--lib"])
|
||||
.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);
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
workspace = { members = ["bar"] }
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
@ -0,0 +1,6 @@
|
||||
[package]
|
||||
name = "bar"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
@ -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);
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
fn main() {}
|
@ -0,0 +1,2 @@
|
||||
Creating library `bar` package
|
||||
note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
@ -0,0 +1,6 @@
|
||||
[workspace]
|
||||
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
@ -0,0 +1 @@
|
||||
fn main() {}
|
@ -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(["bar", "--lib"])
|
||||
.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);
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
[workspace]
|
||||
members = ["bar"]
|
||||
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
@ -0,0 +1,6 @@
|
||||
[package]
|
||||
name = "bar"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
@ -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);
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
fn main() {}
|
@ -0,0 +1,2 @@
|
||||
Creating library `bar` package
|
||||
note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
@ -1,9 +1,11 @@
|
||||
mod add_members_to_non_workspace;
|
||||
mod add_members_to_workspace_format_previous_items;
|
||||
mod add_members_to_workspace_format_sorted;
|
||||
mod add_members_to_workspace_with_absolute_package_path;
|
||||
mod add_members_to_workspace_with_empty_members;
|
||||
mod add_members_to_workspace_with_exclude_list;
|
||||
mod add_members_to_workspace_with_members_glob;
|
||||
mod add_members_to_workspace_without_members;
|
||||
mod empty_name;
|
||||
mod help;
|
||||
mod inherit_workspace_lints;
|
||||
|
Loading…
x
Reference in New Issue
Block a user