[red-knot] Use colors to improve readability of mdtest output (#13725)

This commit is contained in:
Alex Waygood 2024-10-13 14:20:35 +01:00 committed by GitHub
parent 46bc69d1d4
commit defdc4dd8e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 21 additions and 9 deletions

View file

@ -1,3 +1,4 @@
use colored::Colorize;
use parser as test_parser;
use red_knot_python_semantic::types::check_types;
use ruff_db::files::system_path_to_file;
@ -31,13 +32,14 @@ pub fn run(path: &PathBuf, title: &str) {
for test in suite.tests() {
if let Err(failures) = run_test(&test) {
any_failures = true;
println!("{}", test.name());
println!("\n{}\n", test.name().bold().underline());
for (path, by_line) in failures {
println!(" {path}");
for (line, failures) in by_line.iter() {
println!("{}", path.as_str().bold());
for (line_number, failures) in by_line.iter() {
for failure in failures {
println!(" line {line}: {failure}");
let line_info = format!("line {line_number}:").cyan();
println!(" {line_info} {failure}");
}
}
println!();
@ -45,6 +47,8 @@ pub fn run(path: &PathBuf, title: &str) {
}
}
println!("{}\n", "-".repeat(50));
assert!(!any_failures, "Some tests failed.");
}