mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 07:41:12 +00:00
Merge pull request #6549 from hristog/newline-when-tests-failed
Add a newline when reporting test failures
This commit is contained in:
commit
09e8131667
6 changed files with 13 additions and 45 deletions
|
@ -531,7 +531,7 @@ pub fn test(matches: &ArgMatches, triple: Triple) -> io::Result<i32> {
|
|||
"if there were errors, we would have already exited."
|
||||
);
|
||||
if problems.warnings > 0 {
|
||||
problems.print_to_stdout(start_time.elapsed());
|
||||
problems.print_error_warning_count(start_time.elapsed());
|
||||
println!(".\n\nRunning tests…\n\n\x1B[36m{}\x1B[39m", "─".repeat(80));
|
||||
}
|
||||
}
|
||||
|
@ -824,7 +824,7 @@ pub fn build(
|
|||
// since the process is about to exit anyway.
|
||||
// std::mem::forget(arena);
|
||||
|
||||
problems.print_to_stdout(total_time);
|
||||
problems.print_error_warning_count(total_time);
|
||||
println!(" while successfully building:\n\n {generated_filename}");
|
||||
|
||||
// Return a nonzero exit code if there were problems
|
||||
|
@ -832,7 +832,7 @@ pub fn build(
|
|||
}
|
||||
BuildAndRun => {
|
||||
if problems.fatally_errored {
|
||||
problems.print_to_stdout(total_time);
|
||||
problems.print_error_warning_count(total_time);
|
||||
println!(
|
||||
".\n\nCannot run program due to fatal error…\n\n\x1B[36m{}\x1B[39m",
|
||||
"─".repeat(80)
|
||||
|
@ -842,7 +842,7 @@ pub fn build(
|
|||
return Ok(problems.exit_code());
|
||||
}
|
||||
if problems.errors > 0 || problems.warnings > 0 {
|
||||
problems.print_to_stdout(total_time);
|
||||
problems.print_error_warning_count(total_time);
|
||||
println!(
|
||||
".\n\nRunning program anyway…\n\n\x1B[36m{}\x1B[39m",
|
||||
"─".repeat(80)
|
||||
|
@ -862,7 +862,7 @@ pub fn build(
|
|||
}
|
||||
BuildAndRunIfNoErrors => {
|
||||
if problems.fatally_errored {
|
||||
problems.print_to_stdout(total_time);
|
||||
problems.print_error_warning_count(total_time);
|
||||
println!(
|
||||
".\n\nCannot run program due to fatal error…\n\n\x1B[36m{}\x1B[39m",
|
||||
"─".repeat(80)
|
||||
|
@ -877,7 +877,7 @@ pub fn build(
|
|||
);
|
||||
|
||||
if problems.warnings > 0 {
|
||||
problems.print_to_stdout(total_time);
|
||||
problems.print_error_warning_count(total_time);
|
||||
println!(
|
||||
".\n\nRunning program…\n\n\x1B[36m{}\x1B[39m",
|
||||
"─".repeat(80)
|
||||
|
|
|
@ -210,7 +210,7 @@ fn main() -> io::Result<()> {
|
|||
threading,
|
||||
) {
|
||||
Ok((problems, total_time)) => {
|
||||
problems.print_to_stdout(total_time);
|
||||
problems.print_error_warning_count(total_time);
|
||||
Ok(problems.exit_code())
|
||||
}
|
||||
|
||||
|
|
|
@ -649,7 +649,7 @@ pub fn handle_error_module(
|
|||
|
||||
let problems = report_problems_typechecked(&mut module);
|
||||
|
||||
problems.print_to_stdout(total_time);
|
||||
problems.print_error_warning_count(total_time);
|
||||
|
||||
if print_run_anyway_hint {
|
||||
// If you're running "main.roc" then you can just do `roc run`
|
||||
|
|
|
@ -1901,7 +1901,7 @@ fn load_multi_threaded<'a>(
|
|||
// &mut can_problems_recorded,
|
||||
// &mut type_problems_recorded,
|
||||
// )
|
||||
// .print_to_stdout(Duration::default()); // TODO determine total elapsed time and use it here
|
||||
// .print_error_warning_count(Duration::default()); // TODO determine total elapsed time and use it here
|
||||
|
||||
Err(LoadingProblem::FormattedReport(
|
||||
concat!(
|
||||
|
|
|
@ -123,7 +123,7 @@ pub fn generate(
|
|||
"if there are errors, they should have been returned as an error variant"
|
||||
);
|
||||
if problems.warnings > 0 {
|
||||
problems.print_to_stdout(total_time);
|
||||
problems.print_error_warning_count(total_time);
|
||||
println!(
|
||||
".\n\nRunning glue despite warnings…\n\n\x1B[36m{}\x1B[39m",
|
||||
"─".repeat(80)
|
||||
|
|
|
@ -27,11 +27,12 @@ impl Problems {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn print_to_stdout(&self, total_time: std::time::Duration) {
|
||||
// prints e.g. `1 error and 0 warnings found in 63 ms.`
|
||||
pub fn print_error_warning_count(&self, total_time: std::time::Duration) {
|
||||
const GREEN: &str = ANSI_STYLE_CODES.green;
|
||||
const YELLOW: &str = ANSI_STYLE_CODES.yellow;
|
||||
|
||||
print!(
|
||||
println!(
|
||||
"{}{}\x1B[39m {} and {}{}\x1B[39m {} found in {} ms",
|
||||
match self.errors {
|
||||
0 => GREEN,
|
||||
|
@ -56,39 +57,6 @@ impl Problems {
|
|||
}
|
||||
}
|
||||
|
||||
// prints e.g. `1 error and 0 warnings found in 63 ms.`
|
||||
pub fn print_error_warning_count(
|
||||
error_count: usize,
|
||||
warning_count: usize,
|
||||
total_time: std::time::Duration,
|
||||
) {
|
||||
const GREEN: &str = ANSI_STYLE_CODES.green;
|
||||
const YELLOW: &str = ANSI_STYLE_CODES.yellow;
|
||||
|
||||
print!(
|
||||
"{}{}\x1B[39m {} and {}{}\x1B[39m {} found in {} ms",
|
||||
match error_count {
|
||||
0 => GREEN,
|
||||
_ => YELLOW,
|
||||
},
|
||||
error_count,
|
||||
match error_count {
|
||||
1 => "error",
|
||||
_ => "errors",
|
||||
},
|
||||
match warning_count {
|
||||
0 => GREEN,
|
||||
_ => YELLOW,
|
||||
},
|
||||
warning_count,
|
||||
match warning_count {
|
||||
1 => "warning",
|
||||
_ => "warnings",
|
||||
},
|
||||
total_time.as_millis()
|
||||
);
|
||||
}
|
||||
|
||||
pub fn report_problems(
|
||||
sources: &MutMap<ModuleId, (PathBuf, Box<str>)>,
|
||||
interns: &Interns,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue