Add feature flags to test files.

Cranelift can be compiled with feature flags which can change its output. To
accomodate changes of output related to feature flags, test file can now include
`feature "..."` and `feature ! "..."` directives in the preamble of the test
file.

The test runner would skip the test if the flag does not match the expectation
of the test case.
This commit is contained in:
Nicolas B. Pierron
2019-08-27 14:25:21 +02:00
committed by Nicolas B. Pierron
parent 26efc696c6
commit 04b10b3fde
7 changed files with 130 additions and 7 deletions

View File

@@ -20,6 +20,8 @@ pub struct TestFile<'a> {
pub commands: Vec<TestCommand<'a>>,
/// `isa bar ...` lines.
pub isa_spec: IsaSpec,
/// `feature ...` lines
pub features: Vec<Feature<'a>>,
/// Comments appearing before the first function.
/// These are all tagged as 'Function' scope for lack of a better entity.
pub preamble_comments: Vec<Comment<'a>>,
@@ -55,3 +57,17 @@ pub struct Comment<'a> {
/// Text of the comment, including the leading `;`.
pub text: &'a str,
}
/// A cranelift feature in a test file preamble.
///
/// This represents the expectation of the test case. Before running any of the
/// functions of the test file, the feature set should be compared with the
/// feature set used to compile Cranelift. If there is any differences, then the
/// test file should be skipped.
#[derive(PartialEq, Eq, Debug)]
pub enum Feature<'a> {
/// `feature "..."` lines
With(&'a str),
/// `feature ! "..."` lines.
Without(&'a str),
}