Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: runtime test expectation file #70

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ struct Cli {
/// Add the test expectations at the given path
///
/// (If not specified we'll look for a file called abi-cafe-rules.toml in the working dir)
///
/// Note that there are already builtin rules (disabled with `--disable-builtin-riles`),
Gankra marked this conversation as resolved.
Show resolved Hide resolved
/// and it would be nice for rules to be upstreamed so everyone can benefit!
#[clap(long)]
rules: Option<Utf8PathBuf>,

Expand All @@ -142,6 +145,12 @@ struct Cli {
#[clap(long)]
disable_builtin_tests: bool,

/// disable the builtin rules
///
/// See also `--add-rules`
#[clap(long)]
disable_builtin_rules: bool,

/// deprecated, does nothing (we always procgen now)
#[clap(long, hide = true)]
procgen_tests: bool,
Expand All @@ -162,6 +171,7 @@ pub fn make_app() -> Config {
add_tests,
rules,
disable_builtin_tests,
disable_builtin_rules,
// unimplemented
select_vals: _,
key: _,
Expand Down Expand Up @@ -257,6 +267,7 @@ Hint: Try using `--pairs {name}_calls_rustc` or `--pairs rustc_calls_{name}`.
run_selections,
minimizing_write_impl,
disable_builtin_tests,
disable_builtin_rules,
paths,
}
}
12 changes: 8 additions & 4 deletions src/harness/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,18 @@ impl Pathish {
}

pub fn find_test_rules(cfg: &Config) -> Result<Vec<ExpectFile>, GenerateError> {
let static_rules = find_test_rules_static()?;
let static_rules = find_test_rules_static(cfg.disable_builtin_rules)?;
let rules = find_test_rules_runtime(&cfg.paths.runtime_rules_file)?;
Ok(vec![static_rules, rules])
}

pub fn find_test_rules_static() -> Result<ExpectFile, GenerateError> {
let data = files::static_rules();
let rules = toml::from_str(&data)?;
pub fn find_test_rules_static(disable_builtin_rules: bool) -> Result<ExpectFile, GenerateError> {
let rules = if disable_builtin_rules {
ExpectFile::default()
} else {
let data = files::static_rules();
toml::from_str(&data)?
};
Ok(rules)
}

Expand Down
16 changes: 8 additions & 8 deletions src/harness/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@ impl TestHarness {
check: Pass(Check),
};

//
//
// THIS AREA RESERVED FOR VENDORS TO APPLY PATCHES

// END OF VENDOR RESERVED AREA
//
//

for expect_file in &self.test_rules {
let rulesets = [
expect_file.targets.get("*"),
Expand All @@ -50,6 +42,14 @@ impl TestHarness {
}
}

//
//
// THIS AREA RESERVED FOR VENDORS TO APPLY PATCHES

// END OF VENDOR RESERVED AREA
//
//

result
}
}
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ pub struct Config {
pub minimizing_write_impl: WriteImpl,
pub rustc_codegen_backends: Vec<(String, String)>,
pub disable_builtin_tests: bool,
pub disable_builtin_rules: bool,
pub paths: Paths,
}

Expand Down
Loading