2022-04-20 15:44:53 +00:00
|
|
|
//! Tests for inheriting Cargo.toml fields with field.workspace = true
|
2023-02-19 05:26:59 +00:00
|
|
|
use cargo_test_support::registry::{Dependency, Package, RegistryBuilder};
|
2022-04-07 21:34:34 +00:00
|
|
|
use cargo_test_support::{
|
|
|
|
basic_lib_manifest, basic_manifest, git, path2url, paths, project, publish, registry,
|
|
|
|
};
|
2022-03-22 02:27:49 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn permit_additional_workspace_fields() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[workspace]
|
|
|
|
members = ["bar"]
|
2022-04-13 20:22:38 +00:00
|
|
|
[workspace.package]
|
2022-03-22 02:27:49 +00:00
|
|
|
version = "1.2.3"
|
|
|
|
authors = ["Rustaceans"]
|
|
|
|
description = "This is a crate"
|
|
|
|
documentation = "https://www.rust-lang.org/learn"
|
|
|
|
readme = "README.md"
|
|
|
|
homepage = "https://www.rust-lang.org"
|
|
|
|
repository = "https://github.com/example/example"
|
|
|
|
license = "MIT"
|
|
|
|
license-file = "LICENSE"
|
|
|
|
keywords = ["cli"]
|
|
|
|
categories = ["development-tools"]
|
|
|
|
publish = false
|
|
|
|
edition = "2018"
|
2022-04-13 17:03:40 +00:00
|
|
|
rust-version = "1.60"
|
2022-04-13 23:32:53 +00:00
|
|
|
exclude = ["foo.txt"]
|
|
|
|
include = ["bar.txt", "**/*.rs", "Cargo.toml", "LICENSE", "README.md"]
|
2022-03-22 02:27:49 +00:00
|
|
|
|
2022-04-13 20:22:38 +00:00
|
|
|
[workspace.package.badges]
|
2022-03-22 02:27:49 +00:00
|
|
|
gitlab = { repository = "https://gitlab.com/rust-lang/rust", branch = "master" }
|
|
|
|
|
|
|
|
[workspace.dependencies]
|
|
|
|
dep = "0.1"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
workspace = ".."
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("bar/src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
2023-02-15 23:57:30 +00:00
|
|
|
p.cargo("check")
|
2022-03-22 02:27:49 +00:00
|
|
|
// Should not warn about unused fields.
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
2023-02-15 23:57:30 +00:00
|
|
|
[CHECKING] bar v0.1.0 ([CWD]/bar)
|
2022-03-22 02:27:49 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
|
|
|
|
p.cargo("check").run();
|
|
|
|
let lockfile = p.read_lockfile();
|
|
|
|
assert!(!lockfile.contains("dep"));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn deny_optional_dependencies() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[workspace]
|
|
|
|
members = ["bar"]
|
|
|
|
|
|
|
|
[workspace.dependencies]
|
|
|
|
dep1 = { version = "0.1", optional = true }
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.file(
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
workspace = ".."
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("bar/src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
2023-02-15 23:57:30 +00:00
|
|
|
p.cargo("check")
|
2022-03-22 02:27:49 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[ERROR] failed to parse manifest at `[..]foo/Cargo.toml`
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
dep1 is optional, but workspace dependencies cannot be optional
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn inherit_own_workspace_fields() {
|
2023-02-19 05:26:59 +00:00
|
|
|
let registry = RegistryBuilder::new().http_api().http_index().build();
|
2022-03-22 02:27:49 +00:00
|
|
|
|
|
|
|
let p = project().build();
|
|
|
|
|
|
|
|
let _ = git::repo(&paths::root().join("foo"))
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-04-20 15:44:53 +00:00
|
|
|
badges.workspace = true
|
2022-03-22 02:27:49 +00:00
|
|
|
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
2022-04-20 15:44:53 +00:00
|
|
|
version.workspace = true
|
|
|
|
authors.workspace = true
|
|
|
|
description.workspace = true
|
|
|
|
documentation.workspace = true
|
|
|
|
homepage.workspace = true
|
|
|
|
repository.workspace = true
|
|
|
|
license.workspace = true
|
|
|
|
keywords.workspace = true
|
|
|
|
categories.workspace = true
|
|
|
|
publish.workspace = true
|
|
|
|
edition.workspace = true
|
|
|
|
rust-version.workspace = true
|
|
|
|
exclude.workspace = true
|
|
|
|
include.workspace = true
|
2022-03-22 02:27:49 +00:00
|
|
|
|
|
|
|
[workspace]
|
|
|
|
members = []
|
2022-04-13 20:22:38 +00:00
|
|
|
[workspace.package]
|
2022-03-22 02:27:49 +00:00
|
|
|
version = "1.2.3"
|
|
|
|
authors = ["Rustaceans"]
|
|
|
|
description = "This is a crate"
|
|
|
|
documentation = "https://www.rust-lang.org/learn"
|
|
|
|
homepage = "https://www.rust-lang.org"
|
|
|
|
repository = "https://github.com/example/example"
|
|
|
|
license = "MIT"
|
|
|
|
keywords = ["cli"]
|
|
|
|
categories = ["development-tools"]
|
|
|
|
publish = true
|
|
|
|
edition = "2018"
|
2022-04-13 17:03:40 +00:00
|
|
|
rust-version = "1.60"
|
2022-04-13 23:32:53 +00:00
|
|
|
exclude = ["foo.txt"]
|
|
|
|
include = ["bar.txt", "**/*.rs", "Cargo.toml"]
|
2022-04-13 20:22:38 +00:00
|
|
|
[workspace.package.badges]
|
2022-03-22 02:27:49 +00:00
|
|
|
gitlab = { repository = "https://gitlab.com/rust-lang/rust", branch = "master" }
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2022-04-13 23:32:53 +00:00
|
|
|
.file("foo.txt", "") // should be ignored when packaging
|
|
|
|
.file("bar.txt", "") // should be included when packaging
|
2022-03-22 02:27:49 +00:00
|
|
|
.build();
|
|
|
|
|
2022-08-31 05:53:47 +00:00
|
|
|
p.cargo("publish")
|
|
|
|
.replace_crates_io(registry.index_url())
|
2023-02-19 05:26:59 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] [..]
|
|
|
|
[WARNING] [..]
|
|
|
|
[..]
|
|
|
|
[VERIFYING] foo v1.2.3 [..]
|
|
|
|
[COMPILING] foo v1.2.3 [..]
|
|
|
|
[FINISHED] [..]
|
|
|
|
[PACKAGED] [..]
|
|
|
|
[UPLOADING] foo v1.2.3 [..]
|
2023-03-15 15:50:11 +00:00
|
|
|
[UPLOADED] foo v1.2.3 to registry `crates-io`
|
|
|
|
note: Waiting for `foo v1.2.3` to be available at registry `crates-io`.
|
|
|
|
You may press ctrl-c to skip waiting; the crate should be available shortly.
|
|
|
|
[PUBLISHED] foo v1.2.3 at registry `crates-io`
|
2023-02-19 05:26:59 +00:00
|
|
|
",
|
|
|
|
)
|
2022-08-31 05:53:47 +00:00
|
|
|
.run();
|
2023-02-19 05:26:59 +00:00
|
|
|
|
2022-03-22 02:27:49 +00:00
|
|
|
publish::validate_upload_with_contents(
|
|
|
|
r#"
|
|
|
|
{
|
|
|
|
"authors": ["Rustaceans"],
|
|
|
|
"badges": {
|
|
|
|
"gitlab": { "branch": "master", "repository": "https://gitlab.com/rust-lang/rust" }
|
|
|
|
},
|
|
|
|
"categories": ["development-tools"],
|
|
|
|
"deps": [],
|
|
|
|
"description": "This is a crate",
|
|
|
|
"documentation": "https://www.rust-lang.org/learn",
|
|
|
|
"features": {},
|
|
|
|
"homepage": "https://www.rust-lang.org",
|
|
|
|
"keywords": ["cli"],
|
|
|
|
"license": "MIT",
|
2022-03-23 18:40:16 +00:00
|
|
|
"license_file": null,
|
2022-03-22 02:27:49 +00:00
|
|
|
"links": null,
|
|
|
|
"name": "foo",
|
2022-03-23 18:40:16 +00:00
|
|
|
"readme": null,
|
|
|
|
"readme_file": null,
|
2022-03-22 02:27:49 +00:00
|
|
|
"repository": "https://github.com/example/example",
|
2023-03-24 20:46:59 +00:00
|
|
|
"rust_version": "1.60",
|
2022-03-22 02:27:49 +00:00
|
|
|
"vers": "1.2.3"
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
"foo-1.2.3.crate",
|
|
|
|
&[
|
|
|
|
"Cargo.lock",
|
|
|
|
"Cargo.toml",
|
|
|
|
"Cargo.toml.orig",
|
|
|
|
"src/main.rs",
|
|
|
|
".cargo_vcs_info.json",
|
2022-04-13 23:32:53 +00:00
|
|
|
"bar.txt",
|
2022-03-22 02:27:49 +00:00
|
|
|
],
|
|
|
|
&[(
|
|
|
|
"Cargo.toml",
|
|
|
|
&format!(
|
|
|
|
r#"{}
|
|
|
|
[package]
|
|
|
|
edition = "2018"
|
2022-04-13 17:03:40 +00:00
|
|
|
rust-version = "1.60"
|
2022-03-22 02:27:49 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "1.2.3"
|
|
|
|
authors = ["Rustaceans"]
|
2022-04-13 23:32:53 +00:00
|
|
|
exclude = ["foo.txt"]
|
|
|
|
include = [
|
|
|
|
"bar.txt",
|
|
|
|
"**/*.rs",
|
|
|
|
"Cargo.toml",
|
|
|
|
]
|
2022-03-22 02:27:49 +00:00
|
|
|
publish = true
|
|
|
|
description = "This is a crate"
|
|
|
|
homepage = "https://www.rust-lang.org"
|
|
|
|
documentation = "https://www.rust-lang.org/learn"
|
|
|
|
keywords = ["cli"]
|
|
|
|
categories = ["development-tools"]
|
|
|
|
license = "MIT"
|
|
|
|
repository = "https://github.com/example/example"
|
|
|
|
|
|
|
|
[badges.gitlab]
|
|
|
|
branch = "master"
|
|
|
|
repository = "https://gitlab.com/rust-lang/rust"
|
|
|
|
"#,
|
|
|
|
cargo::core::package::MANIFEST_PREAMBLE
|
|
|
|
),
|
|
|
|
)],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn inherit_own_dependencies() {
|
2023-02-19 05:26:59 +00:00
|
|
|
let registry = RegistryBuilder::new().http_api().http_index().build();
|
2022-03-22 02:27:49 +00:00
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2022-03-22 02:27:49 +00:00
|
|
|
name = "bar"
|
|
|
|
version = "0.2.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
2022-04-20 15:45:18 +00:00
|
|
|
dep.workspace = true
|
2022-03-22 02:27:49 +00:00
|
|
|
|
|
|
|
[build-dependencies]
|
2022-04-20 15:45:18 +00:00
|
|
|
dep-build.workspace = true
|
2022-03-22 02:27:49 +00:00
|
|
|
|
|
|
|
[dev-dependencies]
|
2022-04-20 15:45:18 +00:00
|
|
|
dep-dev.workspace = true
|
2022-03-22 02:27:49 +00:00
|
|
|
|
|
|
|
[workspace]
|
|
|
|
members = []
|
|
|
|
|
|
|
|
[workspace.dependencies]
|
|
|
|
dep = "0.1"
|
|
|
|
dep-build = "0.8"
|
|
|
|
dep-dev = "0.5.2"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
Package::new("dep", "0.1.2").publish();
|
|
|
|
Package::new("dep-build", "0.8.2").publish();
|
|
|
|
Package::new("dep-dev", "0.5.2").publish();
|
|
|
|
|
2023-02-15 23:57:30 +00:00
|
|
|
p.cargo("check")
|
2023-02-25 01:28:28 +00:00
|
|
|
// Unordered because the download order is nondeterministic.
|
|
|
|
.with_stderr_unordered(
|
2022-03-22 02:27:49 +00:00
|
|
|
"\
|
|
|
|
[UPDATING] `[..]` index
|
|
|
|
[DOWNLOADING] crates ...
|
|
|
|
[DOWNLOADED] dep v0.1.2 ([..])
|
2023-02-22 02:01:23 +00:00
|
|
|
[DOWNLOADED] dep-build v0.8.2 ([..])
|
2023-02-15 23:57:30 +00:00
|
|
|
[CHECKING] dep v0.1.2
|
|
|
|
[CHECKING] bar v0.2.0 ([CWD])
|
2022-03-22 02:27:49 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
|
2022-07-23 14:36:49 +00:00
|
|
|
p.cargo("check").run();
|
2022-03-22 02:27:49 +00:00
|
|
|
let lockfile = p.read_lockfile();
|
|
|
|
assert!(lockfile.contains("dep"));
|
|
|
|
assert!(lockfile.contains("dep-dev"));
|
|
|
|
assert!(lockfile.contains("dep-build"));
|
2022-11-17 21:54:24 +00:00
|
|
|
|
2022-08-31 05:53:47 +00:00
|
|
|
p.cargo("publish")
|
|
|
|
.replace_crates_io(registry.index_url())
|
2023-02-19 05:26:59 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] [..]
|
|
|
|
[WARNING] [..]
|
|
|
|
[..]
|
|
|
|
[PACKAGING] bar v0.2.0 [..]
|
|
|
|
[UPDATING] [..]
|
|
|
|
[VERIFYING] bar v0.2.0 [..]
|
|
|
|
[COMPILING] dep v0.1.2
|
|
|
|
[COMPILING] bar v0.2.0 [..]
|
|
|
|
[FINISHED] [..]
|
|
|
|
[PACKAGED] [..]
|
|
|
|
[UPLOADING] bar v0.2.0 [..]
|
2023-03-15 15:50:11 +00:00
|
|
|
[UPLOADED] bar v0.2.0 to registry `crates-io`
|
|
|
|
note: Waiting for `bar v0.2.0` to be available at registry `crates-io`.
|
|
|
|
You may press ctrl-c to skip waiting; the crate should be available shortly.
|
|
|
|
[PUBLISHED] bar v0.2.0 at registry `crates-io`
|
2023-02-19 05:26:59 +00:00
|
|
|
",
|
|
|
|
)
|
2022-08-31 05:53:47 +00:00
|
|
|
.run();
|
2023-02-19 05:26:59 +00:00
|
|
|
|
2022-03-22 02:27:49 +00:00
|
|
|
publish::validate_upload_with_contents(
|
|
|
|
r#"
|
|
|
|
{
|
|
|
|
"authors": [],
|
|
|
|
"badges": {},
|
|
|
|
"categories": [],
|
|
|
|
"deps": [
|
|
|
|
{
|
|
|
|
"default_features": true,
|
|
|
|
"features": [],
|
|
|
|
"kind": "normal",
|
|
|
|
"name": "dep",
|
|
|
|
"optional": false,
|
|
|
|
"target": null,
|
|
|
|
"version_req": "^0.1"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"default_features": true,
|
|
|
|
"features": [],
|
|
|
|
"kind": "dev",
|
|
|
|
"name": "dep-dev",
|
|
|
|
"optional": false,
|
|
|
|
"target": null,
|
|
|
|
"version_req": "^0.5.2"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"default_features": true,
|
|
|
|
"features": [],
|
|
|
|
"kind": "build",
|
|
|
|
"name": "dep-build",
|
|
|
|
"optional": false,
|
|
|
|
"target": null,
|
|
|
|
"version_req": "^0.8"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"description": null,
|
|
|
|
"documentation": null,
|
|
|
|
"features": {},
|
|
|
|
"homepage": null,
|
|
|
|
"keywords": [],
|
|
|
|
"license": null,
|
|
|
|
"license_file": null,
|
|
|
|
"links": null,
|
|
|
|
"name": "bar",
|
|
|
|
"readme": null,
|
|
|
|
"readme_file": null,
|
|
|
|
"repository": null,
|
2023-03-24 20:46:59 +00:00
|
|
|
"rust_version": null,
|
2022-03-22 02:27:49 +00:00
|
|
|
"vers": "0.2.0"
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
"bar-0.2.0.crate",
|
|
|
|
&["Cargo.toml", "Cargo.toml.orig", "Cargo.lock", "src/main.rs"],
|
|
|
|
&[(
|
|
|
|
"Cargo.toml",
|
|
|
|
&format!(
|
|
|
|
r#"{}
|
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.2.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies.dep]
|
|
|
|
version = "0.1"
|
|
|
|
|
|
|
|
[dev-dependencies.dep-dev]
|
|
|
|
version = "0.5.2"
|
|
|
|
|
|
|
|
[build-dependencies.dep-build]
|
|
|
|
version = "0.8"
|
|
|
|
"#,
|
|
|
|
cargo::core::package::MANIFEST_PREAMBLE
|
|
|
|
),
|
|
|
|
)],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn inherit_own_detailed_dependencies() {
|
2023-02-19 05:26:59 +00:00
|
|
|
let registry = RegistryBuilder::new().http_api().http_index().build();
|
2022-03-22 02:27:49 +00:00
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2022-03-22 02:27:49 +00:00
|
|
|
name = "bar"
|
|
|
|
version = "0.2.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
2022-04-20 15:45:18 +00:00
|
|
|
dep.workspace = true
|
2022-03-22 02:27:49 +00:00
|
|
|
|
|
|
|
[workspace]
|
|
|
|
members = []
|
|
|
|
|
|
|
|
[workspace.dependencies]
|
|
|
|
dep = { version = "0.1.2", features = ["testing"] }
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
Package::new("dep", "0.1.2")
|
|
|
|
.feature("testing", &vec![])
|
|
|
|
.publish();
|
|
|
|
|
2023-02-15 23:57:30 +00:00
|
|
|
p.cargo("check")
|
2022-03-22 02:27:49 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] `[..]` index
|
|
|
|
[DOWNLOADING] crates ...
|
|
|
|
[DOWNLOADED] dep v0.1.2 ([..])
|
2023-02-15 23:57:30 +00:00
|
|
|
[CHECKING] dep v0.1.2
|
|
|
|
[CHECKING] bar v0.2.0 ([CWD])
|
2022-03-22 02:27:49 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
|
2022-07-23 14:36:49 +00:00
|
|
|
p.cargo("check").run();
|
2022-03-22 02:27:49 +00:00
|
|
|
let lockfile = p.read_lockfile();
|
|
|
|
assert!(lockfile.contains("dep"));
|
2022-11-17 21:54:24 +00:00
|
|
|
|
2022-08-31 05:53:47 +00:00
|
|
|
p.cargo("publish")
|
|
|
|
.replace_crates_io(registry.index_url())
|
2023-02-19 05:26:59 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] [..]
|
|
|
|
[WARNING] [..]
|
|
|
|
[..]
|
|
|
|
[PACKAGING] bar v0.2.0 [..]
|
|
|
|
[UPDATING] [..]
|
|
|
|
[VERIFYING] bar v0.2.0 [..]
|
|
|
|
[COMPILING] dep v0.1.2
|
|
|
|
[COMPILING] bar v0.2.0 [..]
|
|
|
|
[FINISHED] [..]
|
|
|
|
[PACKAGED] [..]
|
|
|
|
[UPLOADING] bar v0.2.0 [..]
|
2023-03-15 15:50:11 +00:00
|
|
|
[UPLOADED] bar v0.2.0 to registry `crates-io`
|
|
|
|
note: Waiting for `bar v0.2.0` to be available at registry `crates-io`.
|
|
|
|
You may press ctrl-c to skip waiting; the crate should be available shortly.
|
|
|
|
[PUBLISHED] bar v0.2.0 at registry `crates-io`
|
2023-02-19 05:26:59 +00:00
|
|
|
",
|
|
|
|
)
|
2022-08-31 05:53:47 +00:00
|
|
|
.run();
|
2023-02-19 05:26:59 +00:00
|
|
|
|
2022-03-22 02:27:49 +00:00
|
|
|
publish::validate_upload_with_contents(
|
|
|
|
r#"
|
|
|
|
{
|
|
|
|
"authors": [],
|
|
|
|
"badges": {},
|
|
|
|
"categories": [],
|
|
|
|
"deps": [
|
|
|
|
{
|
|
|
|
"default_features": true,
|
|
|
|
"features": ["testing"],
|
|
|
|
"kind": "normal",
|
|
|
|
"name": "dep",
|
|
|
|
"optional": false,
|
|
|
|
"target": null,
|
|
|
|
"version_req": "^0.1.2"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"description": null,
|
|
|
|
"documentation": null,
|
|
|
|
"features": {},
|
|
|
|
"homepage": null,
|
|
|
|
"keywords": [],
|
|
|
|
"license": null,
|
|
|
|
"license_file": null,
|
|
|
|
"links": null,
|
|
|
|
"name": "bar",
|
|
|
|
"readme": null,
|
|
|
|
"readme_file": null,
|
|
|
|
"repository": null,
|
2023-03-24 20:46:59 +00:00
|
|
|
"rust_version": null,
|
2022-03-22 02:27:49 +00:00
|
|
|
"vers": "0.2.0"
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
"bar-0.2.0.crate",
|
|
|
|
&["Cargo.toml", "Cargo.toml.orig", "Cargo.lock", "src/main.rs"],
|
|
|
|
&[(
|
|
|
|
"Cargo.toml",
|
|
|
|
&format!(
|
|
|
|
r#"{}
|
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.2.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies.dep]
|
|
|
|
version = "0.1.2"
|
|
|
|
features = ["testing"]
|
|
|
|
"#,
|
|
|
|
cargo::core::package::MANIFEST_PREAMBLE
|
|
|
|
),
|
|
|
|
)],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn inherit_from_own_undefined_field() {
|
|
|
|
registry::init();
|
|
|
|
|
|
|
|
let p = project().build();
|
|
|
|
|
|
|
|
let _ = git::repo(&paths::root().join("foo"))
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "1.2.5"
|
|
|
|
authors = ["rustaceans"]
|
2022-04-20 15:44:53 +00:00
|
|
|
description.workspace = true
|
2022-03-22 02:27:49 +00:00
|
|
|
|
|
|
|
[workspace]
|
|
|
|
members = []
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
2023-02-15 23:57:30 +00:00
|
|
|
p.cargo("check")
|
2022-03-22 02:27:49 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[ERROR] failed to parse manifest at `[CWD]/Cargo.toml`
|
|
|
|
|
|
|
|
Caused by:
|
2022-04-13 20:22:38 +00:00
|
|
|
error inheriting `description` from workspace root manifest's `workspace.package.description`
|
2022-03-23 18:40:16 +00:00
|
|
|
|
|
|
|
Caused by:
|
2022-04-13 20:22:38 +00:00
|
|
|
`workspace.package.description` was not defined
|
2022-03-22 02:27:49 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn inherited_dependencies_union_features() {
|
|
|
|
Package::new("dep", "0.1.0")
|
|
|
|
.feature("fancy", &["fancy_dep"])
|
|
|
|
.feature("dancy", &["dancy_dep"])
|
|
|
|
.add_dep(Dependency::new("fancy_dep", "0.2").optional(true))
|
|
|
|
.add_dep(Dependency::new("dancy_dep", "0.6").optional(true))
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.publish();
|
|
|
|
|
|
|
|
Package::new("fancy_dep", "0.2.4").publish();
|
|
|
|
Package::new("dancy_dep", "0.6.8").publish();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2022-03-22 02:27:49 +00:00
|
|
|
name = "bar"
|
|
|
|
version = "0.2.0"
|
|
|
|
authors = []
|
|
|
|
[dependencies]
|
|
|
|
dep = { workspace = true, features = ["dancy"] }
|
|
|
|
|
|
|
|
[workspace]
|
|
|
|
members = []
|
|
|
|
[workspace.dependencies]
|
|
|
|
dep = { version = "0.1", features = ["fancy"] }
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
2023-02-15 23:57:30 +00:00
|
|
|
p.cargo("check")
|
2022-03-22 02:27:49 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] `[..]` index
|
|
|
|
[DOWNLOADING] crates ...
|
|
|
|
[DOWNLOADED] fancy_dep v0.2.4 ([..])
|
|
|
|
[DOWNLOADED] dep v0.1.0 ([..])
|
|
|
|
[DOWNLOADED] dancy_dep v0.6.8 ([..])
|
2023-02-15 23:57:30 +00:00
|
|
|
[CHECKING] [..]
|
|
|
|
[CHECKING] [..]
|
|
|
|
[CHECKING] dep v0.1.0
|
|
|
|
[CHECKING] bar v0.2.0 ([CWD])
|
2022-03-22 02:27:49 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
|
|
|
|
let lockfile = p.read_lockfile();
|
|
|
|
assert!(lockfile.contains("dep"));
|
|
|
|
assert!(lockfile.contains("fancy_dep"));
|
|
|
|
assert!(lockfile.contains("dancy_dep"));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
2022-04-04 20:32:46 +00:00
|
|
|
fn inherit_workspace_fields() {
|
2023-02-19 05:26:59 +00:00
|
|
|
let registry = RegistryBuilder::new().http_api().http_index().build();
|
2022-03-22 02:27:49 +00:00
|
|
|
|
|
|
|
let p = project().build();
|
|
|
|
|
|
|
|
let _ = git::repo(&paths::root().join("foo"))
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[workspace]
|
|
|
|
members = ["bar"]
|
2022-04-13 20:22:38 +00:00
|
|
|
[workspace.package]
|
2022-03-22 02:27:49 +00:00
|
|
|
version = "1.2.3"
|
2022-04-04 20:32:46 +00:00
|
|
|
authors = ["Rustaceans"]
|
|
|
|
description = "This is a crate"
|
|
|
|
documentation = "https://www.rust-lang.org/learn"
|
2022-04-08 20:18:48 +00:00
|
|
|
readme = "README.md"
|
2022-04-04 20:32:46 +00:00
|
|
|
homepage = "https://www.rust-lang.org"
|
|
|
|
repository = "https://github.com/example/example"
|
2022-04-07 21:34:34 +00:00
|
|
|
license = "MIT"
|
|
|
|
license-file = "LICENSE"
|
2022-04-04 20:32:46 +00:00
|
|
|
keywords = ["cli"]
|
|
|
|
categories = ["development-tools"]
|
|
|
|
publish = true
|
|
|
|
edition = "2018"
|
2022-04-13 17:03:40 +00:00
|
|
|
rust-version = "1.60"
|
2022-04-13 23:32:53 +00:00
|
|
|
exclude = ["foo.txt"]
|
|
|
|
include = ["bar.txt", "**/*.rs", "Cargo.toml", "LICENSE", "README.md"]
|
2022-04-13 20:22:38 +00:00
|
|
|
[workspace.package.badges]
|
2022-04-04 20:32:46 +00:00
|
|
|
gitlab = { repository = "https://gitlab.com/rust-lang/rust", branch = "master" }
|
2022-03-22 02:27:49 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.file(
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
r#"
|
2022-04-20 15:44:53 +00:00
|
|
|
badges.workspace = true
|
2022-03-22 02:27:49 +00:00
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
workspace = ".."
|
2022-04-20 15:44:53 +00:00
|
|
|
version.workspace = true
|
|
|
|
authors.workspace = true
|
|
|
|
description.workspace = true
|
|
|
|
documentation.workspace = true
|
|
|
|
readme.workspace = true
|
|
|
|
homepage.workspace = true
|
|
|
|
repository.workspace = true
|
|
|
|
license.workspace = true
|
|
|
|
license-file.workspace = true
|
|
|
|
keywords.workspace = true
|
|
|
|
categories.workspace = true
|
|
|
|
publish.workspace = true
|
|
|
|
edition.workspace = true
|
|
|
|
rust-version.workspace = true
|
|
|
|
exclude.workspace = true
|
|
|
|
include.workspace = true
|
2022-04-04 20:32:46 +00:00
|
|
|
"#,
|
|
|
|
)
|
2022-04-07 21:34:34 +00:00
|
|
|
.file("LICENSE", "license")
|
2022-04-08 20:18:48 +00:00
|
|
|
.file("README.md", "README.md")
|
2022-04-04 20:32:46 +00:00
|
|
|
.file("bar/src/main.rs", "fn main() {}")
|
2022-04-13 23:32:53 +00:00
|
|
|
.file("bar/foo.txt", "") // should be ignored when packaging
|
|
|
|
.file("bar/bar.txt", "") // should be included when packaging
|
2022-04-04 20:32:46 +00:00
|
|
|
.build();
|
|
|
|
|
2022-08-31 05:53:47 +00:00
|
|
|
p.cargo("publish")
|
|
|
|
.replace_crates_io(registry.index_url())
|
|
|
|
.cwd("bar")
|
2023-02-19 05:26:59 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] [..]
|
|
|
|
[WARNING] [..]
|
|
|
|
[..]
|
|
|
|
[VERIFYING] bar v1.2.3 [..]
|
|
|
|
[WARNING] [..]
|
|
|
|
[..]
|
|
|
|
[..]
|
|
|
|
[..]
|
|
|
|
[COMPILING] bar v1.2.3 [..]
|
|
|
|
[FINISHED] [..]
|
|
|
|
[PACKAGED] [..]
|
|
|
|
[UPLOADING] bar v1.2.3 [..]
|
2023-03-15 15:50:11 +00:00
|
|
|
[UPLOADED] bar v1.2.3 to registry `crates-io`
|
|
|
|
note: Waiting for `bar v1.2.3` to be available at registry `crates-io`.
|
|
|
|
You may press ctrl-c to skip waiting; the crate should be available shortly.
|
|
|
|
[PUBLISHED] bar v1.2.3 at registry `crates-io`
|
2023-02-19 05:26:59 +00:00
|
|
|
",
|
|
|
|
)
|
2022-08-31 05:53:47 +00:00
|
|
|
.run();
|
2023-02-19 05:26:59 +00:00
|
|
|
|
2022-04-04 20:32:46 +00:00
|
|
|
publish::validate_upload_with_contents(
|
|
|
|
r#"
|
|
|
|
{
|
|
|
|
"authors": ["Rustaceans"],
|
|
|
|
"badges": {
|
|
|
|
"gitlab": { "branch": "master", "repository": "https://gitlab.com/rust-lang/rust" }
|
|
|
|
},
|
|
|
|
"categories": ["development-tools"],
|
|
|
|
"deps": [],
|
|
|
|
"description": "This is a crate",
|
|
|
|
"documentation": "https://www.rust-lang.org/learn",
|
|
|
|
"features": {},
|
|
|
|
"homepage": "https://www.rust-lang.org",
|
|
|
|
"keywords": ["cli"],
|
2022-04-07 21:34:34 +00:00
|
|
|
"license": "MIT",
|
|
|
|
"license_file": "../LICENSE",
|
2022-04-04 20:32:46 +00:00
|
|
|
"links": null,
|
|
|
|
"name": "bar",
|
2022-04-08 20:18:48 +00:00
|
|
|
"readme": "README.md",
|
|
|
|
"readme_file": "../README.md",
|
2022-04-04 20:32:46 +00:00
|
|
|
"repository": "https://github.com/example/example",
|
2023-03-24 20:46:59 +00:00
|
|
|
"rust_version": "1.60",
|
2022-04-04 20:32:46 +00:00
|
|
|
"vers": "1.2.3"
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
"bar-1.2.3.crate",
|
|
|
|
&[
|
|
|
|
"Cargo.lock",
|
|
|
|
"Cargo.toml",
|
|
|
|
"Cargo.toml.orig",
|
|
|
|
"src/main.rs",
|
2022-04-08 20:18:48 +00:00
|
|
|
"README.md",
|
2022-04-07 21:34:34 +00:00
|
|
|
"LICENSE",
|
2022-04-04 20:32:46 +00:00
|
|
|
".cargo_vcs_info.json",
|
2022-04-13 23:32:53 +00:00
|
|
|
"bar.txt",
|
2022-04-04 20:32:46 +00:00
|
|
|
],
|
|
|
|
&[(
|
|
|
|
"Cargo.toml",
|
|
|
|
&format!(
|
|
|
|
r#"{}
|
|
|
|
[package]
|
|
|
|
edition = "2018"
|
2022-04-13 17:03:40 +00:00
|
|
|
rust-version = "1.60"
|
2022-04-04 20:32:46 +00:00
|
|
|
name = "bar"
|
|
|
|
version = "1.2.3"
|
|
|
|
authors = ["Rustaceans"]
|
2022-04-13 23:32:53 +00:00
|
|
|
exclude = ["foo.txt"]
|
|
|
|
include = [
|
|
|
|
"bar.txt",
|
|
|
|
"**/*.rs",
|
|
|
|
"Cargo.toml",
|
|
|
|
"LICENSE",
|
|
|
|
"README.md",
|
|
|
|
]
|
2022-04-04 20:32:46 +00:00
|
|
|
publish = true
|
|
|
|
description = "This is a crate"
|
|
|
|
homepage = "https://www.rust-lang.org"
|
|
|
|
documentation = "https://www.rust-lang.org/learn"
|
2022-04-08 20:18:48 +00:00
|
|
|
readme = "README.md"
|
2022-04-04 20:32:46 +00:00
|
|
|
keywords = ["cli"]
|
|
|
|
categories = ["development-tools"]
|
2022-04-07 21:34:34 +00:00
|
|
|
license = "MIT"
|
|
|
|
license-file = "LICENSE"
|
2022-04-04 20:32:46 +00:00
|
|
|
repository = "https://github.com/example/example"
|
|
|
|
|
|
|
|
[badges.gitlab]
|
|
|
|
branch = "master"
|
|
|
|
repository = "https://gitlab.com/rust-lang/rust"
|
|
|
|
"#,
|
|
|
|
cargo::core::package::MANIFEST_PREAMBLE
|
|
|
|
),
|
|
|
|
)],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn inherit_dependencies() {
|
2023-02-19 05:26:59 +00:00
|
|
|
let registry = RegistryBuilder::new().http_api().http_index().build();
|
2022-04-04 20:32:46 +00:00
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[workspace]
|
|
|
|
members = ["bar"]
|
|
|
|
[workspace.dependencies]
|
|
|
|
dep = "0.1"
|
|
|
|
dep-build = "0.8"
|
|
|
|
dep-dev = "0.5.2"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2022-04-04 20:32:46 +00:00
|
|
|
workspace = ".."
|
|
|
|
name = "bar"
|
|
|
|
version = "0.2.0"
|
|
|
|
authors = []
|
|
|
|
[dependencies]
|
2022-04-20 15:45:18 +00:00
|
|
|
dep.workspace = true
|
2022-04-04 20:32:46 +00:00
|
|
|
[build-dependencies]
|
2022-04-20 15:45:18 +00:00
|
|
|
dep-build.workspace = true
|
2022-04-04 20:32:46 +00:00
|
|
|
[dev-dependencies]
|
2022-04-20 15:45:18 +00:00
|
|
|
dep-dev.workspace = true
|
2022-03-22 02:27:49 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("bar/src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
2022-04-04 20:32:46 +00:00
|
|
|
Package::new("dep", "0.1.2").publish();
|
|
|
|
Package::new("dep-build", "0.8.2").publish();
|
|
|
|
Package::new("dep-dev", "0.5.2").publish();
|
|
|
|
|
2023-02-15 23:57:30 +00:00
|
|
|
p.cargo("check")
|
2023-02-25 01:28:28 +00:00
|
|
|
// Unordered because the download order is nondeterministic.
|
|
|
|
.with_stderr_unordered(
|
2022-04-04 20:32:46 +00:00
|
|
|
"\
|
|
|
|
[UPDATING] `[..]` index
|
|
|
|
[DOWNLOADING] crates ...
|
|
|
|
[DOWNLOADED] dep v0.1.2 ([..])
|
2023-02-22 02:01:23 +00:00
|
|
|
[DOWNLOADED] dep-build v0.8.2 ([..])
|
2023-02-15 23:57:30 +00:00
|
|
|
[CHECKING] dep v0.1.2
|
|
|
|
[CHECKING] bar v0.2.0 ([CWD]/bar)
|
2022-04-04 20:32:46 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
|
2022-07-23 14:36:49 +00:00
|
|
|
p.cargo("check").run();
|
2022-04-04 20:32:46 +00:00
|
|
|
let lockfile = p.read_lockfile();
|
|
|
|
assert!(lockfile.contains("dep"));
|
|
|
|
assert!(lockfile.contains("dep-dev"));
|
|
|
|
assert!(lockfile.contains("dep-build"));
|
2022-11-17 21:54:24 +00:00
|
|
|
|
2022-08-31 05:53:47 +00:00
|
|
|
p.cargo("publish")
|
|
|
|
.replace_crates_io(registry.index_url())
|
|
|
|
.cwd("bar")
|
2023-02-19 05:26:59 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] [..]
|
|
|
|
[WARNING] [..]
|
|
|
|
[..]
|
|
|
|
[PACKAGING] bar v0.2.0 [..]
|
|
|
|
[UPDATING] [..]
|
|
|
|
[VERIFYING] bar v0.2.0 [..]
|
|
|
|
[COMPILING] dep v0.1.2
|
|
|
|
[COMPILING] bar v0.2.0 [..]
|
|
|
|
[FINISHED] [..]
|
|
|
|
[PACKAGED] [..]
|
|
|
|
[UPLOADING] bar v0.2.0 [..]
|
2023-03-15 15:50:11 +00:00
|
|
|
[UPLOADED] bar v0.2.0 to registry `crates-io`
|
|
|
|
note: Waiting for `bar v0.2.0` to be available at registry `crates-io`.
|
|
|
|
You may press ctrl-c to skip waiting; the crate should be available shortly.
|
|
|
|
[PUBLISHED] bar v0.2.0 at registry `crates-io`
|
2023-02-19 05:26:59 +00:00
|
|
|
",
|
|
|
|
)
|
2022-08-31 05:53:47 +00:00
|
|
|
.run();
|
2023-02-19 05:26:59 +00:00
|
|
|
|
2022-04-04 20:32:46 +00:00
|
|
|
publish::validate_upload_with_contents(
|
|
|
|
r#"
|
|
|
|
{
|
|
|
|
"authors": [],
|
|
|
|
"badges": {},
|
|
|
|
"categories": [],
|
|
|
|
"deps": [
|
|
|
|
{
|
|
|
|
"default_features": true,
|
|
|
|
"features": [],
|
|
|
|
"kind": "normal",
|
|
|
|
"name": "dep",
|
|
|
|
"optional": false,
|
|
|
|
"target": null,
|
|
|
|
"version_req": "^0.1"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"default_features": true,
|
|
|
|
"features": [],
|
|
|
|
"kind": "dev",
|
|
|
|
"name": "dep-dev",
|
|
|
|
"optional": false,
|
|
|
|
"target": null,
|
|
|
|
"version_req": "^0.5.2"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"default_features": true,
|
|
|
|
"features": [],
|
|
|
|
"kind": "build",
|
|
|
|
"name": "dep-build",
|
|
|
|
"optional": false,
|
|
|
|
"target": null,
|
|
|
|
"version_req": "^0.8"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"description": null,
|
|
|
|
"documentation": null,
|
|
|
|
"features": {},
|
|
|
|
"homepage": null,
|
|
|
|
"keywords": [],
|
|
|
|
"license": null,
|
|
|
|
"license_file": null,
|
|
|
|
"links": null,
|
|
|
|
"name": "bar",
|
|
|
|
"readme": null,
|
|
|
|
"readme_file": null,
|
|
|
|
"repository": null,
|
2023-03-24 20:46:59 +00:00
|
|
|
"rust_version": null,
|
2022-04-04 20:32:46 +00:00
|
|
|
"vers": "0.2.0"
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
"bar-0.2.0.crate",
|
|
|
|
&["Cargo.toml", "Cargo.toml.orig", "Cargo.lock", "src/main.rs"],
|
|
|
|
&[(
|
|
|
|
"Cargo.toml",
|
|
|
|
&format!(
|
|
|
|
r#"{}
|
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.2.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies.dep]
|
|
|
|
version = "0.1"
|
|
|
|
|
|
|
|
[dev-dependencies.dep-dev]
|
|
|
|
version = "0.5.2"
|
|
|
|
|
|
|
|
[build-dependencies.dep-build]
|
|
|
|
version = "0.8"
|
|
|
|
"#,
|
|
|
|
cargo::core::package::MANIFEST_PREAMBLE
|
|
|
|
),
|
|
|
|
)],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn inherit_target_dependencies() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[workspace]
|
|
|
|
members = ["bar"]
|
|
|
|
[workspace.dependencies]
|
|
|
|
dep = "0.1"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2022-04-04 20:32:46 +00:00
|
|
|
workspace = ".."
|
|
|
|
name = "bar"
|
|
|
|
version = "0.2.0"
|
|
|
|
authors = []
|
|
|
|
[target.'cfg(unix)'.dependencies]
|
2022-04-20 15:45:18 +00:00
|
|
|
dep.workspace = true
|
2022-04-04 20:32:46 +00:00
|
|
|
[target.'cfg(windows)'.dependencies]
|
2022-04-20 15:45:18 +00:00
|
|
|
dep.workspace = true
|
2022-04-04 20:32:46 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("bar/src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
Package::new("dep", "0.1.2").publish();
|
|
|
|
|
2023-02-15 23:57:30 +00:00
|
|
|
p.cargo("check")
|
2022-03-22 02:27:49 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
2022-04-04 20:32:46 +00:00
|
|
|
[UPDATING] `[..]` index
|
|
|
|
[DOWNLOADING] crates ...
|
|
|
|
[DOWNLOADED] dep v0.1.2 ([..])
|
2023-02-15 23:57:30 +00:00
|
|
|
[CHECKING] dep v0.1.2
|
|
|
|
[CHECKING] bar v0.2.0 ([CWD]/bar)
|
2022-04-04 20:32:46 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
2022-03-22 02:27:49 +00:00
|
|
|
|
2022-04-04 20:32:46 +00:00
|
|
|
let lockfile = p.read_lockfile();
|
|
|
|
assert!(lockfile.contains("dep"));
|
|
|
|
}
|
2022-03-23 18:40:16 +00:00
|
|
|
|
2022-04-04 20:32:46 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn inherit_dependency_override_optional() {
|
|
|
|
Package::new("dep", "0.1.0").publish();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[workspace]
|
|
|
|
members = ["bar"]
|
|
|
|
[workspace.dependencies]
|
|
|
|
dep = "0.1.0"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2022-04-04 20:32:46 +00:00
|
|
|
workspace = ".."
|
|
|
|
name = "bar"
|
|
|
|
version = "0.2.0"
|
|
|
|
authors = []
|
|
|
|
[dependencies]
|
|
|
|
dep = { workspace = true, optional = true }
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("bar/src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
2023-02-15 23:57:30 +00:00
|
|
|
p.cargo("check")
|
2022-04-04 20:32:46 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] `[..]` index
|
2023-02-15 23:57:30 +00:00
|
|
|
[CHECKING] bar v0.2.0 ([CWD]/bar)
|
2022-04-04 20:32:46 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn inherit_dependency_features() {
|
|
|
|
Package::new("dep", "0.1.0")
|
|
|
|
.feature("fancy", &["fancy_dep"])
|
|
|
|
.add_dep(Dependency::new("fancy_dep", "0.2").optional(true))
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.publish();
|
|
|
|
|
|
|
|
Package::new("fancy_dep", "0.2.4").publish();
|
|
|
|
Package::new("dancy_dep", "0.6.8").publish();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2022-04-04 20:32:46 +00:00
|
|
|
name = "bar"
|
|
|
|
version = "0.2.0"
|
|
|
|
authors = []
|
|
|
|
[dependencies]
|
|
|
|
dep = { workspace = true, features = ["fancy"] }
|
|
|
|
|
|
|
|
[workspace]
|
|
|
|
members = []
|
|
|
|
[workspace.dependencies]
|
|
|
|
dep = "0.1"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
2023-02-15 23:57:30 +00:00
|
|
|
p.cargo("check")
|
2022-04-04 20:32:46 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] `[..]` index
|
|
|
|
[DOWNLOADING] crates ...
|
|
|
|
[DOWNLOADED] fancy_dep v0.2.4 ([..])
|
|
|
|
[DOWNLOADED] dep v0.1.0 ([..])
|
2023-02-15 23:57:30 +00:00
|
|
|
[CHECKING] fancy_dep v0.2.4
|
|
|
|
[CHECKING] dep v0.1.0
|
|
|
|
[CHECKING] bar v0.2.0 ([CWD])
|
2022-04-04 20:32:46 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2022-03-22 02:27:49 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
2022-04-04 20:32:46 +00:00
|
|
|
|
|
|
|
let lockfile = p.read_lockfile();
|
|
|
|
assert!(lockfile.contains("dep"));
|
|
|
|
assert!(lockfile.contains("fancy_dep"));
|
2022-03-22 02:27:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
2022-04-04 20:32:46 +00:00
|
|
|
fn inherit_detailed_dependencies() {
|
2022-03-22 02:27:49 +00:00
|
|
|
let git_project = git::new("detailed", |project| {
|
|
|
|
project
|
|
|
|
.file("Cargo.toml", &basic_lib_manifest("detailed"))
|
|
|
|
.file(
|
|
|
|
"src/detailed.rs",
|
|
|
|
r#"
|
|
|
|
pub fn hello() -> &'static str {
|
|
|
|
"hello world"
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
});
|
|
|
|
|
|
|
|
// Make a new branch based on the current HEAD commit
|
|
|
|
let repo = git2::Repository::open(&git_project.root()).unwrap();
|
|
|
|
let head = repo.head().unwrap().target().unwrap();
|
|
|
|
let head = repo.find_commit(head).unwrap();
|
|
|
|
repo.branch("branchy", &head, true).unwrap();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
&format!(
|
|
|
|
r#"
|
|
|
|
[workspace]
|
|
|
|
members = ["bar"]
|
|
|
|
[workspace.dependencies]
|
|
|
|
detailed = {{ git = '{}', branch = "branchy" }}
|
|
|
|
"#,
|
|
|
|
git_project.url()
|
|
|
|
),
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2022-03-22 02:27:49 +00:00
|
|
|
workspace = ".."
|
|
|
|
name = "bar"
|
|
|
|
version = "0.2.0"
|
|
|
|
authors = []
|
|
|
|
[dependencies]
|
2022-04-20 15:45:18 +00:00
|
|
|
detailed.workspace = true
|
2022-03-22 02:27:49 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("bar/src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
2022-04-04 20:32:46 +00:00
|
|
|
let git_root = git_project.root();
|
|
|
|
|
2023-02-15 23:57:30 +00:00
|
|
|
p.cargo("check")
|
2022-04-04 20:32:46 +00:00
|
|
|
.with_stderr(&format!(
|
2022-03-22 02:27:49 +00:00
|
|
|
"\
|
2022-04-04 20:32:46 +00:00
|
|
|
[UPDATING] git repository `{}`\n\
|
2023-02-15 23:57:30 +00:00
|
|
|
[CHECKING] detailed v0.5.0 ({}?branch=branchy#[..])\n\
|
|
|
|
[CHECKING] bar v0.2.0 ([CWD]/bar)\n\
|
2022-04-04 20:32:46 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]\n",
|
|
|
|
path2url(&git_root),
|
|
|
|
path2url(&git_root),
|
|
|
|
))
|
2022-03-22 02:27:49 +00:00
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2022-04-07 21:34:34 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn inherit_path_dependencies() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[workspace]
|
|
|
|
members = ["bar"]
|
|
|
|
[workspace.dependencies]
|
|
|
|
dep = { path = "dep" }
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2022-04-07 21:34:34 +00:00
|
|
|
workspace = ".."
|
|
|
|
name = "bar"
|
|
|
|
version = "0.2.0"
|
|
|
|
authors = []
|
|
|
|
[dependencies]
|
2022-04-20 15:45:18 +00:00
|
|
|
dep.workspace = true
|
2022-04-07 21:34:34 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("bar/src/main.rs", "fn main() {}")
|
|
|
|
.file("dep/Cargo.toml", &basic_manifest("dep", "0.9.0"))
|
|
|
|
.file("dep/src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
2023-02-15 23:57:30 +00:00
|
|
|
p.cargo("check")
|
2022-04-07 21:34:34 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
2023-02-15 23:57:30 +00:00
|
|
|
[CHECKING] dep v0.9.0 ([CWD]/dep)
|
|
|
|
[CHECKING] bar v0.2.0 ([CWD]/bar)
|
2022-04-07 21:34:34 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
|
|
|
|
let lockfile = p.read_lockfile();
|
|
|
|
assert!(lockfile.contains("dep"));
|
|
|
|
}
|
|
|
|
|
2022-03-22 02:27:49 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn error_workspace_false() {
|
|
|
|
registry::init();
|
|
|
|
|
|
|
|
let p = project().build();
|
|
|
|
|
|
|
|
let _ = git::repo(&paths::root().join("foo"))
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[workspace]
|
|
|
|
members = ["bar"]
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.file(
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
workspace = ".."
|
|
|
|
version = "1.2.3"
|
|
|
|
authors = ["rustaceans"]
|
|
|
|
description = { workspace = false }
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("bar/src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
2023-02-15 23:57:30 +00:00
|
|
|
p.cargo("check")
|
2022-03-22 02:27:49 +00:00
|
|
|
.cwd("bar")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
2023-12-14 22:28:05 +00:00
|
|
|
[ERROR] `workspace` cannot be false
|
|
|
|
--> Cargo.toml:7:41
|
|
|
|
|
|
|
|
|
7 | description = { workspace = false }
|
|
|
|
| ^^^^^
|
|
|
|
|
|
2022-03-22 02:27:49 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2022-03-23 18:40:16 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn error_workspace_dependency_looked_for_workspace_itself() {
|
|
|
|
registry::init();
|
|
|
|
|
|
|
|
let p = project().build();
|
|
|
|
|
|
|
|
let _ = git::repo(&paths::root().join("foo"))
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "1.2.3"
|
|
|
|
|
|
|
|
[dependencies]
|
2022-04-20 15:45:18 +00:00
|
|
|
dep.workspace = true
|
2022-03-23 18:40:16 +00:00
|
|
|
|
|
|
|
[workspace]
|
2023-01-25 16:50:55 +00:00
|
|
|
members = []
|
2022-03-23 18:40:16 +00:00
|
|
|
|
|
|
|
[workspace.dependencies]
|
2022-04-20 15:45:18 +00:00
|
|
|
dep.workspace = true
|
2022-03-23 18:40:16 +00:00
|
|
|
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
2023-02-15 23:57:30 +00:00
|
|
|
p.cargo("check")
|
2022-03-23 18:40:16 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
2023-01-25 16:50:55 +00:00
|
|
|
[WARNING] [CWD]/Cargo.toml: unused manifest key: workspace.dependencies.dep.workspace
|
2023-04-20 01:32:24 +00:00
|
|
|
[WARNING] [CWD]/Cargo.toml: dependency (dep) specified without providing a local path, Git repository, version, \
|
|
|
|
or workspace dependency to use. \
|
|
|
|
This will be considered an error in future versions
|
2023-01-25 16:50:55 +00:00
|
|
|
[UPDATING] `dummy-registry` index
|
|
|
|
[ERROR] no matching package named `dep` found
|
|
|
|
location searched: registry `crates-io`
|
|
|
|
required by package `bar v1.2.3 ([CWD])`
|
2022-03-23 18:40:16 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2022-04-04 20:32:46 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn error_malformed_workspace_root() {
|
|
|
|
registry::init();
|
|
|
|
|
|
|
|
let p = project().build();
|
|
|
|
|
|
|
|
let _ = git::repo(&paths::root().join("foo"))
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[workspace]
|
|
|
|
members = [invalid toml
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.file(
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
workspace = ".."
|
|
|
|
version = "1.2.3"
|
|
|
|
authors = ["rustaceans"]
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("bar/src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
2023-02-15 23:57:30 +00:00
|
|
|
p.cargo("check")
|
2022-04-04 20:32:46 +00:00
|
|
|
.cwd("bar")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
2023-12-14 22:28:05 +00:00
|
|
|
[ERROR] invalid array
|
|
|
|
expected `]`
|
|
|
|
--> ../Cargo.toml:3:24
|
|
|
|
|
|
|
|
|
3 | members = [invalid toml
|
|
|
|
| ^
|
|
|
|
|
|
2022-04-04 20:32:46 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn error_no_root_workspace() {
|
|
|
|
registry::init();
|
|
|
|
|
|
|
|
let p = project().build();
|
|
|
|
|
|
|
|
let _ = git::repo(&paths::root().join("foo"))
|
|
|
|
.file(
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
workspace = ".."
|
|
|
|
version = "1.2.3"
|
|
|
|
authors = ["rustaceans"]
|
2022-04-20 15:44:53 +00:00
|
|
|
description.workspace = true
|
2022-04-04 20:32:46 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.file("bar/src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
2023-02-15 23:57:30 +00:00
|
|
|
p.cargo("check")
|
2022-04-04 20:32:46 +00:00
|
|
|
.cwd("bar")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[ERROR] failed to parse manifest at `[..]/Cargo.toml`
|
|
|
|
|
|
|
|
Caused by:
|
2022-04-13 20:22:38 +00:00
|
|
|
error inheriting `description` from workspace root manifest's `workspace.package.description`
|
2022-04-04 20:32:46 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
root of a workspace inferred but wasn't a root: [..]/Cargo.toml
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn error_inherit_unspecified_dependency() {
|
|
|
|
let p = project().build();
|
|
|
|
|
|
|
|
let _ = git::repo(&paths::root().join("foo"))
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[workspace]
|
|
|
|
members = ["bar"]
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.file(
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
workspace = ".."
|
|
|
|
version = "1.2.3"
|
|
|
|
authors = ["rustaceans"]
|
|
|
|
[dependencies]
|
2022-04-20 15:45:18 +00:00
|
|
|
foo.workspace = true
|
2022-04-04 20:32:46 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("bar/src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
2023-02-15 23:57:30 +00:00
|
|
|
p.cargo("check")
|
2022-04-04 20:32:46 +00:00
|
|
|
.cwd("bar")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[ERROR] failed to parse manifest at `[CWD]/Cargo.toml`
|
|
|
|
|
|
|
|
Caused by:
|
2023-01-25 16:50:55 +00:00
|
|
|
error inheriting `foo` from workspace root manifest's `workspace.dependencies.foo`
|
2022-04-04 20:32:46 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
`workspace.dependencies` was not defined
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
2023-01-10 17:53:45 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn warn_inherit_def_feat_true_member_def_feat_false() {
|
|
|
|
Package::new("dep", "0.1.0")
|
|
|
|
.feature("default", &["fancy_dep"])
|
|
|
|
.add_dep(Dependency::new("fancy_dep", "0.2").optional(true))
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.publish();
|
|
|
|
|
|
|
|
Package::new("fancy_dep", "0.2.4").publish();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.2.0"
|
|
|
|
authors = []
|
|
|
|
[dependencies]
|
|
|
|
dep = { workspace = true, default-features = false }
|
|
|
|
|
|
|
|
[workspace]
|
|
|
|
members = []
|
|
|
|
[workspace.dependencies]
|
|
|
|
dep = { version = "0.1.0", default-features = true }
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("check")
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[WARNING] [CWD]/Cargo.toml: `default-features` is ignored for dep, since `default-features` was \
|
|
|
|
true for `workspace.dependencies.dep`, this could become a hard error in the future
|
|
|
|
[UPDATING] `dummy-registry` index
|
|
|
|
[DOWNLOADING] crates ...
|
|
|
|
[DOWNLOADED] fancy_dep v0.2.4 ([..])
|
|
|
|
[DOWNLOADED] dep v0.1.0 ([..])
|
|
|
|
[CHECKING] fancy_dep v0.2.4
|
|
|
|
[CHECKING] dep v0.1.0
|
|
|
|
[CHECKING] bar v0.2.0 ([CWD])
|
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn warn_inherit_simple_member_def_feat_false() {
|
|
|
|
Package::new("dep", "0.1.0")
|
|
|
|
.feature("default", &["fancy_dep"])
|
|
|
|
.add_dep(Dependency::new("fancy_dep", "0.2").optional(true))
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.publish();
|
|
|
|
|
|
|
|
Package::new("fancy_dep", "0.2.4").publish();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.2.0"
|
|
|
|
authors = []
|
|
|
|
[dependencies]
|
|
|
|
dep = { workspace = true, default-features = false }
|
|
|
|
|
|
|
|
[workspace]
|
|
|
|
members = []
|
|
|
|
[workspace.dependencies]
|
|
|
|
dep = "0.1.0"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("check")
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[WARNING] [CWD]/Cargo.toml: `default-features` is ignored for dep, since `default-features` was \
|
|
|
|
not specified for `workspace.dependencies.dep`, this could become a hard error in the future
|
|
|
|
[UPDATING] `dummy-registry` index
|
|
|
|
[DOWNLOADING] crates ...
|
|
|
|
[DOWNLOADED] fancy_dep v0.2.4 ([..])
|
|
|
|
[DOWNLOADED] dep v0.1.0 ([..])
|
|
|
|
[CHECKING] fancy_dep v0.2.4
|
|
|
|
[CHECKING] dep v0.1.0
|
|
|
|
[CHECKING] bar v0.2.0 ([CWD])
|
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn inherit_def_feat_false_member_def_feat_true() {
|
|
|
|
Package::new("dep", "0.1.0")
|
|
|
|
.feature("default", &["fancy_dep"])
|
|
|
|
.add_dep(Dependency::new("fancy_dep", "0.2").optional(true))
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.publish();
|
|
|
|
|
|
|
|
Package::new("fancy_dep", "0.2.4").publish();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.2.0"
|
|
|
|
authors = []
|
|
|
|
[dependencies]
|
|
|
|
dep = { workspace = true, default-features = true }
|
|
|
|
|
|
|
|
[workspace]
|
|
|
|
members = []
|
|
|
|
[workspace.dependencies]
|
|
|
|
dep = { version = "0.1.0", default-features = false }
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("check")
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] `dummy-registry` index
|
|
|
|
[DOWNLOADING] crates ...
|
|
|
|
[DOWNLOADED] fancy_dep v0.2.4 ([..])
|
|
|
|
[DOWNLOADED] dep v0.1.0 ([..])
|
|
|
|
[CHECKING] fancy_dep v0.2.4
|
|
|
|
[CHECKING] dep v0.1.0
|
|
|
|
[CHECKING] bar v0.2.0 ([CWD])
|
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
2023-01-25 16:50:55 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn cannot_inherit_in_patch() {
|
|
|
|
Package::new("bar", "0.1.0").publish();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[workspace]
|
|
|
|
members = []
|
|
|
|
|
|
|
|
[workspace.dependencies]
|
|
|
|
bar = { path = "bar" }
|
|
|
|
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.2.0"
|
|
|
|
|
|
|
|
[patch.crates-io]
|
|
|
|
bar.workspace = true
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = "0.1.0"
|
|
|
|
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("check")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[WARNING] [CWD]/Cargo.toml: unused manifest key: patch.crates-io.bar.workspace
|
2023-04-20 01:32:24 +00:00
|
|
|
[WARNING] [CWD]/Cargo.toml: dependency (bar) specified without providing a local path, Git repository, version, \
|
|
|
|
or workspace dependency to use. \
|
|
|
|
This will be considered an error in future versions
|
2023-01-25 16:50:55 +00:00
|
|
|
[UPDATING] `dummy-registry` index
|
|
|
|
[ERROR] failed to resolve patches for `https://github.com/rust-lang/crates.io-index`
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
patch for `bar` in `https://github.com/rust-lang/crates.io-index` points to the same source, but patches must point to different sources
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
2023-03-01 19:38:20 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn warn_inherit_unused_manifest_key_dep() {
|
|
|
|
Package::new("dep", "0.1.0").publish();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[workspace]
|
|
|
|
members = []
|
|
|
|
[workspace.dependencies]
|
|
|
|
dep = { version = "0.1", wxz = "wxz" }
|
|
|
|
|
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.2.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
dep = { workspace = true, wxz = "wxz" }
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("check")
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[WARNING] [CWD]/Cargo.toml: unused manifest key: workspace.dependencies.dep.wxz
|
|
|
|
[WARNING] [CWD]/Cargo.toml: unused manifest key: dependencies.dep.wxz
|
|
|
|
[UPDATING] `[..]` index
|
|
|
|
[DOWNLOADING] crates ...
|
|
|
|
[DOWNLOADED] dep v0.1.0 ([..])
|
|
|
|
[CHECKING] [..]
|
|
|
|
[CHECKING] bar v0.2.0 ([CWD])
|
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2024-01-08 15:21:31 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn warn_unused_workspace_package_field() {
|
|
|
|
Package::new("dep", "0.1.0").publish();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[workspace]
|
|
|
|
members = []
|
|
|
|
[workspace.package]
|
|
|
|
name = "unused"
|
|
|
|
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("check")
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[WARNING] [CWD]/Cargo.toml: unused manifest key: workspace.package.name
|
|
|
|
[CHECKING] foo v0.0.0 ([CWD])
|
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2023-03-01 19:38:20 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn warn_inherit_unused_manifest_key_package() {
|
|
|
|
Package::new("dep", "0.1.0").publish();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
badges = { workspace = true, xyz = "abc"}
|
|
|
|
|
|
|
|
[workspace]
|
|
|
|
members = []
|
|
|
|
[workspace.package]
|
|
|
|
version = "1.2.3"
|
|
|
|
authors = ["Rustaceans"]
|
|
|
|
description = "This is a crate"
|
|
|
|
documentation = "https://www.rust-lang.org/learn"
|
|
|
|
homepage = "https://www.rust-lang.org"
|
|
|
|
repository = "https://github.com/example/example"
|
|
|
|
license = "MIT"
|
|
|
|
keywords = ["cli"]
|
|
|
|
categories = ["development-tools"]
|
|
|
|
publish = true
|
|
|
|
edition = "2018"
|
|
|
|
rust-version = "1.60"
|
|
|
|
exclude = ["foo.txt"]
|
|
|
|
include = ["bar.txt", "**/*.rs", "Cargo.toml"]
|
|
|
|
[workspace.package.badges]
|
|
|
|
gitlab = { repository = "https://gitlab.com/rust-lang/rust", branch = "master" }
|
|
|
|
|
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = { workspace = true, xyz = "abc"}
|
|
|
|
authors = { workspace = true, xyz = "abc"}
|
|
|
|
description = { workspace = true, xyz = "abc"}
|
|
|
|
documentation = { workspace = true, xyz = "abc"}
|
|
|
|
homepage = { workspace = true, xyz = "abc"}
|
|
|
|
repository = { workspace = true, xyz = "abc"}
|
|
|
|
license = { workspace = true, xyz = "abc"}
|
|
|
|
keywords = { workspace = true, xyz = "abc"}
|
|
|
|
categories = { workspace = true, xyz = "abc"}
|
|
|
|
publish = { workspace = true, xyz = "abc"}
|
|
|
|
edition = { workspace = true, xyz = "abc"}
|
|
|
|
rust-version = { workspace = true, xyz = "abc"}
|
|
|
|
exclude = { workspace = true, xyz = "abc"}
|
|
|
|
include = { workspace = true, xyz = "abc"}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("check")
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[WARNING] [CWD]/Cargo.toml: unused manifest key: package.authors.xyz
|
|
|
|
[WARNING] [CWD]/Cargo.toml: unused manifest key: package.categories.xyz
|
|
|
|
[WARNING] [CWD]/Cargo.toml: unused manifest key: package.description.xyz
|
|
|
|
[WARNING] [CWD]/Cargo.toml: unused manifest key: package.documentation.xyz
|
|
|
|
[WARNING] [CWD]/Cargo.toml: unused manifest key: package.edition.xyz
|
|
|
|
[WARNING] [CWD]/Cargo.toml: unused manifest key: package.exclude.xyz
|
|
|
|
[WARNING] [CWD]/Cargo.toml: unused manifest key: package.homepage.xyz
|
|
|
|
[WARNING] [CWD]/Cargo.toml: unused manifest key: package.include.xyz
|
|
|
|
[WARNING] [CWD]/Cargo.toml: unused manifest key: package.keywords.xyz
|
|
|
|
[WARNING] [CWD]/Cargo.toml: unused manifest key: package.license.xyz
|
|
|
|
[WARNING] [CWD]/Cargo.toml: unused manifest key: package.publish.xyz
|
|
|
|
[WARNING] [CWD]/Cargo.toml: unused manifest key: package.repository.xyz
|
|
|
|
[WARNING] [CWD]/Cargo.toml: unused manifest key: package.rust-version.xyz
|
|
|
|
[WARNING] [CWD]/Cargo.toml: unused manifest key: package.version.xyz
|
|
|
|
[CHECKING] bar v1.2.3 ([CWD])
|
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|