Skip to content

Commit eb29be5

Browse files
committed
Register --minicore-path config and //@ use-minicore test props
1 parent 4172234 commit eb29be5

File tree

5 files changed

+30
-1
lines changed

5 files changed

+30
-1
lines changed

src/tools/compiletest/src/command-list.rs

+1
Original file line numberDiff line numberDiff line change
@@ -240,5 +240,6 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
240240
"unset-rustc-env",
241241
// Used by the tidy check `unknown_revision`.
242242
"unused-revision-names",
243+
"use-minicore",
243244
// tidy-alphabetical-end
244245
];

src/tools/compiletest/src/common.rs

+5
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,11 @@ pub struct Config {
392392
/// True if the profiler runtime is enabled for this target.
393393
/// Used by the "needs-profiler-support" header in test files.
394394
pub profiler_support: bool,
395+
396+
/// Path to minicore aux library, used for tests that need std and core stubs in
397+
/// cross-compilation scenarios that do not otherwise need to `-Zbuild-std`. Used in e.g. ABI
398+
/// tests.
399+
pub minicore_path: PathBuf,
395400
}
396401

397402
impl Config {

src/tools/compiletest/src/header.rs

+18
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@ pub struct TestProps {
218218
pub filecheck_flags: Vec<String>,
219219
/// Don't automatically insert any `--check-cfg` args
220220
pub no_auto_check_cfg: bool,
221+
/// Build and use minicore as std/core stub for tests in cross-compilation scenarios that don't
222+
/// otherwise need `-Z build-std`.
223+
pub use_minicore: bool,
221224
}
222225

223226
mod directives {
@@ -263,6 +266,7 @@ mod directives {
263266
pub const LLVM_COV_FLAGS: &'static str = "llvm-cov-flags";
264267
pub const FILECHECK_FLAGS: &'static str = "filecheck-flags";
265268
pub const NO_AUTO_CHECK_CFG: &'static str = "no-auto-check-cfg";
269+
pub const USE_MINICORE: &'static str = "use-minicore";
266270
// This isn't a real directive, just one that is probably mistyped often
267271
pub const INCORRECT_COMPILER_FLAGS: &'static str = "compiler-flags";
268272
}
@@ -322,6 +326,7 @@ impl TestProps {
322326
llvm_cov_flags: vec![],
323327
filecheck_flags: vec![],
324328
no_auto_check_cfg: false,
329+
use_minicore: false,
325330
}
326331
}
327332

@@ -597,6 +602,8 @@ impl TestProps {
597602
}
598603

599604
config.set_name_directive(ln, NO_AUTO_CHECK_CFG, &mut self.no_auto_check_cfg);
605+
606+
self.update_use_minicore(ln, config);
600607
},
601608
);
602609

@@ -710,6 +717,17 @@ impl TestProps {
710717
pub fn local_pass_mode(&self) -> Option<PassMode> {
711718
self.pass_mode
712719
}
720+
721+
pub fn update_use_minicore(&mut self, ln: &str, config: &Config) {
722+
let use_minicore = config.parse_name_directive(ln, directives::USE_MINICORE);
723+
if use_minicore {
724+
if !matches!(config.mode, Mode::Ui | Mode::Codegen | Mode::Assembly) {
725+
panic!("`use-minicore` is only supported for ui, codegen and assembly test modes");
726+
}
727+
728+
self.use_minicore = use_minicore;
729+
}
730+
}
713731
}
714732

715733
/// Extract an `(Option<line_revision>, directive)` directive from a line if comment is present.

src/tools/compiletest/src/header/tests.rs

+1
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ impl ConfigBuilder {
149149
"--git-repository=",
150150
"--nightly-branch=",
151151
"--git-merge-commit-email=",
152+
"--minicore-path=",
152153
];
153154
let mut args: Vec<String> = args.iter().map(ToString::to_string).collect();
154155

src/tools/compiletest/src/lib.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
170170
"git-merge-commit-email",
171171
"email address used for finding merge commits",
172172
"EMAIL",
173-
);
173+
)
174+
.reqopt("", "minicore-path", "path to minicore aux library", "PATH");
174175

175176
let (argv0, args_) = args.split_first().unwrap();
176177
if args.len() == 1 || args[1] == "-h" || args[1] == "--help" {
@@ -357,6 +358,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
357358
git_merge_commit_email: matches.opt_str("git-merge-commit-email").unwrap(),
358359

359360
profiler_support: matches.opt_present("profiler-support"),
361+
362+
minicore_path: opt_path(matches, "minicore-path"),
360363
}
361364
}
362365

@@ -394,6 +397,7 @@ pub fn log_config(config: &Config) {
394397
logv(c, format!("host-linker: {:?}", config.host_linker));
395398
logv(c, format!("verbose: {}", config.verbose));
396399
logv(c, format!("format: {:?}", config.format));
400+
logv(c, format!("minicore_path: {:?}", config.minicore_path.display()));
397401
logv(c, "\n".to_string());
398402
}
399403

0 commit comments

Comments
 (0)