11//! Tests for progress bar.
22
3- #![ allow( deprecated) ]
4-
3+ use cargo_test_support:: prelude:: * ;
54use cargo_test_support:: project;
65use cargo_test_support:: registry:: Package ;
6+ use cargo_test_support:: str;
77
88#[ cargo_test]
99fn 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
2826Caused 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
7773Caused by:
7874 missing field `when`
79- " ,
80- )
75+
76+ "# ] ] )
8177 . run ( ) ;
8278}
8379
@@ -116,9 +112,19 @@ 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
@@ -156,9 +162,28 @@ fn never_progress() {
156162 . file ( "src/lib.rs" , "" )
157163 . build ( ) ;
158164
165+ // should not contain
166+ // [DOWNLOADING] [..] crates [..]
167+ // [..][DOWNLOADED] 3 crates ([..]) in [..]
168+ // [BUILDING] [..] [..]/4: [..]
159169 p. cargo ( "check" )
160- . with_stderr_does_not_contain ( "[DOWNLOADING] [..] crates [..]" )
161- . with_stderr_does_not_contain ( "[..][DOWNLOADED] 3 crates ([..]) in [..]" )
162- . with_stderr_does_not_contain ( "[BUILDING] [..] [..]/4: [..]" )
170+ . with_stderr_data (
171+ str![ [ r#"
172+ [WARNING] no edition set: defaulting to the 2015 edition while the latest is 2021
173+ [UPDATING] `dummy-registry` index
174+ [LOCKING] 4 packages to latest compatible versions
175+ [DOWNLOADING] crates ...
176+ [DOWNLOADED] dep3 v1.0.0 (registry `dummy-registry`)
177+ [DOWNLOADED] dep2 v1.0.0 (registry `dummy-registry`)
178+ [DOWNLOADED] dep1 v1.0.0 (registry `dummy-registry`)
179+ [CHECKING] dep3 v1.0.0
180+ [CHECKING] dep2 v1.0.0
181+ [CHECKING] dep1 v1.0.0
182+ [CHECKING] foo v0.1.0 ([ROOT]/foo)
183+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
184+
185+ "# ] ]
186+ . unordered ( ) ,
187+ )
163188 . run ( ) ;
164189}
0 commit comments