mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
test: migrate weak_dep_features to snapbox
This commit is contained in:
parent
5e93754c31
commit
51b794636d
@ -1,10 +1,9 @@
|
|||||||
//! Tests for weak-dep-features.
|
//! Tests for weak-dep-features.
|
||||||
|
|
||||||
#![allow(deprecated)]
|
|
||||||
|
|
||||||
use super::features2::switch_to_resolver_2;
|
use super::features2::switch_to_resolver_2;
|
||||||
use cargo_test_support::paths::CargoPathExt;
|
use cargo_test_support::paths::CargoPathExt;
|
||||||
use cargo_test_support::registry::{Dependency, Package, RegistryBuilder};
|
use cargo_test_support::registry::{Dependency, Package, RegistryBuilder};
|
||||||
|
use cargo_test_support::str;
|
||||||
use cargo_test_support::{project, publish};
|
use cargo_test_support::{project, publish};
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
|
|
||||||
@ -51,26 +50,24 @@ fn simple() {
|
|||||||
// It's a bit unfortunate that this has to download `bar`, but avoiding
|
// It's a bit unfortunate that this has to download `bar`, but avoiding
|
||||||
// that is extremely difficult.
|
// that is extremely difficult.
|
||||||
p.cargo("check --features f1")
|
p.cargo("check --features f1")
|
||||||
.with_stderr(
|
.with_stderr_data(str![[r#"
|
||||||
"\
|
[UPDATING] `dummy-registry` index
|
||||||
[UPDATING] [..]
|
|
||||||
[LOCKING] 2 packages to latest compatible versions
|
[LOCKING] 2 packages to latest compatible versions
|
||||||
[DOWNLOADING] crates ...
|
[DOWNLOADING] crates ...
|
||||||
[DOWNLOADED] bar v1.0.0 [..]
|
[DOWNLOADED] bar v1.0.0 (registry `dummy-registry`)
|
||||||
[CHECKING] foo v0.1.0 [..]
|
[CHECKING] foo v0.1.0 ([ROOT]/foo)
|
||||||
[FINISHED] [..]
|
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||||
",
|
|
||||||
)
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
p.cargo("check --features f1,bar")
|
p.cargo("check --features f1,bar")
|
||||||
.with_stderr(
|
.with_stderr_data(str![[r#"
|
||||||
"\
|
|
||||||
[CHECKING] bar v1.0.0
|
[CHECKING] bar v1.0.0
|
||||||
[CHECKING] foo v0.1.0 [..]
|
[CHECKING] foo v0.1.0 ([ROOT]/foo)
|
||||||
[FINISHED] [..]
|
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||||
",
|
|
||||||
)
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,21 +104,20 @@ fn deferred() {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
p.cargo("check")
|
p.cargo("check")
|
||||||
.with_stderr(
|
.with_stderr_data(str![[r#"
|
||||||
"\
|
[UPDATING] `dummy-registry` index
|
||||||
[UPDATING] [..]
|
|
||||||
[LOCKING] 4 packages to latest compatible versions
|
[LOCKING] 4 packages to latest compatible versions
|
||||||
[DOWNLOADING] crates ...
|
[DOWNLOADING] crates ...
|
||||||
[DOWNLOADED] dep v1.0.0 [..]
|
[DOWNLOADED] dep v1.0.0 (registry `dummy-registry`)
|
||||||
[DOWNLOADED] bar_activator v1.0.0 [..]
|
[DOWNLOADED] bar_activator v1.0.0 (registry `dummy-registry`)
|
||||||
[DOWNLOADED] bar v1.0.0 [..]
|
[DOWNLOADED] bar v1.0.0 (registry `dummy-registry`)
|
||||||
[CHECKING] bar v1.0.0
|
[CHECKING] bar v1.0.0
|
||||||
[CHECKING] dep v1.0.0
|
[CHECKING] dep v1.0.0
|
||||||
[CHECKING] bar_activator v1.0.0
|
[CHECKING] bar_activator v1.0.0
|
||||||
[CHECKING] foo v0.1.0 [..]
|
[CHECKING] foo v0.1.0 ([ROOT]/foo)
|
||||||
[FINISHED] [..]
|
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||||
",
|
|
||||||
)
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,13 +147,14 @@ fn not_optional_dep() {
|
|||||||
|
|
||||||
p.cargo("check")
|
p.cargo("check")
|
||||||
.with_status(101)
|
.with_status(101)
|
||||||
.with_stderr("\
|
.with_stderr_data(str![[r#"
|
||||||
error: failed to parse manifest at `[ROOT]/foo/Cargo.toml`
|
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
|
||||||
|
|
||||||
Caused by:
|
Caused by:
|
||||||
feature `feat` includes `dep?/feat` with a `?`, but `dep` is not an optional dependency
|
feature `feat` includes `dep?/feat` with a `?`, but `dep` is not an optional dependency
|
||||||
A non-optional dependency of the same name is defined; consider removing the `?` or changing the dependency to be optional
|
A non-optional dependency of the same name is defined; consider removing the `?` or changing the dependency to be optional
|
||||||
")
|
|
||||||
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,27 +184,25 @@ fn optional_cli_syntax() {
|
|||||||
|
|
||||||
// Does not build bar.
|
// Does not build bar.
|
||||||
p.cargo("check --features bar?/feat")
|
p.cargo("check --features bar?/feat")
|
||||||
.with_stderr(
|
.with_stderr_data(str![[r#"
|
||||||
"\
|
[UPDATING] `dummy-registry` index
|
||||||
[UPDATING] [..]
|
|
||||||
[LOCKING] 2 packages to latest compatible versions
|
[LOCKING] 2 packages to latest compatible versions
|
||||||
[DOWNLOADING] crates ...
|
[DOWNLOADING] crates ...
|
||||||
[DOWNLOADED] bar v1.0.0 [..]
|
[DOWNLOADED] bar v1.0.0 (registry `dummy-registry`)
|
||||||
[CHECKING] foo v0.1.0 [..]
|
[CHECKING] foo v0.1.0 ([ROOT]/foo)
|
||||||
[FINISHED] [..]
|
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||||
",
|
|
||||||
)
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
// Builds bar.
|
// Builds bar.
|
||||||
p.cargo("check --features bar?/feat,bar")
|
p.cargo("check --features bar?/feat,bar")
|
||||||
.with_stderr(
|
.with_stderr_data(str![[r#"
|
||||||
"\
|
|
||||||
[CHECKING] bar v1.0.0
|
[CHECKING] bar v1.0.0
|
||||||
[CHECKING] foo v0.1.0 [..]
|
[CHECKING] foo v0.1.0 ([ROOT]/foo)
|
||||||
[FINISHED] [..]
|
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||||
",
|
|
||||||
)
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
eprintln!("check V2 resolver");
|
eprintln!("check V2 resolver");
|
||||||
@ -215,23 +210,21 @@ fn optional_cli_syntax() {
|
|||||||
p.build_dir().rm_rf();
|
p.build_dir().rm_rf();
|
||||||
// Does not build bar.
|
// Does not build bar.
|
||||||
p.cargo("check --features bar?/feat")
|
p.cargo("check --features bar?/feat")
|
||||||
.with_stderr(
|
.with_stderr_data(str![[r#"
|
||||||
"\
|
[CHECKING] foo v0.1.0 ([ROOT]/foo)
|
||||||
[CHECKING] foo v0.1.0 [..]
|
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||||
[FINISHED] [..]
|
|
||||||
",
|
"#]])
|
||||||
)
|
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
// Builds bar.
|
// Builds bar.
|
||||||
p.cargo("check --features bar?/feat,bar")
|
p.cargo("check --features bar?/feat,bar")
|
||||||
.with_stderr(
|
.with_stderr_data(str![[r#"
|
||||||
"\
|
|
||||||
[CHECKING] bar v1.0.0
|
[CHECKING] bar v1.0.0
|
||||||
[CHECKING] foo v0.1.0 [..]
|
[CHECKING] foo v0.1.0 ([ROOT]/foo)
|
||||||
[FINISHED] [..]
|
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||||
",
|
|
||||||
)
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,14 +255,12 @@ fn required_features() {
|
|||||||
|
|
||||||
p.cargo("check")
|
p.cargo("check")
|
||||||
.with_status(101)
|
.with_status(101)
|
||||||
.with_stderr(
|
.with_stderr_data(str![[r#"
|
||||||
"\
|
[UPDATING] `dummy-registry` index
|
||||||
[UPDATING] [..]
|
|
||||||
[LOCKING] 2 packages to latest compatible versions
|
[LOCKING] 2 packages to latest compatible versions
|
||||||
[ERROR] invalid feature `bar?/feat` in required-features of target `foo`: \
|
[ERROR] invalid feature `bar?/feat` in required-features of target `foo`: optional dependency with `?` is not allowed in required-features
|
||||||
optional dependency with `?` is not allowed in required-features
|
|
||||||
",
|
"#]])
|
||||||
)
|
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,22 +349,21 @@ fn weak_with_host_decouple() {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
p.cargo("run")
|
p.cargo("run")
|
||||||
.with_stderr(
|
.with_stderr_data(str![[r#"
|
||||||
"\
|
[UPDATING] `dummy-registry` index
|
||||||
[UPDATING] [..]
|
|
||||||
[LOCKING] 4 packages to latest compatible versions
|
[LOCKING] 4 packages to latest compatible versions
|
||||||
[DOWNLOADING] crates ...
|
[DOWNLOADING] crates ...
|
||||||
[DOWNLOADED] [..]
|
[DOWNLOADED] common v1.0.0 (registry `dummy-registry`)
|
||||||
[DOWNLOADED] [..]
|
[DOWNLOADED] bar_activator v1.0.0 (registry `dummy-registry`)
|
||||||
[DOWNLOADED] [..]
|
[DOWNLOADED] bar v1.0.0 (registry `dummy-registry`)
|
||||||
[COMPILING] bar v1.0.0
|
[COMPILING] bar v1.0.0
|
||||||
[COMPILING] common v1.0.0
|
[COMPILING] common v1.0.0
|
||||||
[COMPILING] bar_activator v1.0.0
|
[COMPILING] bar_activator v1.0.0
|
||||||
[COMPILING] foo v0.1.0 [..]
|
[COMPILING] foo v0.1.0 ([ROOT]/foo)
|
||||||
[FINISHED] [..]
|
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||||
[RUNNING] `target/debug/foo[EXE]`
|
[RUNNING] `target/debug/foo[EXE]`
|
||||||
",
|
|
||||||
)
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -405,49 +395,52 @@ fn weak_namespaced() {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
p.cargo("check --features f1")
|
p.cargo("check --features f1")
|
||||||
.with_stderr(
|
.with_stderr_data(str![[r#"
|
||||||
"\
|
[UPDATING] `dummy-registry` index
|
||||||
[UPDATING] [..]
|
|
||||||
[LOCKING] 2 packages to latest compatible versions
|
[LOCKING] 2 packages to latest compatible versions
|
||||||
[DOWNLOADING] crates ...
|
[DOWNLOADING] crates ...
|
||||||
[DOWNLOADED] bar v1.0.0 [..]
|
[DOWNLOADED] bar v1.0.0 (registry `dummy-registry`)
|
||||||
[CHECKING] foo v0.1.0 [..]
|
[CHECKING] foo v0.1.0 ([ROOT]/foo)
|
||||||
[FINISHED] [..]
|
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||||
",
|
|
||||||
)
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
p.cargo("tree -f")
|
p.cargo("tree -f")
|
||||||
.arg("{p} feats:{f}")
|
.arg("{p} feats:{f}")
|
||||||
.with_stdout("foo v0.1.0 ([ROOT]/foo) feats:")
|
.with_stdout_data(str![[r#"
|
||||||
|
foo v0.1.0 ([ROOT]/foo) feats:
|
||||||
|
|
||||||
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
p.cargo("tree --features f1 -f")
|
p.cargo("tree --features f1 -f")
|
||||||
.arg("{p} feats:{f}")
|
.arg("{p} feats:{f}")
|
||||||
.with_stdout("foo v0.1.0 ([ROOT]/foo) feats:f1")
|
.with_stdout_data(str![[r#"
|
||||||
|
foo v0.1.0 ([ROOT]/foo) feats:f1
|
||||||
|
|
||||||
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
p.cargo("tree --features f1,f2 -f")
|
p.cargo("tree --features f1,f2 -f")
|
||||||
.arg("{p} feats:{f}")
|
.arg("{p} feats:{f}")
|
||||||
.with_stdout(
|
.with_stdout_data(str![[r#"
|
||||||
"\
|
|
||||||
foo v0.1.0 ([ROOT]/foo) feats:f1,f2
|
foo v0.1.0 ([ROOT]/foo) feats:f1,f2
|
||||||
└── bar v1.0.0 feats:feat
|
└── bar v1.0.0 feats:feat
|
||||||
",
|
|
||||||
)
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
// "bar" remains not-a-feature
|
// "bar" remains not-a-feature
|
||||||
p.change_file("src/lib.rs", &require(&["f1", "f2"], &["bar"]));
|
p.change_file("src/lib.rs", &require(&["f1", "f2"], &["bar"]));
|
||||||
|
|
||||||
p.cargo("check --features f1,f2")
|
p.cargo("check --features f1,f2")
|
||||||
.with_stderr(
|
.with_stderr_data(str![[r#"
|
||||||
"\
|
|
||||||
[CHECKING] bar v1.0.0
|
[CHECKING] bar v1.0.0
|
||||||
[CHECKING] foo v0.1.0 [..]
|
[CHECKING] foo v0.1.0 ([ROOT]/foo)
|
||||||
[FINISHED] [..]
|
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||||
",
|
|
||||||
)
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -477,64 +470,66 @@ fn tree() {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
p.cargo("tree --features f1")
|
p.cargo("tree --features f1")
|
||||||
.with_stdout("foo v0.1.0 ([ROOT]/foo)")
|
.with_stdout_data(str![[r#"
|
||||||
|
foo v0.1.0 ([ROOT]/foo)
|
||||||
|
|
||||||
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
p.cargo("tree --features f1,bar")
|
p.cargo("tree --features f1,bar")
|
||||||
.with_stdout(
|
.with_stdout_data(str![[r#"
|
||||||
"\
|
|
||||||
foo v0.1.0 ([ROOT]/foo)
|
foo v0.1.0 ([ROOT]/foo)
|
||||||
└── bar v1.0.0
|
└── bar v1.0.0
|
||||||
",
|
|
||||||
)
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
p.cargo("tree --features f1,bar -e features")
|
p.cargo("tree --features f1,bar -e features")
|
||||||
.with_stdout(
|
.with_stdout_data(str![[r#"
|
||||||
"\
|
|
||||||
foo v0.1.0 ([ROOT]/foo)
|
foo v0.1.0 ([ROOT]/foo)
|
||||||
└── bar feature \"default\"
|
└── bar feature "default"
|
||||||
└── bar v1.0.0
|
└── bar v1.0.0
|
||||||
",
|
|
||||||
)
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
p.cargo("tree --features f1,bar -e features -i bar")
|
p.cargo("tree --features f1,bar -e features -i bar")
|
||||||
.with_stdout(
|
.with_stdout_data(str![[r#"
|
||||||
"\
|
|
||||||
bar v1.0.0
|
bar v1.0.0
|
||||||
├── bar feature \"default\"
|
├── bar feature "default"
|
||||||
│ └── foo v0.1.0 ([ROOT]/foo)
|
│ └── foo v0.1.0 ([ROOT]/foo)
|
||||||
│ ├── foo feature \"bar\" (command-line)
|
│ ├── foo feature "bar" (command-line)
|
||||||
│ ├── foo feature \"default\" (command-line)
|
│ ├── foo feature "default" (command-line)
|
||||||
│ └── foo feature \"f1\" (command-line)
|
│ └── foo feature "f1" (command-line)
|
||||||
└── bar feature \"feat\"
|
└── bar feature "feat"
|
||||||
└── foo feature \"f1\" (command-line)
|
└── foo feature "f1" (command-line)
|
||||||
",
|
|
||||||
)
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
p.cargo("tree -e features --features bar?/feat")
|
p.cargo("tree -e features --features bar?/feat")
|
||||||
.with_stdout("foo v0.1.0 ([ROOT]/foo)")
|
.with_stdout_data(str![[r#"
|
||||||
|
foo v0.1.0 ([ROOT]/foo)
|
||||||
|
|
||||||
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
// This is a little strange in that it produces no output.
|
// This is a little strange in that it produces no output.
|
||||||
// Maybe `cargo tree` should print a note about why?
|
// Maybe `cargo tree` should print a note about why?
|
||||||
p.cargo("tree -e features -i bar --features bar?/feat")
|
p.cargo("tree -e features -i bar --features bar?/feat")
|
||||||
.with_stdout("")
|
.with_stdout_data("")
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
p.cargo("tree -e features -i bar --features bar?/feat,bar")
|
p.cargo("tree -e features -i bar --features bar?/feat,bar")
|
||||||
.with_stdout(
|
.with_stdout_data(str![[r#"
|
||||||
"\
|
|
||||||
bar v1.0.0
|
bar v1.0.0
|
||||||
├── bar feature \"default\"
|
├── bar feature "default"
|
||||||
│ └── foo v0.1.0 ([ROOT]/foo)
|
│ └── foo v0.1.0 ([ROOT]/foo)
|
||||||
│ ├── foo feature \"bar\" (command-line)
|
│ ├── foo feature "bar" (command-line)
|
||||||
│ └── foo feature \"default\" (command-line)
|
│ └── foo feature "default" (command-line)
|
||||||
└── bar feature \"feat\" (command-line)
|
└── bar feature "feat" (command-line)
|
||||||
",
|
|
||||||
)
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -569,22 +564,21 @@ fn publish() {
|
|||||||
|
|
||||||
p.cargo("publish")
|
p.cargo("publish")
|
||||||
.replace_crates_io(registry.index_url())
|
.replace_crates_io(registry.index_url())
|
||||||
.with_stderr(
|
.with_stderr_data(str![[r#"
|
||||||
"\
|
[UPDATING] crates.io index
|
||||||
[UPDATING] [..]
|
[PACKAGING] foo v0.1.0 ([ROOT]/foo)
|
||||||
[PACKAGING] foo v0.1.0 [..]
|
[PACKAGED] 3 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
|
||||||
[PACKAGED] [..]
|
[VERIFYING] foo v0.1.0 ([ROOT]/foo)
|
||||||
[VERIFYING] foo v0.1.0 [..]
|
[UPDATING] crates.io index
|
||||||
[UPDATING] [..]
|
[COMPILING] foo v0.1.0 ([ROOT]/foo/target/package/foo-0.1.0)
|
||||||
[COMPILING] foo v0.1.0 [..]
|
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||||
[FINISHED] [..]
|
[UPLOADING] foo v0.1.0 ([ROOT]/foo)
|
||||||
[UPLOADING] foo v0.1.0 [..]
|
|
||||||
[UPLOADED] foo v0.1.0 to registry `crates-io`
|
[UPLOADED] foo v0.1.0 to registry `crates-io`
|
||||||
[NOTE] waiting for `foo v0.1.0` to be available at registry `crates-io`.
|
[NOTE] waiting for `foo v0.1.0` to be available at registry `crates-io`.
|
||||||
You may press ctrl-c to skip waiting; the crate should be available shortly.
|
You may press ctrl-c to skip waiting; the crate should be available shortly.
|
||||||
[PUBLISHED] foo v0.1.0 at registry `crates-io`
|
[PUBLISHED] foo v0.1.0 at registry `crates-io`
|
||||||
",
|
|
||||||
)
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
publish::validate_upload_with_contents(
|
publish::validate_upload_with_contents(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user