Skip to content

Commit d70bc81

Browse files
committed
test: migrate cfg to snapbox
1 parent bff8a08 commit d70bc81

File tree

1 file changed

+77
-86
lines changed

1 file changed

+77
-86
lines changed

tests/testsuite/cfg.rs

+77-86
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
//! Tests for cfg() expressions.
22
3-
#![allow(deprecated)]
4-
53
use cargo_test_support::registry::Package;
64
use cargo_test_support::rustc_host;
7-
use cargo_test_support::{basic_manifest, project};
5+
use cargo_test_support::{basic_manifest, project, str};
86

97
#[cargo_test]
108
fn cfg_easy() {
@@ -56,13 +54,12 @@ fn dont_include() {
5654
.file("b/src/lib.rs", "")
5755
.build();
5856
p.cargo("check")
59-
.with_stderr(
60-
"\
57+
.with_stderr_data(str![[r#"
6158
[LOCKING] 2 packages to latest compatible versions
62-
[CHECKING] a v0.0.1 ([..])
63-
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
64-
",
65-
)
59+
[CHECKING] a v0.0.1 ([ROOT]/foo)
60+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
61+
62+
"#]])
6663
.run();
6764
}
6865

@@ -95,19 +92,18 @@ fn works_through_the_registry() {
9592
.build();
9693

9794
p.cargo("check")
98-
.with_stderr(
99-
"\
100-
[UPDATING] [..] index
95+
.with_stderr_data(str![[r#"
96+
[UPDATING] `dummy-registry` index
10197
[LOCKING] 3 packages to latest compatible versions
10298
[DOWNLOADING] crates ...
103-
[DOWNLOADED] [..]
104-
[DOWNLOADED] [..]
99+
[DOWNLOADED] baz v0.1.0 (registry `dummy-registry`)
100+
[DOWNLOADED] bar v0.1.0 (registry `dummy-registry`)
105101
[CHECKING] baz v0.1.0
106102
[CHECKING] bar v0.1.0
107-
[CHECKING] foo v0.0.1 ([..])
108-
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
109-
",
110-
)
103+
[CHECKING] foo v0.0.1 ([ROOT]/foo)
104+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
105+
106+
"#]])
111107
.run();
112108
}
113109

@@ -145,18 +141,17 @@ fn ignore_version_from_other_platform() {
145141
.build();
146142

147143
p.cargo("check")
148-
.with_stderr(
149-
"\
150-
[UPDATING] [..] index
144+
.with_stderr_data(str![[r#"
145+
[UPDATING] `dummy-registry` index
151146
[LOCKING] 3 packages to latest compatible versions
152147
[ADDING] bar v0.1.0 (latest: v0.2.0)
153148
[DOWNLOADING] crates ...
154-
[DOWNLOADED] [..]
149+
[DOWNLOADED] bar v0.1.0 (registry `dummy-registry`)
155150
[CHECKING] bar v0.1.0
156-
[CHECKING] foo v0.0.1 ([..])
157-
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
158-
",
159-
)
151+
[CHECKING] foo v0.0.1 ([ROOT]/foo)
152+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
153+
154+
"#]])
160155
.run();
161156
}
162157

@@ -181,14 +176,13 @@ fn bad_target_spec() {
181176

182177
p.cargo("check")
183178
.with_status(101)
184-
.with_stderr(
185-
"\
186-
[ERROR] failed to parse manifest at `[..]`
179+
.with_stderr_data(str![[r#"
180+
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
187181
188182
Caused by:
189-
failed to parse `4` as a cfg expression: unexpected character `4` in cfg, [..]
190-
",
191-
)
183+
failed to parse `4` as a cfg expression: unexpected character `4` in cfg, expected parens, a comma, an identifier, or a string
184+
185+
"#]])
192186
.run();
193187
}
194188

@@ -213,14 +207,13 @@ fn bad_target_spec2() {
213207

214208
p.cargo("check")
215209
.with_status(101)
216-
.with_stderr(
217-
"\
218-
[ERROR] failed to parse manifest at `[..]`
210+
.with_stderr_data(str![[r#"
211+
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
219212
220213
Caused by:
221214
failed to parse `bar =` as a cfg expression: expected a string, but cfg expression ended
222-
",
223-
)
215+
216+
"#]])
224217
.run();
225218
}
226219

@@ -404,95 +397,89 @@ fn bad_cfg_discovery() {
404397
.env("RUSTC", &funky_rustc)
405398
.env("FUNKY_MODE", "bad-version")
406399
.with_status(101)
407-
.with_stderr(
408-
"\
400+
.with_stderr_data(str![[r#"
409401
[ERROR] `rustc -vV` didn't have a line for `host:`, got:
410402
foo
411403
412-
",
413-
)
404+
405+
"#]])
414406
.run();
415407

416408
p.cargo("check")
417409
.env("RUSTC", &funky_rustc)
418410
.env("FUNKY_MODE", "no-crate-types")
419411
.with_status(101)
420-
.with_stderr(
421-
"\
412+
.with_stderr_data(str![[r#"
422413
[ERROR] malformed output when learning about crate-type bin information
423-
command was: `[..]compiler[..] --crate-name ___ [..]`
414+
command was: `[ROOT]/compiler/target/debug/compiler[..] --crate-name ___ [..]`
424415
(no output received)
425-
",
426-
)
416+
417+
"#]])
427418
.run();
428419

429420
p.cargo("check")
430421
.env("RUSTC", &funky_rustc)
431422
.env("FUNKY_MODE", "no-sysroot")
432423
.with_status(101)
433-
.with_stderr(
434-
"\
424+
.with_stderr_data(str![[r#"
435425
[ERROR] output of --print=sysroot missing when learning about target-specific information from rustc
436-
command was: `[..]compiler[..]--crate-type [..]`
426+
command was: `[ROOT]/compiler/target/debug/compiler[..]--crate-type [..]`
437427
438428
--- stdout
439-
[..]___[..]
440-
[..]___[..]
441-
[..]___[..]
442-
[..]___[..]
443-
[..]___[..]
444-
[..]___[..]
445-
446-
",
447-
)
429+
___[EXE]
430+
lib___.rlib
431+
[..]___.[..]
432+
[..]___.[..]
433+
[..]___.[..]
434+
[..]___.[..]
435+
436+
437+
"#]])
448438
.run();
449439

450440
p.cargo("check")
451441
.env("RUSTC", &funky_rustc)
452442
.env("FUNKY_MODE", "no-split-debuginfo")
453443
.with_status(101)
454-
.with_stderr(
455-
"\
444+
.with_stderr_data(str![[r#"
456445
[ERROR] output of --print=split-debuginfo missing when learning about target-specific information from rustc
457-
command was: `[..]compiler[..]--crate-type [..]`
446+
command was: `[ROOT]/compiler/target/debug/compiler[..]--crate-type [..]`
458447
459448
--- stdout
460-
[..]___[..]
461-
[..]___[..]
462-
[..]___[..]
463-
[..]___[..]
464-
[..]___[..]
465-
[..]___[..]
466-
[..]
467-
468-
",
469-
)
449+
___[EXE]
450+
lib___.rlib
451+
[..]___.[..]
452+
[..]___.[..]
453+
[..]___.[..]
454+
[..]___.[..]
455+
[..]rust[..]
456+
457+
458+
"#]])
470459
.run();
471460

472461
p.cargo("check")
473462
.env("RUSTC", &funky_rustc)
474463
.env("FUNKY_MODE", "bad-cfg")
475464
.with_status(101)
476-
.with_stderr(
477-
"\
465+
.with_stderr_data(str![[r#"
478466
[ERROR] failed to parse the cfg from `rustc --print=cfg`, got:
479-
[..]___[..]
480-
[..]___[..]
481-
[..]___[..]
482-
[..]___[..]
483-
[..]___[..]
484-
[..]___[..]
485-
[..]
486-
[..],[..]
467+
___
468+
lib___.rlib
469+
[..]___.[..]
470+
[..]___.[..]
471+
[..]___.[..]
472+
[..]___.[..]
473+
[..]rust[..]
474+
off,packed,unpacked,
487475
___
488476
123
489477
490478
491479
Caused by:
492-
failed to parse `123` as a cfg expression: unexpected character `1` in cfg, \
493-
expected parens, a comma, an identifier, or a string
494-
",
495-
)
480+
failed to parse `123` as a cfg expression: unexpected character `1` in cfg, expected parens, a comma, an identifier, or a string
481+
482+
"#]])
496483
.run();
497484
}
498485

@@ -526,6 +513,10 @@ fn exclusive_dep_kinds() {
526513
p.cargo("check")
527514
.with_status(101)
528515
// can't find crate for `bar`
529-
.with_stderr_contains("[..]E0463[..]")
516+
.with_stderr_data(str![[r#"
517+
[COMPILING] foo v0.1.0 ([ROOT]/foo)
518+
error[E0463]: can't find crate for `bar`
519+
...
520+
"#]])
530521
.run();
531522
}

0 commit comments

Comments
 (0)