Run the filetests as part of "cargo test".
Refactor the filetests harness so that it can be run as part of `cargo test`. And begin reorganizing the test harness code in preparation for moving it out of the src directory. - Test subcommand files are now named `test_*.rs`. - cton-util subcommand files now just export their `run` and nothing else. - src/filetest/mod.rs now also just exports `run` and nothing else. - Tests are now run in release mode (with debug assertions enabled).
This commit is contained in:
@@ -3,12 +3,9 @@
|
||||
//! Read a sequence of Cretonne IL files and print them again to stdout. This has the effect of
|
||||
//! normalizing formatting and removing comments.
|
||||
|
||||
use std::borrow::Cow;
|
||||
use cretonne::ir::Function;
|
||||
use cton_reader::{parse_functions, TestCommand};
|
||||
use cton_reader::parse_functions;
|
||||
use CommandResult;
|
||||
use utils::read_to_string;
|
||||
use filetest::subtest::{self, SubTest, Context, Result as STResult};
|
||||
|
||||
pub fn run(files: Vec<String>) -> CommandResult {
|
||||
for (i, f) in files.into_iter().enumerate() {
|
||||
@@ -37,34 +34,3 @@ fn cat_one(filename: String) -> CommandResult {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Object implementing the `test cat` sub-test.
|
||||
///
|
||||
/// This command is used for testing the parser and function printer. It simply parses a function
|
||||
/// and prints it out again.
|
||||
///
|
||||
/// The result is verified by filecheck.
|
||||
struct TestCat;
|
||||
|
||||
pub fn subtest(parsed: &TestCommand) -> STResult<Box<SubTest>> {
|
||||
assert_eq!(parsed.command, "cat");
|
||||
if !parsed.options.is_empty() {
|
||||
Err(format!("No options allowed on {}", parsed))
|
||||
} else {
|
||||
Ok(Box::new(TestCat))
|
||||
}
|
||||
}
|
||||
|
||||
impl SubTest for TestCat {
|
||||
fn name(&self) -> Cow<str> {
|
||||
Cow::from("cat")
|
||||
}
|
||||
|
||||
fn needs_verifier(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn run(&self, func: Cow<Function>, context: &Context) -> STResult<()> {
|
||||
subtest::run_filecheck(&func.display(context.isa).to_string(), context)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user