diff --git a/lib/remap-lang/src/error.rs b/lib/remap-lang/src/error.rs index 35ed82c2b31715..817a0eb60e1001 100644 --- a/lib/remap-lang/src/error.rs +++ b/lib/remap-lang/src/error.rs @@ -115,19 +115,19 @@ impl<'a> From<(&'a str, program::Error)> for ProgramError<'a> { fn fmt_diagnostic(f: &mut fmt::Formatter<'_>, source: &str, diagnostic: Diagnostic) -> fmt::Result { use codespan_reporting::files::SimpleFile; - use codespan_reporting::term::{self, DisplayStyle}; + use codespan_reporting::term; use std::str::from_utf8; use termcolor::Buffer; let file = SimpleFile::new("", source); - let mut config = term::Config::default(); - config.display_style = if f.alternate() { - DisplayStyle::Short + let config = term::Config::default(); + + let mut buffer = if f.alternate() { + Buffer::ansi() } else { - DisplayStyle::Rich + Buffer::no_color() }; - let mut buffer = Buffer::no_color(); term::emit(&mut buffer, &config, &file, &diagnostic.into()).map_err(|_| fmt::Error)?; f.write_str(from_utf8(buffer.as_slice()).map_err(|_| fmt::Error)?) diff --git a/lib/remap-tests/src/main.rs b/lib/remap-tests/src/main.rs index ad6d9b75388eb8..44b48d489a6889 100644 --- a/lib/remap-tests/src/main.rs +++ b/lib/remap-tests/src/main.rs @@ -4,6 +4,11 @@ use std::fs; use std::path::PathBuf; fn main() { + let verbose = std::env::args() + .nth(1) + .map(|s| s == "--verbose") + .unwrap_or_default(); + let mut failed_count = 0; let tests = fs::read_dir("tests").expect("dir exists"); @@ -31,6 +36,10 @@ fn main() { if got == want { println!("{}", Colour::Green.bold().paint("OK")); + + if verbose { + println!("{:#}", value); + } } else { println!("{} (expectation)", Colour::Red.bold().paint("FAILED")); @@ -45,6 +54,10 @@ fn main() { let got = err.to_string(); if got == want { println!("{}", Colour::Green.bold().paint("OK")); + + if verbose { + println!("{:#}", err); + } } else { println!("{} (runtime)", Colour::Red.bold().paint("FAILED")); println!("{}", err); @@ -57,6 +70,10 @@ fn main() { let want = want.trim().to_owned(); if got == want { println!("{}", Colour::Green.bold().paint("OK")); + + if verbose { + println!("{:#}", err); + } } else { println!("{} (compilation)", Colour::Red.bold().paint("FAILED"));