Skip to content

Commit 34f88f3

Browse files
committed
Combine run-pass tests into a single crate
1 parent 8b3d4d9 commit 34f88f3

File tree

22 files changed

+680
-30
lines changed

22 files changed

+680
-30
lines changed

config.toml.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,9 @@
283283
# desired in distributions, for example.
284284
#rpath = true
285285

286+
# Merge Rust test files into larger units for faster testing
287+
#combine-tests = false
288+
286289
# Suppresses extraneous output from tests to ensure the output of the test
287290
# harness is relatively clean.
288291
#quiet-tests = false

src/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/bootstrap/config.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ pub struct Config {
119119
pub low_priority: bool,
120120
pub channel: String,
121121
pub quiet_tests: bool,
122+
pub combine_tests: bool,
122123
pub test_miri: bool,
123124
pub save_toolstates: Option<PathBuf>,
124125

@@ -288,6 +289,7 @@ struct Rust {
288289
debug: Option<bool>,
289290
dist_src: Option<bool>,
290291
quiet_tests: Option<bool>,
292+
combine_tests: Option<bool>,
291293
test_miri: Option<bool>,
292294
save_toolstates: Option<String>,
293295
codegen_backends: Option<Vec<String>>,
@@ -478,6 +480,7 @@ impl Config {
478480
set(&mut config.backtrace, rust.backtrace);
479481
set(&mut config.channel, rust.channel.clone());
480482
set(&mut config.rust_dist_src, rust.dist_src);
483+
set(&mut config.combine_tests, rust.combine_tests);
481484
set(&mut config.quiet_tests, rust.quiet_tests);
482485
set(&mut config.test_miri, rust.test_miri);
483486
set(&mut config.wasm_syscall, rust.wasm_syscall);

src/bootstrap/configure.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def v(*args):
4747
o("test-miri", "rust.test-miri", "run miri's test suite")
4848
o("debuginfo-tests", "rust.debuginfo-tests", "build tests with debugger metadata")
4949
o("quiet-tests", "rust.quiet-tests", "enable quieter output when running tests")
50+
o("combined-tests", "rust.combine-tests", "merge tests together when possible")
5051
o("ccache", "llvm.ccache", "invoke gcc/clang via ccache to reuse object files between builds")
5152
o("sccache", None, "invoke gcc/clang via sccache to reuse object files between builds")
5253
o("local-rust", None, "use an installed rustc rather than downloading a snapshot")

src/bootstrap/test.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,10 @@ impl Step for Compiletest {
848848
cmd.arg("--run-lib-path").arg(builder.sysroot_libdir(compiler, target));
849849
cmd.arg("--rustc-path").arg(builder.rustc(compiler));
850850

851+
if builder.config.combine_tests && mode == "run-pass" {
852+
cmd.arg("--combine");
853+
}
854+
851855
// Avoid depending on rustdoc when we don't need it.
852856
if mode == "rustdoc" || mode == "run-make" {
853857
cmd.arg("--rustdoc-path").arg(builder.rustdoc(compiler.host));

src/librustc/session/config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,6 +1114,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
11141114
"generate comments into the assembly (may change behavior)"),
11151115
no_verify: bool = (false, parse_bool, [TRACKED],
11161116
"skip LLVM verification"),
1117+
submodules_crate_like: bool = (false, parse_bool, [TRACKED],
1118+
"pretend immediate submodules of the crate are crates themselves"),
11171119
borrowck_stats: bool = (false, parse_bool, [UNTRACKED],
11181120
"gather borrowck statistics"),
11191121
no_landing_pads: bool = (false, parse_bool, [TRACKED],

src/librustc/session/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,8 @@ pub fn build_session_(
10951095
};
10961096
let target_cfg = config::build_target_config(&sopts, &span_diagnostic);
10971097

1098-
let p_s = parse::ParseSess::with_span_handler(span_diagnostic, codemap);
1098+
let mut p_s = parse::ParseSess::with_span_handler(span_diagnostic, codemap);
1099+
p_s.combine_test_mode = sopts.debugging_opts.submodules_crate_like;
10991100
let default_sysroot = match sopts.maybe_sysroot {
11001101
Some(_) => None,
11011102
None => Some(filesearch::get_or_default_sysroot()),

src/librustc_driver/driver.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ pub fn phase_1_parse_input<'a>(control: &CompileController,
521521
profile::begin(sess);
522522
}
523523

524-
let krate = time(sess, "parsing", || {
524+
let mut krate = time(sess, "parsing", || {
525525
match *input {
526526
Input::File(ref file) => {
527527
parse::parse_crate_from_file(file, &sess.parse_sess)
@@ -549,6 +549,17 @@ pub fn phase_1_parse_input<'a>(control: &CompileController,
549549
syntax::show_span::run(sess.diagnostic(), s, &krate);
550550
}
551551

552+
if sess.opts.debugging_opts.submodules_crate_like {
553+
krate = time(sess,
554+
"Pretending submodules are crates",
555+
|| rustc_passes::submodules_crate_like::modify_crate(sess, krate));
556+
}
557+
558+
if sess.opts.debugging_opts.ast_json_noexpand {
559+
println!("\n\n\n\n\n\n\n\n");
560+
println!("{}", json::as_json(&krate));
561+
}
562+
552563
if sess.opts.debugging_opts.hir_stats {
553564
hir_stats::print_ast_stats(&krate, "PRE EXPANSION AST STATS");
554565
}

src/librustc_driver/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -895,8 +895,8 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
895895
}
896896

897897
if sess.opts.debugging_opts.parse_only ||
898-
sess.opts.debugging_opts.show_span.is_some() ||
899-
sess.opts.debugging_opts.ast_json_noexpand {
898+
sess.opts.debugging_opts.show_span.is_some()/* ||
899+
sess.opts.debugging_opts.ast_json_noexpand*/ {
900900
control.after_parse.stop = Compilation::Stop;
901901
}
902902

src/librustc_passes/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ use rustc::ty::maps::Providers;
3838

3939
mod diagnostics;
4040

41+
pub mod submodules_crate_like;
4142
pub mod ast_validation;
4243
pub mod rvalue_promotion;
4344
pub mod hir_stats;

0 commit comments

Comments
 (0)