From 4f6a002f704e4d0023d122836bc6468e7376e7c1 Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Thu, 18 Jun 2020 12:21:19 +0200 Subject: [PATCH] cranelift-filetests: tell when a run test is skipped (fixes #1558); --- cranelift/filetests/src/runone.rs | 2 ++ cranelift/filetests/src/subtest.rs | 3 +++ cranelift/filetests/src/test_run.rs | 20 ++++++++++++-------- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/cranelift/filetests/src/runone.rs b/cranelift/filetests/src/runone.rs index 531179164d..56675a3b0e 100644 --- a/cranelift/filetests/src/runone.rs +++ b/cranelift/filetests/src/runone.rs @@ -75,6 +75,7 @@ pub fn run(path: &Path, passes: Option<&[String]>, target: Option<&str>) -> Test Some(t) => t, }; + let file_path = path.to_string_lossy(); for (func, details) in testfile.functions { let mut context = Context { preamble_comments: &testfile.preamble_comments, @@ -82,6 +83,7 @@ pub fn run(path: &Path, passes: Option<&[String]>, target: Option<&str>) -> Test verified: false, flags, isa: None, + file_path: file_path.as_ref(), }; for tuple in &tuples { diff --git a/cranelift/filetests/src/subtest.rs b/cranelift/filetests/src/subtest.rs index 0264169e4c..bc65145833 100644 --- a/cranelift/filetests/src/subtest.rs +++ b/cranelift/filetests/src/subtest.rs @@ -26,6 +26,9 @@ pub struct Context<'a> { /// Target ISA to test against. Only guaranteed to be present for sub-tests whose `needs_isa` /// method returned `true`. For other sub-tests, this is set if the test file has a unique ISA. pub isa: Option<&'a dyn TargetIsa>, + + /// Full path to the file containing the test. + pub file_path: &'a str, } impl<'a> Context<'a> { diff --git a/cranelift/filetests/src/test_run.rs b/cranelift/filetests/src/test_run.rs index 58888bf0f3..05e544efc5 100644 --- a/cranelift/filetests/src/test_run.rs +++ b/cranelift/filetests/src/test_run.rs @@ -36,6 +36,18 @@ impl SubTest for TestRun { } fn run(&self, func: Cow, context: &Context) -> SubtestResult<()> { + // If this test requests to run on a completely different + // architecture than the host platform then we skip it entirely, + // since we won't be able to natively execute machine code. + let requested_arch = context.isa.unwrap().triple().architecture; + if requested_arch != Architecture::host() { + println!( + "skipped {}: host can't run {:?} programs", + context.file_path, requested_arch + ); + return Ok(()); + } + let mut compiler = SingleFunctionCompiler::with_host_isa(context.flags.clone()); for comment in context.details.comments.iter() { if let Some(command) = @@ -43,14 +55,6 @@ impl SubTest for TestRun { { trace!("Parsed run command: {}", command); - // If this test requests to run on a completely different - // architecture than the host platform then we skip it entirely, - // since we won't be able to natively execute machine code. - let requested_arch = context.isa.unwrap().triple().architecture; - if requested_arch != Architecture::host() { - return Ok(()); - } - // Note that here we're also explicitly ignoring `context.isa`, // regardless of what's requested. We want to use the native // host ISA no matter what here, so the ISA listed in the file