Skip to content

Commit 0dea3cd

Browse files
authored
Allow term.progress.when to default (#15287)
### What does this PR try to resolve? The config section `term.progress` contains a collection of options (currently only `when` and `width`). If only `width` is set, Cargo fails with the error: "missing field `when`." This behavior may be surprising and inconvenient for users who want to set the `CARGO_TERM_PROGRESS_WIDTH` environment variable. ### How should we test and review this PR? The relevant test, `bad_progress_config_missing_when`, has been replaced with `default_progress_is_auto`. #14615 From #14615 (comment) > I don't recall any particular decisions made regarding bad_progress_config_missing_when. I personally would not object to changing that to allow it to pass. I can't think of a reason it would be required to specify when with width.
2 parents 4a8fd9b + 59b11a7 commit 0dea3cd

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

src/cargo/util/context/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2830,6 +2830,7 @@ pub struct TermConfig {
28302830
#[derive(Debug, Default, Deserialize)]
28312831
#[serde(rename_all = "kebab-case")]
28322832
pub struct ProgressConfig {
2833+
#[serde(default)]
28332834
pub when: ProgressWhen,
28342835
pub width: Option<usize>,
28352836
}

tests/testsuite/progress.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ fn bad_progress_config_missing_width() {
5353
}
5454

5555
#[cargo_test]
56-
fn bad_progress_config_missing_when() {
56+
fn default_progress_is_auto() {
5757
let p = project()
5858
.file(
5959
".cargo/config.toml",
@@ -65,16 +65,7 @@ fn bad_progress_config_missing_when() {
6565
.file("src/lib.rs", "")
6666
.build();
6767

68-
p.cargo("check")
69-
.with_status(101)
70-
.with_stderr_data(str![[r#"
71-
[ERROR] error in [ROOT]/foo/.cargo/config.toml: could not load config key `term.progress`
72-
73-
Caused by:
74-
missing field `when`
75-
76-
"#]])
77-
.run();
68+
p.cargo("check").run();
7869
}
7970

8071
#[cargo_test]

0 commit comments

Comments
 (0)