committed by
Jakob Stoklund Olesen
parent
c8be39fa9d
commit
7459fee71a
@@ -39,7 +39,7 @@ impl SubTest for TestLegalizer {
|
||||
legalize_function(&mut func, isa);
|
||||
|
||||
let mut text = String::new();
|
||||
try!(write_function(&mut text, &func, Some(isa)).map_err(|e| e.to_string()));
|
||||
write_function(&mut text, &func, Some(isa)).map_err(|e| e.to_string())?;
|
||||
run_filecheck(&text, context)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ impl SubTest for TestRegalloc {
|
||||
comp_ctx.regalloc(isa);
|
||||
|
||||
let mut text = String::new();
|
||||
try!(write_function(&mut text, &comp_ctx.func, Some(isa)).map_err(|e| e.to_string()));
|
||||
write_function(&mut text, &comp_ctx.func, Some(isa)).map_err(|e| e.to_string())?;
|
||||
run_filecheck(&text, context)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,14 +18,14 @@ use filetest::subtest::{SubTest, Context, Result};
|
||||
/// If running this test causes a panic, it will propagate as normal.
|
||||
pub fn run(path: &Path) -> TestResult {
|
||||
let started = time::Instant::now();
|
||||
let buffer = try!(read_to_string(path).map_err(|e| e.to_string()));
|
||||
let testfile = try!(parse_test(&buffer).map_err(|e| e.to_string()));
|
||||
let buffer = read_to_string(path).map_err(|e| e.to_string())?;
|
||||
let testfile = parse_test(&buffer).map_err(|e| e.to_string())?;
|
||||
if testfile.functions.is_empty() {
|
||||
return Err("no functions found".to_string());
|
||||
}
|
||||
|
||||
// Parse the test commands.
|
||||
let mut tests = try!(testfile.commands.iter().map(new_subtest).collect::<Result<Vec<_>>>());
|
||||
let mut tests = testfile.commands.iter().map(new_subtest).collect::<Result<Vec<_>>>()?;
|
||||
|
||||
// Flags to use for those tests that don't need an ISA.
|
||||
// This is the cumulative effect of all the `set` commands in the file.
|
||||
@@ -39,7 +39,7 @@ pub fn run(path: &Path) -> TestResult {
|
||||
tests.sort_by_key(|st| (st.is_mutating(), st.needs_verifier()));
|
||||
|
||||
// Expand the tests into (test, flags, isa) tuples.
|
||||
let mut tuples = try!(test_tuples(&tests, &testfile.isa_spec, flags));
|
||||
let mut tuples = test_tuples(&tests, &testfile.isa_spec, flags)?;
|
||||
|
||||
// Isolate the last test in the hope that this is the only mutating test.
|
||||
// If so, we can completely avoid cloning functions.
|
||||
@@ -58,11 +58,11 @@ pub fn run(path: &Path) -> TestResult {
|
||||
};
|
||||
|
||||
for tuple in &tuples {
|
||||
try!(run_one_test(*tuple, Cow::Borrowed(&func), &mut context));
|
||||
run_one_test(*tuple, Cow::Borrowed(&func), &mut context)?;
|
||||
}
|
||||
// Run the last test with an owned function which means it won't need to clone it before
|
||||
// mutating.
|
||||
try!(run_one_test(last_tuple, Cow::Owned(func), &mut context));
|
||||
run_one_test(last_tuple, Cow::Owned(func), &mut context)?;
|
||||
}
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ fn run_one_test<'a>(tuple: (&'a SubTest, &'a Flags, Option<&'a TargetIsa>),
|
||||
|
||||
// Should we run the verifier before this test?
|
||||
if !context.verified && test.needs_verifier() {
|
||||
try!(verify_function(&func).map_err(|e| e.to_string()));
|
||||
verify_function(&func).map_err(|e| e.to_string())?;
|
||||
context.verified = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -72,13 +72,13 @@ impl<'a> filecheck::VariableMap for Context<'a> {
|
||||
|
||||
/// Run filecheck on `text`, using directives extracted from `context`.
|
||||
pub fn run_filecheck(text: &str, context: &Context) -> Result<()> {
|
||||
let checker = try!(build_filechecker(context));
|
||||
if try!(checker.check(&text, context).map_err(|e| format!("filecheck: {}", e))) {
|
||||
let checker = build_filechecker(context)?;
|
||||
if checker.check(&text, context).map_err(|e| format!("filecheck: {}", e))? {
|
||||
Ok(())
|
||||
} else {
|
||||
// Filecheck mismatch. Emit an explanation as output.
|
||||
let (_, explain) = try!(checker.explain(&text, context)
|
||||
.map_err(|e| format!("explain: {}", e)));
|
||||
let (_, explain) = checker.explain(&text, context)
|
||||
.map_err(|e| format!("explain: {}", e))?;
|
||||
Err(format!("filecheck failed:\n{}{}", checker, explain))
|
||||
}
|
||||
}
|
||||
@@ -88,10 +88,10 @@ pub fn build_filechecker(context: &Context) -> Result<Checker> {
|
||||
let mut builder = CheckerBuilder::new();
|
||||
// Preamble comments apply to all functions.
|
||||
for comment in context.preamble_comments {
|
||||
try!(builder.directive(comment.text).map_err(|e| format!("filecheck: {}", e)));
|
||||
builder.directive(comment.text).map_err(|e| format!("filecheck: {}", e))?;
|
||||
}
|
||||
for comment in &context.details.comments {
|
||||
try!(builder.directive(comment.text).map_err(|e| format!("filecheck: {}", e)));
|
||||
builder.directive(comment.text).map_err(|e| format!("filecheck: {}", e))?;
|
||||
}
|
||||
let checker = builder.finish();
|
||||
if checker.is_empty() {
|
||||
|
||||
Reference in New Issue
Block a user