cranelift_filetests/
test_cat.rs

1//! The `cat` subtest.
2
3use crate::subtest::{self, Context, SubTest};
4use cranelift_codegen::ir::Function;
5use cranelift_reader::TestCommand;
6use std::borrow::Cow;
7
8/// Object implementing the `test cat` sub-test.
9///
10/// This command is used for testing the parser and function printer. It simply parses a function
11/// and prints it out again.
12///
13/// The result is verified by filecheck.
14struct TestCat;
15
16pub fn subtest(parsed: &TestCommand) -> anyhow::Result<Box<dyn SubTest>> {
17    assert_eq!(parsed.command, "cat");
18    if !parsed.options.is_empty() {
19        anyhow::bail!("No options allowed on {}", parsed);
20    }
21    Ok(Box::new(TestCat))
22}
23
24impl SubTest for TestCat {
25    fn name(&self) -> &'static str {
26        "cat"
27    }
28
29    fn needs_verifier(&self) -> bool {
30        false
31    }
32
33    fn run(&self, func: Cow<Function>, context: &Context) -> anyhow::Result<()> {
34        subtest::run_filecheck(&func.display().to_string(), context)
35    }
36}