mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
test: migrate cfg to snapbox
This commit is contained in:
parent
bff8a08165
commit
de159b09f7
@ -1,10 +1,8 @@
|
|||||||
//! Tests for cfg() expressions.
|
//! Tests for cfg() expressions.
|
||||||
|
|
||||||
#![allow(deprecated)]
|
|
||||||
|
|
||||||
use cargo_test_support::registry::Package;
|
use cargo_test_support::registry::Package;
|
||||||
use cargo_test_support::rustc_host;
|
use cargo_test_support::rustc_host;
|
||||||
use cargo_test_support::{basic_manifest, project};
|
use cargo_test_support::{basic_manifest, project, str};
|
||||||
|
|
||||||
#[cargo_test]
|
#[cargo_test]
|
||||||
fn cfg_easy() {
|
fn cfg_easy() {
|
||||||
@ -56,13 +54,12 @@ fn dont_include() {
|
|||||||
.file("b/src/lib.rs", "")
|
.file("b/src/lib.rs", "")
|
||||||
.build();
|
.build();
|
||||||
p.cargo("check")
|
p.cargo("check")
|
||||||
.with_stderr(
|
.with_stderr_data(str![[r#"
|
||||||
"\
|
|
||||||
[LOCKING] 2 packages to latest compatible versions
|
[LOCKING] 2 packages to latest compatible versions
|
||||||
[CHECKING] a v0.0.1 ([..])
|
[CHECKING] a v0.0.1 ([ROOT]/foo)
|
||||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
|
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||||
",
|
|
||||||
)
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,19 +92,18 @@ fn works_through_the_registry() {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
p.cargo("check")
|
p.cargo("check")
|
||||||
.with_stderr(
|
.with_stderr_data(str![[r#"
|
||||||
"\
|
[UPDATING] `dummy-registry` index
|
||||||
[UPDATING] [..] index
|
|
||||||
[LOCKING] 3 packages to latest compatible versions
|
[LOCKING] 3 packages to latest compatible versions
|
||||||
[DOWNLOADING] crates ...
|
[DOWNLOADING] crates ...
|
||||||
[DOWNLOADED] [..]
|
[DOWNLOADED] baz v0.1.0 (registry `dummy-registry`)
|
||||||
[DOWNLOADED] [..]
|
[DOWNLOADED] bar v0.1.0 (registry `dummy-registry`)
|
||||||
[CHECKING] baz v0.1.0
|
[CHECKING] baz v0.1.0
|
||||||
[CHECKING] bar v0.1.0
|
[CHECKING] bar v0.1.0
|
||||||
[CHECKING] foo v0.0.1 ([..])
|
[CHECKING] foo v0.0.1 ([ROOT]/foo)
|
||||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
|
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||||
",
|
|
||||||
)
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,18 +141,17 @@ fn ignore_version_from_other_platform() {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
p.cargo("check")
|
p.cargo("check")
|
||||||
.with_stderr(
|
.with_stderr_data(str![[r#"
|
||||||
"\
|
[UPDATING] `dummy-registry` index
|
||||||
[UPDATING] [..] index
|
|
||||||
[LOCKING] 3 packages to latest compatible versions
|
[LOCKING] 3 packages to latest compatible versions
|
||||||
[ADDING] bar v0.1.0 (latest: v0.2.0)
|
[ADDING] bar v0.1.0 (latest: v0.2.0)
|
||||||
[DOWNLOADING] crates ...
|
[DOWNLOADING] crates ...
|
||||||
[DOWNLOADED] [..]
|
[DOWNLOADED] bar v0.1.0 (registry `dummy-registry`)
|
||||||
[CHECKING] bar v0.1.0
|
[CHECKING] bar v0.1.0
|
||||||
[CHECKING] foo v0.0.1 ([..])
|
[CHECKING] foo v0.0.1 ([ROOT]/foo)
|
||||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
|
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||||
",
|
|
||||||
)
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,14 +176,13 @@ fn bad_target_spec() {
|
|||||||
|
|
||||||
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 `[..]`
|
|
||||||
|
|
||||||
Caused by:
|
Caused by:
|
||||||
failed to parse `4` as a cfg expression: unexpected character `4` in cfg, [..]
|
failed to parse `4` as a cfg expression: unexpected character `4` in cfg, expected parens, a comma, an identifier, or a string
|
||||||
",
|
|
||||||
)
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,14 +207,13 @@ fn bad_target_spec2() {
|
|||||||
|
|
||||||
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 `[..]`
|
|
||||||
|
|
||||||
Caused by:
|
Caused by:
|
||||||
failed to parse `bar =` as a cfg expression: expected a string, but cfg expression ended
|
failed to parse `bar =` as a cfg expression: expected a string, but cfg expression ended
|
||||||
",
|
|
||||||
)
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -404,95 +397,89 @@ fn bad_cfg_discovery() {
|
|||||||
.env("RUSTC", &funky_rustc)
|
.env("RUSTC", &funky_rustc)
|
||||||
.env("FUNKY_MODE", "bad-version")
|
.env("FUNKY_MODE", "bad-version")
|
||||||
.with_status(101)
|
.with_status(101)
|
||||||
.with_stderr(
|
.with_stderr_data(str![[r#"
|
||||||
"\
|
|
||||||
[ERROR] `rustc -vV` didn't have a line for `host:`, got:
|
[ERROR] `rustc -vV` didn't have a line for `host:`, got:
|
||||||
foo
|
foo
|
||||||
|
|
||||||
",
|
|
||||||
)
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
p.cargo("check")
|
p.cargo("check")
|
||||||
.env("RUSTC", &funky_rustc)
|
.env("RUSTC", &funky_rustc)
|
||||||
.env("FUNKY_MODE", "no-crate-types")
|
.env("FUNKY_MODE", "no-crate-types")
|
||||||
.with_status(101)
|
.with_status(101)
|
||||||
.with_stderr(
|
.with_stderr_data(str![[r#"
|
||||||
"\
|
|
||||||
[ERROR] malformed output when learning about crate-type bin information
|
[ERROR] malformed output when learning about crate-type bin information
|
||||||
command was: `[..]compiler[..] --crate-name ___ [..]`
|
command was: `[ROOT]/compiler/target/debug/compiler[..] --crate-name ___ [..]`
|
||||||
(no output received)
|
(no output received)
|
||||||
",
|
|
||||||
)
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
p.cargo("check")
|
p.cargo("check")
|
||||||
.env("RUSTC", &funky_rustc)
|
.env("RUSTC", &funky_rustc)
|
||||||
.env("FUNKY_MODE", "no-sysroot")
|
.env("FUNKY_MODE", "no-sysroot")
|
||||||
.with_status(101)
|
.with_status(101)
|
||||||
.with_stderr(
|
.with_stderr_data(str![[r#"
|
||||||
"\
|
|
||||||
[ERROR] output of --print=sysroot missing when learning about target-specific information from rustc
|
[ERROR] output of --print=sysroot missing when learning about target-specific information from rustc
|
||||||
command was: `[..]compiler[..]--crate-type [..]`
|
command was: `[ROOT]/compiler/target/debug/compiler[..]--crate-type [..]`
|
||||||
|
|
||||||
--- stdout
|
--- stdout
|
||||||
[..]___[..]
|
___[EXE]
|
||||||
[..]___[..]
|
lib___.rlib
|
||||||
[..]___[..]
|
[..]___.[..]
|
||||||
[..]___[..]
|
[..]___.[..]
|
||||||
[..]___[..]
|
[..]___.[..]
|
||||||
[..]___[..]
|
[..]___.[..]
|
||||||
|
|
||||||
",
|
|
||||||
)
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
p.cargo("check")
|
p.cargo("check")
|
||||||
.env("RUSTC", &funky_rustc)
|
.env("RUSTC", &funky_rustc)
|
||||||
.env("FUNKY_MODE", "no-split-debuginfo")
|
.env("FUNKY_MODE", "no-split-debuginfo")
|
||||||
.with_status(101)
|
.with_status(101)
|
||||||
.with_stderr(
|
.with_stderr_data(str![[r#"
|
||||||
"\
|
|
||||||
[ERROR] output of --print=split-debuginfo missing when learning about target-specific information from rustc
|
[ERROR] output of --print=split-debuginfo missing when learning about target-specific information from rustc
|
||||||
command was: `[..]compiler[..]--crate-type [..]`
|
command was: `[ROOT]/compiler/target/debug/compiler[..]--crate-type [..]`
|
||||||
|
|
||||||
--- stdout
|
--- stdout
|
||||||
[..]___[..]
|
___[EXE]
|
||||||
[..]___[..]
|
lib___.rlib
|
||||||
[..]___[..]
|
[..]___.[..]
|
||||||
[..]___[..]
|
[..]___.[..]
|
||||||
[..]___[..]
|
[..]___.[..]
|
||||||
[..]___[..]
|
[..]___.[..]
|
||||||
[..]
|
[..]rust[..]
|
||||||
|
|
||||||
",
|
|
||||||
)
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
p.cargo("check")
|
p.cargo("check")
|
||||||
.env("RUSTC", &funky_rustc)
|
.env("RUSTC", &funky_rustc)
|
||||||
.env("FUNKY_MODE", "bad-cfg")
|
.env("FUNKY_MODE", "bad-cfg")
|
||||||
.with_status(101)
|
.with_status(101)
|
||||||
.with_stderr(
|
.with_stderr_data(str![[r#"
|
||||||
"\
|
|
||||||
[ERROR] failed to parse the cfg from `rustc --print=cfg`, got:
|
[ERROR] failed to parse the cfg from `rustc --print=cfg`, got:
|
||||||
[..]___[..]
|
___[EXE]
|
||||||
[..]___[..]
|
lib___.rlib
|
||||||
[..]___[..]
|
[..]___.[..]
|
||||||
[..]___[..]
|
[..]___.[..]
|
||||||
[..]___[..]
|
[..]___.[..]
|
||||||
[..]___[..]
|
[..]___.[..]
|
||||||
[..]
|
[..]rust[..]
|
||||||
[..],[..]
|
[..],[..]
|
||||||
___
|
___
|
||||||
123
|
123
|
||||||
|
|
||||||
|
|
||||||
Caused by:
|
Caused by:
|
||||||
failed to parse `123` as a cfg expression: unexpected character `1` in cfg, \
|
failed to parse `123` as a cfg expression: unexpected character `1` in cfg, expected parens, a comma, an identifier, or a string
|
||||||
expected parens, a comma, an identifier, or a string
|
|
||||||
",
|
"#]])
|
||||||
)
|
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -526,6 +513,10 @@ fn exclusive_dep_kinds() {
|
|||||||
p.cargo("check")
|
p.cargo("check")
|
||||||
.with_status(101)
|
.with_status(101)
|
||||||
// can't find crate for `bar`
|
// can't find crate for `bar`
|
||||||
.with_stderr_contains("[..]E0463[..]")
|
.with_stderr_data(str![[r#"
|
||||||
|
[COMPILING] foo v0.1.0 ([ROOT]/foo)
|
||||||
|
error[E0463]: can't find crate for `bar`
|
||||||
|
...
|
||||||
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user