Rename subtest's Result to SubtestResult.
This avoids naming confusion with the standard `Result`, which is included in the prelude.
This commit is contained in:
@@ -79,7 +79,7 @@ pub fn run(verbose: bool, files: &[String]) -> TestResult {
|
||||
///
|
||||
/// This function knows how to create all of the possible `test <foo>` commands that can appear in
|
||||
/// a `.cton` test file.
|
||||
fn new_subtest(parsed: &TestCommand) -> subtest::Result<Box<subtest::SubTest>> {
|
||||
fn new_subtest(parsed: &TestCommand) -> subtest::SubtestResult<Box<subtest::SubTest>> {
|
||||
match parsed.command {
|
||||
"binemit" => test_binemit::subtest(parsed),
|
||||
"cat" => test_cat::subtest(parsed),
|
||||
|
||||
@@ -13,7 +13,7 @@ use std::fs;
|
||||
use std::io::{self, Read};
|
||||
use std::path::Path;
|
||||
use std::time;
|
||||
use subtest::{Context, Result, SubTest};
|
||||
use subtest::{Context, SubTest, SubtestResult};
|
||||
use {new_subtest, TestResult};
|
||||
|
||||
/// Read an entire file into a string.
|
||||
@@ -42,7 +42,7 @@ pub fn run(path: &Path) -> TestResult {
|
||||
.commands
|
||||
.iter()
|
||||
.map(new_subtest)
|
||||
.collect::<Result<Vec<_>>>()?;
|
||||
.collect::<SubtestResult<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.
|
||||
@@ -90,7 +90,7 @@ fn test_tuples<'a>(
|
||||
tests: &'a [Box<SubTest>],
|
||||
isa_spec: &'a IsaSpec,
|
||||
no_isa_flags: &'a Flags,
|
||||
) -> Result<Vec<(&'a SubTest, &'a Flags, Option<&'a TargetIsa>)>> {
|
||||
) -> SubtestResult<Vec<(&'a SubTest, &'a Flags, Option<&'a TargetIsa>)>> {
|
||||
let mut out = Vec::new();
|
||||
for test in tests {
|
||||
if test.needs_isa() {
|
||||
@@ -119,7 +119,7 @@ fn run_one_test<'a>(
|
||||
tuple: (&'a SubTest, &'a Flags, Option<&'a TargetIsa>),
|
||||
func: Cow<Function>,
|
||||
context: &mut Context<'a>,
|
||||
) -> Result<()> {
|
||||
) -> SubtestResult<()> {
|
||||
let (test, flags, isa) = tuple;
|
||||
let name = format!("{}({})", test.name(), func.name);
|
||||
dbg!("Test: {} {}", name, isa.map_or("-", TargetIsa::name));
|
||||
|
||||
@@ -6,9 +6,8 @@ use cretonne_codegen::settings::{Flags, FlagsOrIsa};
|
||||
use cretonne_reader::{Comment, Details};
|
||||
use filecheck::{Checker, CheckerBuilder, NO_VARIABLES};
|
||||
use std::borrow::Cow;
|
||||
use std::result;
|
||||
|
||||
pub type Result<T> = result::Result<T, String>;
|
||||
pub type SubtestResult<T> = Result<T, String>;
|
||||
|
||||
/// Context for running a test on a single function.
|
||||
pub struct Context<'a> {
|
||||
@@ -64,11 +63,11 @@ pub trait SubTest {
|
||||
}
|
||||
|
||||
/// Run this test on `func`.
|
||||
fn run(&self, func: Cow<Function>, context: &Context) -> Result<()>;
|
||||
fn run(&self, func: Cow<Function>, context: &Context) -> SubtestResult<()>;
|
||||
}
|
||||
|
||||
/// Run filecheck on `text`, using directives extracted from `context`.
|
||||
pub fn run_filecheck(text: &str, context: &Context) -> Result<()> {
|
||||
pub fn run_filecheck(text: &str, context: &Context) -> SubtestResult<()> {
|
||||
let checker = build_filechecker(context)?;
|
||||
if checker
|
||||
.check(text, NO_VARIABLES)
|
||||
@@ -85,7 +84,7 @@ pub fn run_filecheck(text: &str, context: &Context) -> Result<()> {
|
||||
}
|
||||
|
||||
/// Build a filechecker using the directives in the file preamble and the function's comments.
|
||||
pub fn build_filechecker(context: &Context) -> Result<Checker> {
|
||||
pub fn build_filechecker(context: &Context) -> SubtestResult<Checker> {
|
||||
let mut builder = CheckerBuilder::new();
|
||||
// Preamble comments apply to all functions.
|
||||
for comment in context.preamble_comments {
|
||||
|
||||
@@ -15,11 +15,11 @@ use match_directive::match_directive;
|
||||
use std::borrow::Cow;
|
||||
use std::collections::HashMap;
|
||||
use std::fmt::Write;
|
||||
use subtest::{Context, Result, SubTest};
|
||||
use subtest::{Context, SubTest, SubtestResult};
|
||||
|
||||
struct TestBinEmit;
|
||||
|
||||
pub fn subtest(parsed: &TestCommand) -> Result<Box<SubTest>> {
|
||||
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<SubTest>> {
|
||||
assert_eq!(parsed.command, "binemit");
|
||||
if !parsed.options.is_empty() {
|
||||
Err(format!("No options allowed on {}", parsed))
|
||||
@@ -108,7 +108,7 @@ impl SubTest for TestBinEmit {
|
||||
true
|
||||
}
|
||||
|
||||
fn run(&self, func: Cow<ir::Function>, context: &Context) -> Result<()> {
|
||||
fn run(&self, func: Cow<ir::Function>, context: &Context) -> SubtestResult<()> {
|
||||
let isa = context.isa.expect("binemit needs an ISA");
|
||||
let encinfo = isa.encoding_info();
|
||||
// TODO: Run a verifier pass over the code first to detect any bad encodings or missing/bad
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
use cretonne_codegen::ir::Function;
|
||||
use cretonne_reader::TestCommand;
|
||||
use std::borrow::Cow;
|
||||
use subtest::{self, Context, Result as STResult, SubTest};
|
||||
use subtest::{self, Context, SubTest, SubtestResult as STResult};
|
||||
|
||||
/// Object implementing the `test cat` sub-test.
|
||||
///
|
||||
|
||||
@@ -7,11 +7,11 @@ use cretonne_codegen::print_errors::pretty_error;
|
||||
use cretonne_codegen::{binemit, ir};
|
||||
use cretonne_reader::TestCommand;
|
||||
use std::borrow::Cow;
|
||||
use subtest::{run_filecheck, Context, Result, SubTest};
|
||||
use subtest::{run_filecheck, Context, SubTest, SubtestResult};
|
||||
|
||||
struct TestCompile;
|
||||
|
||||
pub fn subtest(parsed: &TestCommand) -> Result<Box<SubTest>> {
|
||||
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<SubTest>> {
|
||||
assert_eq!(parsed.command, "compile");
|
||||
if !parsed.options.is_empty() {
|
||||
Err(format!("No options allowed on {}", parsed))
|
||||
@@ -33,7 +33,7 @@ impl SubTest for TestCompile {
|
||||
true
|
||||
}
|
||||
|
||||
fn run(&self, func: Cow<ir::Function>, context: &Context) -> Result<()> {
|
||||
fn run(&self, func: Cow<ir::Function>, context: &Context) -> SubtestResult<()> {
|
||||
let isa = context.isa.expect("compile needs an ISA");
|
||||
let mut comp_ctx = cretonne_codegen::Context::for_function(func.into_owned());
|
||||
|
||||
|
||||
@@ -10,11 +10,11 @@ use cretonne_codegen::ir::Function;
|
||||
use cretonne_codegen::print_errors::pretty_error;
|
||||
use cretonne_reader::TestCommand;
|
||||
use std::borrow::Cow;
|
||||
use subtest::{run_filecheck, Context, Result, SubTest};
|
||||
use subtest::{run_filecheck, Context, SubTest, SubtestResult};
|
||||
|
||||
struct TestDCE;
|
||||
|
||||
pub fn subtest(parsed: &TestCommand) -> Result<Box<SubTest>> {
|
||||
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<SubTest>> {
|
||||
assert_eq!(parsed.command, "dce");
|
||||
if !parsed.options.is_empty() {
|
||||
Err(format!("No options allowed on {}", parsed))
|
||||
@@ -32,7 +32,7 @@ impl SubTest for TestDCE {
|
||||
true
|
||||
}
|
||||
|
||||
fn run(&self, func: Cow<Function>, context: &Context) -> Result<()> {
|
||||
fn run(&self, func: Cow<Function>, context: &Context) -> SubtestResult<()> {
|
||||
let mut comp_ctx = cretonne_codegen::Context::for_function(func.into_owned());
|
||||
|
||||
comp_ctx.flowgraph();
|
||||
|
||||
@@ -21,12 +21,11 @@ use match_directive::match_directive;
|
||||
use std::borrow::{Borrow, Cow};
|
||||
use std::collections::HashMap;
|
||||
use std::fmt::{self, Write};
|
||||
use std::result;
|
||||
use subtest::{run_filecheck, Context, Result, SubTest};
|
||||
use subtest::{run_filecheck, Context, SubTest, SubtestResult};
|
||||
|
||||
struct TestDomtree;
|
||||
|
||||
pub fn subtest(parsed: &TestCommand) -> Result<Box<SubTest>> {
|
||||
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<SubTest>> {
|
||||
assert_eq!(parsed.command, "domtree");
|
||||
if !parsed.options.is_empty() {
|
||||
Err(format!("No options allowed on {}", parsed))
|
||||
@@ -41,7 +40,7 @@ impl SubTest for TestDomtree {
|
||||
}
|
||||
|
||||
// Extract our own dominator tree from
|
||||
fn run(&self, func: Cow<Function>, context: &Context) -> Result<()> {
|
||||
fn run(&self, func: Cow<Function>, context: &Context) -> SubtestResult<()> {
|
||||
let func = func.borrow();
|
||||
let cfg = ControlFlowGraph::with_function(func);
|
||||
let domtree = DominatorTree::with_function(func, &cfg);
|
||||
@@ -114,7 +113,7 @@ impl SubTest for TestDomtree {
|
||||
}
|
||||
|
||||
// Generate some output for filecheck testing
|
||||
fn filecheck_text(func: &Function, domtree: &DominatorTree) -> result::Result<String, fmt::Error> {
|
||||
fn filecheck_text(func: &Function, domtree: &DominatorTree) -> Result<String, fmt::Error> {
|
||||
let mut s = String::new();
|
||||
|
||||
write!(s, "cfg_postorder:")?;
|
||||
|
||||
@@ -8,11 +8,11 @@ use cretonne_codegen::ir::Function;
|
||||
use cretonne_codegen::print_errors::pretty_error;
|
||||
use cretonne_reader::TestCommand;
|
||||
use std::borrow::Cow;
|
||||
use subtest::{run_filecheck, Context, Result, SubTest};
|
||||
use subtest::{run_filecheck, Context, SubTest, SubtestResult};
|
||||
|
||||
struct TestLegalizer;
|
||||
|
||||
pub fn subtest(parsed: &TestCommand) -> Result<Box<SubTest>> {
|
||||
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<SubTest>> {
|
||||
assert_eq!(parsed.command, "legalizer");
|
||||
if !parsed.options.is_empty() {
|
||||
Err(format!("No options allowed on {}", parsed))
|
||||
@@ -34,7 +34,7 @@ impl SubTest for TestLegalizer {
|
||||
true
|
||||
}
|
||||
|
||||
fn run(&self, func: Cow<Function>, context: &Context) -> Result<()> {
|
||||
fn run(&self, func: Cow<Function>, context: &Context) -> SubtestResult<()> {
|
||||
let mut comp_ctx = cretonne_codegen::Context::for_function(func.into_owned());
|
||||
let isa = context.isa.expect("legalizer needs an ISA");
|
||||
|
||||
|
||||
@@ -10,11 +10,11 @@ use cretonne_codegen::ir::Function;
|
||||
use cretonne_codegen::print_errors::pretty_error;
|
||||
use cretonne_reader::TestCommand;
|
||||
use std::borrow::Cow;
|
||||
use subtest::{run_filecheck, Context, Result, SubTest};
|
||||
use subtest::{run_filecheck, Context, SubTest, SubtestResult};
|
||||
|
||||
struct TestLICM;
|
||||
|
||||
pub fn subtest(parsed: &TestCommand) -> Result<Box<SubTest>> {
|
||||
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<SubTest>> {
|
||||
assert_eq!(parsed.command, "licm");
|
||||
if !parsed.options.is_empty() {
|
||||
Err(format!("No options allowed on {}", parsed))
|
||||
@@ -32,7 +32,7 @@ impl SubTest for TestLICM {
|
||||
true
|
||||
}
|
||||
|
||||
fn run(&self, func: Cow<Function>, context: &Context) -> Result<()> {
|
||||
fn run(&self, func: Cow<Function>, context: &Context) -> SubtestResult<()> {
|
||||
let mut comp_ctx = cretonne_codegen::Context::for_function(func.into_owned());
|
||||
|
||||
comp_ctx.flowgraph();
|
||||
|
||||
@@ -7,11 +7,11 @@ use cretonne_codegen::ir::Function;
|
||||
use cretonne_codegen::print_errors::pretty_error;
|
||||
use cretonne_reader::TestCommand;
|
||||
use std::borrow::Cow;
|
||||
use subtest::{run_filecheck, Context, Result, SubTest};
|
||||
use subtest::{run_filecheck, Context, SubTest, SubtestResult};
|
||||
|
||||
struct TestPostopt;
|
||||
|
||||
pub fn subtest(parsed: &TestCommand) -> Result<Box<SubTest>> {
|
||||
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<SubTest>> {
|
||||
assert_eq!(parsed.command, "postopt");
|
||||
if !parsed.options.is_empty() {
|
||||
Err(format!("No options allowed on {}", parsed))
|
||||
@@ -29,7 +29,7 @@ impl SubTest for TestPostopt {
|
||||
true
|
||||
}
|
||||
|
||||
fn run(&self, func: Cow<Function>, context: &Context) -> Result<()> {
|
||||
fn run(&self, func: Cow<Function>, context: &Context) -> SubtestResult<()> {
|
||||
let mut comp_ctx = cretonne_codegen::Context::for_function(func.into_owned());
|
||||
let isa = context.isa.expect("postopt needs an ISA");
|
||||
|
||||
|
||||
@@ -7,11 +7,11 @@ use cretonne_codegen::ir::Function;
|
||||
use cretonne_codegen::print_errors::pretty_error;
|
||||
use cretonne_reader::TestCommand;
|
||||
use std::borrow::Cow;
|
||||
use subtest::{run_filecheck, Context, Result, SubTest};
|
||||
use subtest::{run_filecheck, Context, SubTest, SubtestResult};
|
||||
|
||||
struct TestPreopt;
|
||||
|
||||
pub fn subtest(parsed: &TestCommand) -> Result<Box<SubTest>> {
|
||||
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<SubTest>> {
|
||||
assert_eq!(parsed.command, "preopt");
|
||||
if !parsed.options.is_empty() {
|
||||
Err(format!("No options allowed on {}", parsed))
|
||||
@@ -29,7 +29,7 @@ impl SubTest for TestPreopt {
|
||||
true
|
||||
}
|
||||
|
||||
fn run(&self, func: Cow<Function>, context: &Context) -> Result<()> {
|
||||
fn run(&self, func: Cow<Function>, context: &Context) -> SubtestResult<()> {
|
||||
let mut comp_ctx = cretonne_codegen::Context::for_function(func.into_owned());
|
||||
let isa = context.isa.expect("preopt needs an ISA");
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ use std::borrow::Cow;
|
||||
use cretonne_codegen::cfg_printer::CFGPrinter;
|
||||
use cretonne_codegen::ir::Function;
|
||||
use cretonne_reader::TestCommand;
|
||||
use subtest::{self, Context, Result as STResult, SubTest};
|
||||
use subtest::{self, Context, SubTest, SubtestResult as STResult};
|
||||
|
||||
/// Object implementing the `test print-cfg` sub-test.
|
||||
struct TestPrintCfg;
|
||||
|
||||
@@ -10,11 +10,11 @@ use cretonne_codegen::ir::Function;
|
||||
use cretonne_codegen::print_errors::pretty_error;
|
||||
use cretonne_reader::TestCommand;
|
||||
use std::borrow::Cow;
|
||||
use subtest::{run_filecheck, Context, Result, SubTest};
|
||||
use subtest::{run_filecheck, Context, SubTest, SubtestResult};
|
||||
|
||||
struct TestRegalloc;
|
||||
|
||||
pub fn subtest(parsed: &TestCommand) -> Result<Box<SubTest>> {
|
||||
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<SubTest>> {
|
||||
assert_eq!(parsed.command, "regalloc");
|
||||
if !parsed.options.is_empty() {
|
||||
Err(format!("No options allowed on {}", parsed))
|
||||
@@ -36,7 +36,7 @@ impl SubTest for TestRegalloc {
|
||||
true
|
||||
}
|
||||
|
||||
fn run(&self, func: Cow<Function>, context: &Context) -> Result<()> {
|
||||
fn run(&self, func: Cow<Function>, context: &Context) -> SubtestResult<()> {
|
||||
let isa = context.isa.expect("register allocator needs an ISA");
|
||||
let mut comp_ctx = cretonne_codegen::Context::for_function(func.into_owned());
|
||||
|
||||
|
||||
@@ -10,11 +10,11 @@ use cretonne_codegen::ir::Function;
|
||||
use cretonne_codegen::print_errors::pretty_error;
|
||||
use cretonne_reader::TestCommand;
|
||||
use std::borrow::Cow;
|
||||
use subtest::{run_filecheck, Context, Result, SubTest};
|
||||
use subtest::{run_filecheck, Context, SubTest, SubtestResult};
|
||||
|
||||
struct TestSimpleGVN;
|
||||
|
||||
pub fn subtest(parsed: &TestCommand) -> Result<Box<SubTest>> {
|
||||
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<SubTest>> {
|
||||
assert_eq!(parsed.command, "simple-gvn");
|
||||
if !parsed.options.is_empty() {
|
||||
Err(format!("No options allowed on {}", parsed))
|
||||
@@ -32,7 +32,7 @@ impl SubTest for TestSimpleGVN {
|
||||
true
|
||||
}
|
||||
|
||||
fn run(&self, func: Cow<Function>, context: &Context) -> Result<()> {
|
||||
fn run(&self, func: Cow<Function>, context: &Context) -> SubtestResult<()> {
|
||||
let mut comp_ctx = cretonne_codegen::Context::for_function(func.into_owned());
|
||||
|
||||
comp_ctx.flowgraph();
|
||||
|
||||
@@ -14,11 +14,11 @@ use cretonne_codegen::verify_function;
|
||||
use cretonne_reader::TestCommand;
|
||||
use match_directive::match_directive;
|
||||
use std::borrow::{Borrow, Cow};
|
||||
use subtest::{Context, Result, SubTest};
|
||||
use subtest::{Context, SubTest, SubtestResult};
|
||||
|
||||
struct TestVerifier;
|
||||
|
||||
pub fn subtest(parsed: &TestCommand) -> Result<Box<SubTest>> {
|
||||
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<SubTest>> {
|
||||
assert_eq!(parsed.command, "verifier");
|
||||
if !parsed.options.is_empty() {
|
||||
Err(format!("No options allowed on {}", parsed))
|
||||
@@ -37,7 +37,7 @@ impl SubTest for TestVerifier {
|
||||
false
|
||||
}
|
||||
|
||||
fn run(&self, func: Cow<Function>, context: &Context) -> Result<()> {
|
||||
fn run(&self, func: Cow<Function>, context: &Context) -> SubtestResult<()> {
|
||||
let func = func.borrow();
|
||||
|
||||
// Scan source annotations for "error:" directives.
|
||||
|
||||
Reference in New Issue
Block a user