compiletest: register --minicore-path
flag and //@ add-core-stubs
directive
This commit is contained in:
parent
74c0c48858
commit
95d01fcee9
@ -392,6 +392,11 @@ pub struct Config {
|
||||
|
||||
/// Command for visual diff display, e.g. `diff-tool --color=always`.
|
||||
pub diff_command: Option<String>,
|
||||
|
||||
/// Path to minicore aux library, used for `no_core` tests that need `core` stubs in
|
||||
/// cross-compilation scenarios that do not otherwise want/need to `-Zbuild-std`. Used in e.g.
|
||||
/// ABI tests.
|
||||
pub minicore_path: PathBuf,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
|
@ -3,6 +3,7 @@
|
||||
/// a best-effort approximation for diagnostics. Add new headers to this list when needed.
|
||||
const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
|
||||
// tidy-alphabetical-start
|
||||
"add-core-stubs",
|
||||
"assembly-output",
|
||||
"aux-bin",
|
||||
"aux-build",
|
||||
|
@ -198,6 +198,9 @@ pub struct TestProps {
|
||||
pub no_auto_check_cfg: bool,
|
||||
/// Run tests which require enzyme being build
|
||||
pub has_enzyme: bool,
|
||||
/// Build and use `minicore` as `core` stub for `no_core` tests in cross-compilation scenarios
|
||||
/// that don't otherwise want/need `-Z build-std`.
|
||||
pub add_core_stubs: bool,
|
||||
}
|
||||
|
||||
mod directives {
|
||||
@ -243,6 +246,7 @@ mod directives {
|
||||
pub const LLVM_COV_FLAGS: &'static str = "llvm-cov-flags";
|
||||
pub const FILECHECK_FLAGS: &'static str = "filecheck-flags";
|
||||
pub const NO_AUTO_CHECK_CFG: &'static str = "no-auto-check-cfg";
|
||||
pub const ADD_CORE_STUBS: &'static str = "add-core-stubs";
|
||||
// This isn't a real directive, just one that is probably mistyped often
|
||||
pub const INCORRECT_COMPILER_FLAGS: &'static str = "compiler-flags";
|
||||
}
|
||||
@ -300,6 +304,7 @@ pub fn new() -> Self {
|
||||
filecheck_flags: vec![],
|
||||
no_auto_check_cfg: false,
|
||||
has_enzyme: false,
|
||||
add_core_stubs: false,
|
||||
}
|
||||
}
|
||||
|
||||
@ -564,6 +569,8 @@ fn split_flags(flags: &str) -> Vec<String> {
|
||||
}
|
||||
|
||||
config.set_name_directive(ln, NO_AUTO_CHECK_CFG, &mut self.no_auto_check_cfg);
|
||||
|
||||
self.update_add_core_stubs(ln, config);
|
||||
},
|
||||
);
|
||||
|
||||
@ -677,6 +684,27 @@ pub fn pass_mode(&self, config: &Config) -> Option<PassMode> {
|
||||
pub fn local_pass_mode(&self) -> Option<PassMode> {
|
||||
self.pass_mode
|
||||
}
|
||||
|
||||
pub fn update_add_core_stubs(&mut self, ln: &str, config: &Config) {
|
||||
let add_core_stubs = config.parse_name_directive(ln, directives::ADD_CORE_STUBS);
|
||||
if add_core_stubs {
|
||||
if !matches!(config.mode, Mode::Ui | Mode::Codegen | Mode::Assembly) {
|
||||
panic!(
|
||||
"`add-core-stubs` is currently only supported for ui, codegen and assembly test modes"
|
||||
);
|
||||
}
|
||||
|
||||
// FIXME(jieyouxu): this check is currently order-dependent, but we should probably
|
||||
// collect all directives in one go then perform a validation pass after that.
|
||||
if self.local_pass_mode().is_some_and(|pm| pm == PassMode::Run) {
|
||||
// `minicore` can only be used with non-run modes, because it's `core` prelude stubs
|
||||
// and can't run.
|
||||
panic!("`add-core-stubs` cannot be used to run the test binary");
|
||||
}
|
||||
|
||||
self.add_core_stubs = add_core_stubs;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// If the given line begins with the appropriate comment prefix for a directive,
|
||||
|
@ -152,6 +152,7 @@ fn build(&mut self) -> Config {
|
||||
"--git-repository=",
|
||||
"--nightly-branch=",
|
||||
"--git-merge-commit-email=",
|
||||
"--minicore-path=",
|
||||
];
|
||||
let mut args: Vec<String> = args.iter().map(ToString::to_string).collect();
|
||||
|
||||
|
@ -181,7 +181,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
|
||||
"compiletest-diff-tool",
|
||||
"What custom diff tool to use for displaying compiletest tests.",
|
||||
"COMMAND",
|
||||
);
|
||||
)
|
||||
.reqopt("", "minicore-path", "path to minicore aux library", "PATH");
|
||||
|
||||
let (argv0, args_) = args.split_first().unwrap();
|
||||
if args.len() == 1 || args[1] == "-h" || args[1] == "--help" {
|
||||
@ -371,7 +372,10 @@ fn make_absolute(path: PathBuf) -> PathBuf {
|
||||
git_merge_commit_email: matches.opt_str("git-merge-commit-email").unwrap(),
|
||||
|
||||
profiler_runtime: matches.opt_present("profiler-runtime"),
|
||||
|
||||
diff_command: matches.opt_str("compiletest-diff-tool"),
|
||||
|
||||
minicore_path: opt_path(matches, "minicore-path"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -409,6 +413,7 @@ pub fn log_config(config: &Config) {
|
||||
logv(c, format!("host-linker: {:?}", config.host_linker));
|
||||
logv(c, format!("verbose: {}", config.verbose));
|
||||
logv(c, format!("format: {:?}", config.format));
|
||||
logv(c, format!("minicore_path: {:?}", config.minicore_path.display()));
|
||||
logv(c, "\n".to_string());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user