Skip to content

Commit

Permalink
test: migrate progress to snapbox
Browse files Browse the repository at this point in the history
  • Loading branch information
eth3lbert committed Jul 3, 2024
1 parent 165df2b commit 2ea54b6
Showing 1 changed file with 49 additions and 24 deletions.
73 changes: 49 additions & 24 deletions tests/testsuite/progress.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//! Tests for progress bar.
#![allow(deprecated)]

use cargo_test_support::prelude::*;
use cargo_test_support::project;
use cargo_test_support::registry::Package;
use cargo_test_support::str;

#[cargo_test]
fn bad_progress_config_unknown_when() {
Expand All @@ -20,15 +20,13 @@ fn bad_progress_config_unknown_when() {

p.cargo("check")
.with_status(101)
.with_stderr(
"\
[ERROR] error in [..].cargo/config.toml: \
could not load config key `term.progress.when`
.with_stderr_data(str![[r#"
[ERROR] error in [ROOT]/foo/.cargo/config.toml: could not load config key `term.progress.when`
Caused by:
unknown variant `unknown`, expected one of `auto`, `never`, `always`
",
)
"#]])
.run();
}

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

p.cargo("check")
.with_status(101)
.with_stderr(
"\
[ERROR] \"always\" progress requires a `width` key
",
)
.with_stderr_data(str![[r#"
[ERROR] "always" progress requires a `width` key
"#]])
.run();
}

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

p.cargo("check")
.with_status(101)
.with_stderr(
"\
error: error in [..]: could not load config key `term.progress`
.with_stderr_data(str![[r#"
[ERROR] error in [ROOT]/foo/.cargo/config.toml: could not load config key `term.progress`
Caused by:
missing field `when`
",
)
"#]])
.run();
}

Expand Down Expand Up @@ -116,9 +112,19 @@ fn always_shows_progress() {
.build();

p.cargo("check")
.with_stderr_contains("[DOWNLOADING] [..] crates [..]")
.with_stderr_contains("[..][DOWNLOADED] 3 crates ([..]) in [..]")
.with_stderr_contains("[BUILDING] [..] [..]/4: [..]")
.with_stderr_data(
str![[r#"
[DOWNLOADING] 1 crate
[DOWNLOADING] 2 crates
[DOWNLOADING] 3 crates
[DOWNLOADED] 3 crates ([..]KB) in [..]s
[BUILDING] [..] 0/4: [..]
[BUILDING] [..] 3/4: foo
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
...
"#]]
.unordered(),
)
.run();
}

Expand Down Expand Up @@ -156,9 +162,28 @@ fn never_progress() {
.file("src/lib.rs", "")
.build();

// should not contain
// [DOWNLOADING] [..] crates [..]
// [..][DOWNLOADED] 3 crates ([..]) in [..]
// [BUILDING] [..] [..]/4: [..]
p.cargo("check")
.with_stderr_does_not_contain("[DOWNLOADING] [..] crates [..]")
.with_stderr_does_not_contain("[..][DOWNLOADED] 3 crates ([..]) in [..]")
.with_stderr_does_not_contain("[BUILDING] [..] [..]/4: [..]")
.with_stderr_data(
str![[r#"
[WARNING] no edition set: defaulting to the 2015 edition while the latest is 2021
[UPDATING] `dummy-registry` index
[LOCKING] 4 packages to latest compatible versions
[DOWNLOADING] crates ...
[DOWNLOADED] dep3 v1.0.0 (registry `dummy-registry`)
[DOWNLOADED] dep2 v1.0.0 (registry `dummy-registry`)
[DOWNLOADED] dep1 v1.0.0 (registry `dummy-registry`)
[CHECKING] dep3 v1.0.0
[CHECKING] dep2 v1.0.0
[CHECKING] dep1 v1.0.0
[CHECKING] foo v0.1.0 ([ROOT]/foo)
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
"#]]
.unordered(),
)
.run();
}

0 comments on commit 2ea54b6

Please sign in to comment.