Use a unique ISA in 'test cat' file tests.

Add a Function::display() method which can include ISA-specific
information when printing the function.

If a test file has a unique ISA, use that in the `test cat`
implementation.
This commit is contained in:
Jakob Stoklund Olesen
2017-03-08 12:50:43 -08:00
parent 4525929df2
commit cbbf5cc88b
5 changed files with 27 additions and 10 deletions

View File

@@ -61,6 +61,6 @@ impl SubTest for TestCat {
}
fn run(&self, func: Cow<Function>, context: &Context) -> STResult<()> {
subtest::run_filecheck(&func.to_string(), context)
subtest::run_filecheck(&func.display(context.isa).to_string(), context)
}
}

View File

@@ -90,7 +90,10 @@ fn test_tuples<'a>(tests: &'a [Box<SubTest>],
}
}
} else {
out.push((&**test, no_isa_flags, None));
// This test doesn't require an ISA, and we only want to run one instance of it.
// Still, give it an ISA ref if we happen to have a unique one.
// For example, `test cat` can use this to print encodings and register names.
out.push((&**test, no_isa_flags, isa_spec.unique_isa()));
}
}
Ok(out)

View File

@@ -10,7 +10,7 @@ use filecheck::{self, CheckerBuilder, Checker, Value as FCValue};
pub type Result<T> = result::Result<T, String>;
/// Context for running a a test on a single function.
/// Context for running a test on a single function.
pub struct Context<'a> {
/// Comments from the preamble f the test file. These apply to all functions.
pub preamble_comments: &'a [Comment<'a>],
@@ -24,8 +24,8 @@ pub struct Context<'a> {
/// ISA-independent flags for this test.
pub flags: &'a Flags,
/// Target ISA to test against. Only present for sub-tests whose `needs_isa` method returned
/// true.
/// 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 TargetIsa>,
}