Allow filecheck directives with "test compile".

Things like inserted prologues and epilogues in #201 can be tested this
way.
This commit is contained in:
Jakob Stoklund Olesen
2017-12-04 09:18:30 -08:00
parent 919de82e9c
commit 04f6ccabe5
2 changed files with 19 additions and 3 deletions

View File

@@ -6,8 +6,9 @@ use cretonne::binemit;
use cretonne::ir;
use cretonne;
use cton_reader::TestCommand;
use filetest::subtest::{SubTest, Context, Result};
use filetest::subtest::{SubTest, Context, Result, run_filecheck};
use std::borrow::Cow;
use std::fmt::Write;
use utils::pretty_error;
struct TestCompile;
@@ -51,7 +52,7 @@ impl SubTest for TestCompile {
comp_ctx.func.display(isa)
);
// Finally verify that the returned code size matches the emitted bytes.
// Verify that the returned code size matches the emitted bytes.
let mut sink = SizeSink { offset: 0 };
binemit::emit_function(
&comp_ctx.func,
@@ -67,7 +68,11 @@ impl SubTest for TestCompile {
));
}
Ok(())
// Run final code through filecheck.
let mut text = String::new();
write!(&mut text, "{}", &comp_ctx.func.display(Some(isa)))
.map_err(|e| e.to_string())?;
run_filecheck(&text, context)
}
}