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

Allow pretty prints in CI #1090

Merged
merged 1 commit into from
Dec 12, 2024
Merged
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
28 changes: 16 additions & 12 deletions src/reporter/ui/human.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
pb.finish_and_clear(); // Hide the spinner on startup
pb
}

fn println(&self, message: impl Display) {
self.pb.suspend(|| println!("{message}"))
}

Check warning on line 52 in src/reporter/ui/human.rs

View check run for this annotation

Codecov / codecov/patch

src/reporter/ui/human.rs#L50-L52

Added lines #L50 - L52 were not covered by tests
}

impl EventHandler for HumanProgressHandler {
Expand All @@ -56,18 +60,18 @@
match event.message() {
Message::Meta(it) => {
let message = it.format_human();
self.pb.println(message);
self.println(message);

Check warning on line 63 in src/reporter/ui/human.rs

View check run for this annotation

Codecov / codecov/patch

src/reporter/ui/human.rs#L63

Added line #L63 was not covered by tests
}
Message::SubcommandInit(it) if it.should_enable_spinner() => {
self.pb.reset(); // We'll reset here to ensure the steady tick call below works
self.pb.enable_steady_tick(Duration::from_millis(150));
}
Message::UnableToConfirmValidReleaseVersion(_) => {
let message = Status::info("Unable to verify if provided version is an existing Rust release version");
self.pb.println(message);
self.println(message);

Check warning on line 71 in src/reporter/ui/human.rs

View check run for this annotation

Codecov / codecov/patch

src/reporter/ui/human.rs#L71

Added line #L71 was not covered by tests
}
Message::CheckToolchain(it) if event.is_scope_start() => {
self.pb.println(it.header(self.sequence_number.load(Ordering::SeqCst)));
self.println(it.header(self.sequence_number.load(Ordering::SeqCst)));

Check warning on line 74 in src/reporter/ui/human.rs

View check run for this annotation

Codecov / codecov/patch

src/reporter/ui/human.rs#L74

Added line #L74 was not covered by tests
self.start_runner_progress(it.toolchain.version());
}
Message::CheckToolchain(_it) /* is scope end */ => {
Expand All @@ -76,22 +80,22 @@
// Message::Compatibility(CheckResult { compatibility_report: CompatibilityReport::Compatible, toolchain, .. }) => {
Message::CheckResult(CheckResult { compatibility }) if compatibility.is_compatible() => {
let message = Status::ok("Is compatible");
self.pb.println(message);
self.println(message);

Check warning on line 83 in src/reporter/ui/human.rs

View check run for this annotation

Codecov / codecov/patch

src/reporter/ui/human.rs#L83

Added line #L83 was not covered by tests
}
Message::CheckResult(CheckResult { compatibility }) if !compatibility.is_compatible() => {
let message = Status::fail("Is incompatible");
self.pb.println(message);
self.println(message);

Check warning on line 87 in src/reporter/ui/human.rs

View check run for this annotation

Codecov / codecov/patch

src/reporter/ui/human.rs#L87

Added line #L87 was not covered by tests

if let Some(error_report) = compatibility.error() {
self.pb.println(message_box(error_report));
self.println(message_box(error_report));

Check warning on line 90 in src/reporter/ui/human.rs

View check run for this annotation

Codecov / codecov/patch

src/reporter/ui/human.rs#L90

Added line #L90 was not covered by tests
}
}
Message::SubcommandResult(result) => self.handle_subcommand_result(result),
Message::TerminateWithFailure(termination) if termination.should_highlight() => {
self.pb.println(format!("\n\n{}", termination.as_message().red()));
self.println(format!("\n\n{}", termination.as_message().red()));

Check warning on line 95 in src/reporter/ui/human.rs

View check run for this annotation

Codecov / codecov/patch

src/reporter/ui/human.rs#L95

Added line #L95 was not covered by tests
}
Message::TerminateWithFailure(termination) if !termination.should_highlight() => {
self.pb.println(format!("\n\n{}", termination.as_message().dimmed().bold()));
self.println(format!("\n\n{}", termination.as_message().dimmed().bold()));

Check warning on line 98 in src/reporter/ui/human.rs

View check run for this annotation

Codecov / codecov/patch

src/reporter/ui/human.rs#L98

Added line #L98 was not covered by tests
}
_ => {}
};
Expand All @@ -102,24 +106,24 @@
fn handle_subcommand_result(&self, result: &SubcommandResult) {
match result {
SubcommandResult::Find(inner) => {
self.pb.println(format!("\n{}\n", inner.summary()));
self.println(format!("\n{}\n", inner.summary()));

Check warning on line 109 in src/reporter/ui/human.rs

View check run for this annotation

Codecov / codecov/patch

src/reporter/ui/human.rs#L109

Added line #L109 was not covered by tests
}
SubcommandResult::List(inner) => {
self.pb.println(inner.to_string());
self.println(inner);

Check warning on line 112 in src/reporter/ui/human.rs

View check run for this annotation

Codecov / codecov/patch

src/reporter/ui/human.rs#L112

Added line #L112 was not covered by tests
}
SubcommandResult::Set(inner) => {
let message = Status::with_lead(
"Set".bright_green(),
format_args!("Rust {}", inner.version()),
);
self.pb.println(message);
self.println(message);

Check warning on line 119 in src/reporter/ui/human.rs

View check run for this annotation

Codecov / codecov/patch

src/reporter/ui/human.rs#L119

Added line #L119 was not covered by tests
}
SubcommandResult::Show(inner) => {
let message = Status::with_lead(
"Show".bright_green(),
format_args!("MSRV is Rust {}", inner.version()),
);
self.pb.println(message);
self.println(message);

Check warning on line 126 in src/reporter/ui/human.rs

View check run for this annotation

Codecov / codecov/patch

src/reporter/ui/human.rs#L126

Added line #L126 was not covered by tests
}
SubcommandResult::Verify(_inner) => {
// tbd.
Expand Down
Loading