Skip to content

Commit

Permalink
feat: add --disable-builtin-rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Gankra committed Jul 14, 2024
1 parent a6bb706 commit 1297b82
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
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`),
/// 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
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

0 comments on commit 1297b82

Please sign in to comment.