Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nextest-runner] add option hide-progress-bar to configuration file #1348

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion cargo-nextest/src/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,10 @@
if let Some(final_status_level) = self.final_status_level {
builder.set_final_status_level(final_status_level.into());
}
builder.set_hide_progress_bar(self.hide_progress_bar);
match self.hide_progress_bar {
true => builder.set_hide_progress_bar(Some(true)),

Check warning on line 882 in cargo-nextest/src/dispatch.rs

View check run for this annotation

Codecov / codecov/patch

cargo-nextest/src/dispatch.rs#L882

Added line #L882 was not covered by tests
false => builder.set_hide_progress_bar(None),
};
builder
}
}
Expand Down
4 changes: 4 additions & 0 deletions nextest-runner/default-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ success-output = "never"
# to false.
fail-fast = true

# Hide the progress bar when running tests. For CI runs, consider setting this
# to true
hide-progress-bar = false

# Treat a test that takes longer than the configured 'period' as slow, and print a message.
# See <https://nexte.st/book/slow-tests> for more information.
#
Expand Down
13 changes: 13 additions & 0 deletions nextest-runner/src/config/config_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,13 @@ impl<'cfg> NextestProfile<'cfg, FinalConfig> {
.unwrap_or(self.default_profile.fail_fast)
}

/// Returns the hide-progress-bar config for this profile.
pub fn hide_progress_bar(&self) -> bool {
self.custom_profile
.and_then(|profile| profile.hide_progress_bar)
.unwrap_or(self.default_profile.hide_progress_bar)
}

/// Returns the list of setup scripts.
pub fn setup_scripts(&self, test_list: &TestList<'_>) -> SetupScripts<'_> {
SetupScripts::new(self, test_list)
Expand Down Expand Up @@ -880,6 +887,7 @@ pub(super) struct DefaultProfileImpl {
failure_output: TestOutputDisplay,
success_output: TestOutputDisplay,
fail_fast: bool,
hide_progress_bar: bool,
slow_timeout: SlowTimeout,
leak_timeout: Duration,
overrides: Vec<DeserializedOverride>,
Expand Down Expand Up @@ -910,6 +918,9 @@ impl DefaultProfileImpl {
.success_output
.expect("success-output present in default profile"),
fail_fast: p.fail_fast.expect("fail-fast present in default profile"),
hide_progress_bar: p
.hide_progress_bar
.expect("hide-progress-bar present in default profile"),
slow_timeout: p
.slow_timeout
.expect("slow-timeout present in default profile"),
Expand Down Expand Up @@ -972,6 +983,8 @@ pub(super) struct CustomProfileImpl {
success_output: Option<TestOutputDisplay>,
#[serde(default)]
fail_fast: Option<bool>,
#[serde(default)]
hide_progress_bar: Option<bool>,
#[serde(default, deserialize_with = "super::deserialize_slow_timeout")]
slow_timeout: Option<SlowTimeout>,
#[serde(default, with = "humantime_serde::option")]
Expand Down
13 changes: 7 additions & 6 deletions nextest-runner/src/reporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,8 @@
success_output: Option<TestOutputDisplay>,
status_level: Option<StatusLevel>,
final_status_level: Option<FinalStatusLevel>,

verbose: bool,
hide_progress_bar: bool,
hide_progress_bar: Option<bool>,
}

impl TestReporterBuilder {
Expand Down Expand Up @@ -215,7 +214,7 @@

/// Sets visibility of the progress bar.
/// The progress bar is also hidden if `no_capture` is set.
pub fn set_hide_progress_bar(&mut self, hide_progress_bar: bool) -> &mut Self {
pub fn set_hide_progress_bar(&mut self, hide_progress_bar: Option<bool>) -> &mut Self {
self.hide_progress_bar = hide_progress_bar;
self
}
Expand Down Expand Up @@ -250,6 +249,10 @@
.final_status_level
.unwrap_or_else(|| profile.final_status_level());

let hide_progress_bar = self
.hide_progress_bar
.unwrap_or_else(|| profile.hide_progress_bar());

// failure_output and success_output are meaningless if the runner isn't capturing any
// output.
let force_success_output = match self.no_capture {
Expand Down Expand Up @@ -278,9 +281,7 @@
// in these environments.
ReporterStderrImpl::TerminalWithoutBar
}
ReporterStderr::Terminal if self.hide_progress_bar => {
ReporterStderrImpl::TerminalWithoutBar
}
ReporterStderr::Terminal if hide_progress_bar => ReporterStderrImpl::TerminalWithoutBar,

Check warning on line 284 in nextest-runner/src/reporter.rs

View check run for this annotation

Codecov / codecov/patch

nextest-runner/src/reporter.rs#L284

Added line #L284 was not covered by tests

ReporterStderr::Terminal => {
let progress_bar = ProgressBar::new(test_list.test_count() as u64);
Expand Down