Files
wasmtime/cranelift/filetests/src/test_cat.rs
Nick Fitzgerald 31cbbd1d20 clif-util: Use anyhow::Error for errors instead of String
Also does the same for `cranelift-filetests`.
2020-09-14 18:29:00 -07:00

37 lines
966 B
Rust

//! The `cat` subtest.
use crate::subtest::{self, Context, SubTest};
use cranelift_codegen::ir::Function;
use cranelift_reader::TestCommand;
use std::borrow::Cow;
/// 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) -> anyhow::Result<Box<dyn SubTest>> {
assert_eq!(parsed.command, "cat");
if !parsed.options.is_empty() {
anyhow::bail!("No options allowed on {}", parsed);
}
Ok(Box::new(TestCat))
}
impl SubTest for TestCat {
fn name(&self) -> &'static str {
"cat"
}
fn needs_verifier(&self) -> bool {
false
}
fn run(&self, func: Cow<Function>, context: &Context) -> anyhow::Result<()> {
subtest::run_filecheck(&func.display(context.isa).to_string(), context)
}
}