]> git.lizzy.rs Git - rust.git/blobdiff - ui_test/src/lib.rs
tweak failure output a little
[rust.git] / ui_test / src / lib.rs
index 32c04290bca20ff556d3c0c7ed2b03e5f5bfbbc3..917e382379abe34443d2dba3ed6713eff12020c4 100644 (file)
@@ -109,7 +109,7 @@ pub fn run_tests(config: Config) -> Result<()> {
                     }
                     let comments = Comments::parse_file(&path)?;
                     // Ignore file if only/ignore rules do (not) apply
-                    if !test_file_conditions(&comments, &target) {
+                    if !test_file_conditions(&comments, &target, &config) {
                         ignored.fetch_add(1, Ordering::Relaxed);
                         eprintln!(
                             "{} ... {}",
@@ -164,15 +164,14 @@ pub fn run_tests(config: Config) -> Result<()> {
     if !failures.is_empty() {
         for (path, miri, revision, errors, stderr) in &failures {
             eprintln!();
-            eprint!("{}", path.display().to_string().underline());
+            eprint!("{}", path.display().to_string().underline().bold());
             if !revision.is_empty() {
                 eprint!(" (revision `{}`)", revision);
             }
-            eprint!(" {}", "FAILED".red());
+            eprint!(" {}", "FAILED:".red().bold());
             eprintln!();
             eprintln!("command: {:?}", miri);
             eprintln!();
-            let mut dump_stderr = true;
             for error in errors {
                 match error {
                     Error::ExitStatus(mode, exit_status) => eprintln!("{mode:?} got {exit_status}"),
@@ -194,9 +193,6 @@ pub fn run_tests(config: Config) -> Result<()> {
                     Error::PatternFoundInPassTest =>
                         eprintln!("{}", "error pattern found in success test".red()),
                     Error::OutputDiffers { path, actual, expected } => {
-                        if path.extension().unwrap() == "stderr" {
-                            dump_stderr = false;
-                        }
                         eprintln!("actual output differed from expected {}", path.display());
                         eprintln!("{}", pretty_assertions::StrComparison::new(expected, actual));
                         eprintln!()
@@ -223,14 +219,11 @@ pub fn run_tests(config: Config) -> Result<()> {
                 }
                 eprintln!();
             }
-            // Unless we already dumped the stderr via an OutputDiffers diff, let's dump it here.
-            if dump_stderr {
-                eprintln!("actual stderr:");
-                eprintln!("{}", stderr);
-                eprintln!();
-            }
+            eprintln!("full stderr:");
+            eprintln!("{}", stderr);
+            eprintln!();
         }
-        eprintln!("{}", "failures:".red().underline());
+        eprintln!("{}", "FAILURES:".red().underline().bold());
         for (path, _miri, _revision, _errors, _stderr) in &failures {
             eprintln!("    {}", path.display());
         }
@@ -499,19 +492,20 @@ fn output_path(path: &Path, comments: &Comments, kind: String, target: &str) ->
     path.with_extension(kind)
 }
 
-fn test_condition(condition: &Condition, target: &str) -> bool {
+fn test_condition(condition: &Condition, target: &str, config: &Config) -> bool {
     match condition {
         Condition::Bitwidth(bits) => get_pointer_width(target) == *bits,
         Condition::Target(t) => target.contains(t),
+        Condition::OnHost => config.target.is_none(),
     }
 }
 
 /// Returns whether according to the in-file conditions, this file should be run.
-fn test_file_conditions(comments: &Comments, target: &str) -> bool {
-    if comments.ignore.iter().any(|c| test_condition(c, target)) {
+fn test_file_conditions(comments: &Comments, target: &str, config: &Config) -> bool {
+    if comments.ignore.iter().any(|c| test_condition(c, target, config)) {
         return false;
     }
-    comments.only.iter().all(|c| test_condition(c, target))
+    comments.only.iter().all(|c| test_condition(c, target, config))
 }
 
 // Taken 1:1 from compiletest-rs