Skip to content

Commit d0c58e2

Browse files
committed
test: migrate progress to snapbox
1 parent 98b33ed commit d0c58e2

File tree

1 file changed

+28
-21
lines changed

1 file changed

+28
-21
lines changed

tests/testsuite/progress.rs

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
//! Tests for progress bar.
22
3-
#![allow(deprecated)]
4-
3+
use cargo_test_support::prelude::*;
54
use cargo_test_support::project;
65
use cargo_test_support::registry::Package;
6+
use cargo_test_support::str;
77

88
#[cargo_test]
99
fn bad_progress_config_unknown_when() {
@@ -20,15 +20,13 @@ fn bad_progress_config_unknown_when() {
2020

2121
p.cargo("check")
2222
.with_status(101)
23-
.with_stderr(
24-
"\
25-
[ERROR] error in [..].cargo/config.toml: \
26-
could not load config key `term.progress.when`
23+
.with_stderr_data(str![[r#"
24+
[ERROR] error in [ROOT]/foo/.cargo/config.toml: could not load config key `term.progress.when`
2725
2826
Caused by:
2927
unknown variant `unknown`, expected one of `auto`, `never`, `always`
30-
",
31-
)
28+
29+
"#]])
3230
.run();
3331
}
3432

@@ -47,11 +45,10 @@ fn bad_progress_config_missing_width() {
4745

4846
p.cargo("check")
4947
.with_status(101)
50-
.with_stderr(
51-
"\
52-
[ERROR] \"always\" progress requires a `width` key
53-
",
54-
)
48+
.with_stderr_data(str![[r#"
49+
[ERROR] "always" progress requires a `width` key
50+
51+
"#]])
5552
.run();
5653
}
5754

@@ -70,14 +67,13 @@ fn bad_progress_config_missing_when() {
7067

7168
p.cargo("check")
7269
.with_status(101)
73-
.with_stderr(
74-
"\
75-
error: error in [..]: could not load config key `term.progress`
70+
.with_stderr_data(str![[r#"
71+
[ERROR] error in [ROOT]/foo/.cargo/config.toml: could not load config key `term.progress`
7672
7773
Caused by:
7874
missing field `when`
79-
",
80-
)
75+
76+
"#]])
8177
.run();
8278
}
8379

@@ -116,12 +112,23 @@ fn always_shows_progress() {
116112
.build();
117113

118114
p.cargo("check")
119-
.with_stderr_contains("[DOWNLOADING] [..] crates [..]")
120-
.with_stderr_contains("[..][DOWNLOADED] 3 crates ([..]) in [..]")
121-
.with_stderr_contains("[BUILDING] [..] [..]/4: [..]")
115+
.with_stderr_data(
116+
str![[r#"
117+
[DOWNLOADING] 1 crate
118+
[DOWNLOADING] 2 crates
119+
[DOWNLOADING] 3 crates
120+
[DOWNLOADED] 3 crates ([..]KB) in [..]s
121+
[BUILDING] [..] 0/4: [..]
122+
[BUILDING] [..] 3/4: foo
123+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
124+
...
125+
"#]]
126+
.unordered(),
127+
)
122128
.run();
123129
}
124130

131+
#[allow(deprecated)]
125132
#[cargo_test]
126133
fn never_progress() {
127134
const N: usize = 3;

0 commit comments

Comments
 (0)