test: migrate cargo_target to snapbox

This commit is contained in:
heisen-li 2024-06-26 12:22:54 +08:00
parent 8c6c8a164e
commit 0708802a71

View file

@ -1,8 +1,7 @@
//! Tests specifically related to target handling (lib, bins, examples, tests, benches).
#![allow(deprecated)]
use cargo_test_support::project;
use cargo_test_support::str;
#[cargo_test]
fn warn_unmatched_target_filters() {
@ -24,13 +23,11 @@ fn warn_unmatched_target_filters() {
.build();
p.cargo("check --tests --bins --examples --benches")
.with_stderr(
"\
[WARNING] target filters `bins`, `tests`, `examples`, `benches` specified, \
but no targets matched; this is a no-op
[FINISHED][..]
",
)
.with_stderr_data(str![[r#"
[WARNING] target filters `bins`, `tests`, `examples`, `benches` specified, but no targets matched; this is a no-op
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
"#]])
.run();
}
@ -55,18 +52,20 @@ fn reserved_windows_target_name() {
if cfg!(windows) {
p.cargo("check")
.with_stderr(
"\
[WARNING] binary target `con` is a reserved Windows filename, \
this target will not work on Windows platforms
[CHECKING] foo[..]
[FINISHED][..]
",
)
.with_stderr_data(str![[r#"
[WARNING] binary target `con` is a reserved Windows filename, this target will not work on Windows platforms
[CHECKING] foo v0.1.0 ([ROOT]/foo)
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
"#]])
.run();
} else {
p.cargo("check")
.with_stderr("[CHECKING] foo[..]\n[FINISHED][..]")
.with_stderr_data(str![[r#"
[CHECKING] foo v0.1.0 ([ROOT]/foo)
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
"#]])
.run();
}
}