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

[WIP] Combine run-pass tests into a single crate #49142

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,9 @@
# desired in distributions, for example.
#rpath = true

# Merge Rust test files into larger units for faster testing
#combine-tests = false

# Suppresses extraneous output from tests to ensure the output of the test
# harness is relatively clean.
#quiet-tests = false
Expand Down
2 changes: 2 additions & 0 deletions src/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use std::collections::BTreeSet;
use std::env;
use std::fmt::Debug;
use std::fs;
use std::cmp;
use std::hash::Hash;
use std::ops::Deref;
use std::path::{Path, PathBuf};
Expand Down Expand Up @@ -551,6 +552,7 @@ impl<'a> Builder<'a> {
} else {
stage = compiler.stage;
}
let source_stage = cmp::max(stage, 1);

let mut extra_args = env::var(&format!("RUSTFLAGS_STAGE_{}", stage)).unwrap_or_default();
if stage != 0 {
Expand Down Expand Up @@ -598,7 +600,8 @@ impl<'a> Builder<'a> {
cargo.env("RUSTC_ERROR_FORMAT", error_format);
}
if cmd != "build" && cmd != "check" {
cargo.env("RUSTDOC_LIBDIR", self.rustc_libdir(self.compiler(2, self.build.build)));
cargo.env("RUSTDOC_LIBDIR",
self.rustc_libdir(self.compiler(source_stage, self.build.build)));
}

if mode != Mode::Tool {
Expand Down
3 changes: 3 additions & 0 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ pub struct Config {
pub low_priority: bool,
pub channel: String,
pub quiet_tests: bool,
pub combine_tests: bool,
pub test_miri: bool,
pub save_toolstates: Option<PathBuf>,
pub print_step_timings: bool,
Expand Down Expand Up @@ -290,6 +291,7 @@ struct Rust {
debug: Option<bool>,
dist_src: Option<bool>,
quiet_tests: Option<bool>,
combine_tests: Option<bool>,
test_miri: Option<bool>,
save_toolstates: Option<String>,
codegen_backends: Option<Vec<String>>,
Expand Down Expand Up @@ -481,6 +483,7 @@ impl Config {
set(&mut config.backtrace, rust.backtrace);
set(&mut config.channel, rust.channel.clone());
set(&mut config.rust_dist_src, rust.dist_src);
set(&mut config.combine_tests, rust.combine_tests);
set(&mut config.quiet_tests, rust.quiet_tests);
set(&mut config.test_miri, rust.test_miri);
set(&mut config.wasm_syscall, rust.wasm_syscall);
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def v(*args):
o("test-miri", "rust.test-miri", "run miri's test suite")
o("debuginfo-tests", "rust.debuginfo-tests", "build tests with debugger metadata")
o("quiet-tests", "rust.quiet-tests", "enable quieter output when running tests")
o("combined-tests", "rust.combine-tests", "merge tests together when possible")
o("ccache", "llvm.ccache", "invoke gcc/clang via ccache to reuse object files between builds")
o("sccache", None, "invoke gcc/clang via sccache to reuse object files between builds")
o("local-rust", None, "use an installed rustc rather than downloading a snapshot")
Expand Down
1 change: 0 additions & 1 deletion src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@
//! More documentation can be found in each respective module below, and you can
//! also check out the `src/bootstrap/README.md` file for more information.

#![deny(warnings)]
#![feature(core_intrinsics)]
#![feature(slice_concat_ext)]

Expand Down
9 changes: 9 additions & 0 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,10 @@ impl Step for Compiletest {
cmd.arg("--run-lib-path").arg(builder.sysroot_libdir(compiler, target));
cmd.arg("--rustc-path").arg(builder.rustc(compiler));

if builder.config.combine_tests && mode == "run-pass" {
cmd.arg("--combine");
}

// Avoid depending on rustdoc when we don't need it.
if mode == "rustdoc" || (mode == "run-make" && suite.ends_with("fulldeps")) {
cmd.arg("--rustdoc-path").arg(builder.rustdoc(compiler.host));
Expand Down Expand Up @@ -1420,6 +1424,11 @@ impl Step for Crate {
cargo.arg("--doc");
}

if build.config.combine_tests {
cargo.env("RUSTDOC_COMBINE_TESTS", "1");
//cargo.arg("--doc"); -- RUNS ONLY DOCTESTS
}

cargo.arg("-p").arg(krate);

// The tests are going to run with the *target* libraries, so we need to
Expand Down
1 change: 1 addition & 0 deletions src/ci/docker/x86_64-gnu-llvm-3.9/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ RUN sh /scripts/sccache.sh
ENV RUST_CONFIGURE_ARGS \
--build=x86_64-unknown-linux-gnu \
--llvm-root=/usr/lib/llvm-3.9 \
--enable-combined-tests \
--enable-llvm-link-shared
ENV RUST_CHECK_TARGET check
2 changes: 2 additions & 0 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
"generate comments into the assembly (may change behavior)"),
no_verify: bool = (false, parse_bool, [TRACKED],
"skip LLVM verification"),
combine_tests: bool = (false, parse_bool, [TRACKED],
"pretend immediate submodules of the crate are crates themselves"),
borrowck_stats: bool = (false, parse_bool, [UNTRACKED],
"gather borrowck statistics"),
no_landing_pads: bool = (false, parse_bool, [TRACKED],
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,8 @@ pub fn build_session_(
};
let target_cfg = config::build_target_config(&sopts, &span_diagnostic);

let p_s = parse::ParseSess::with_span_handler(span_diagnostic, codemap);
let mut p_s = parse::ParseSess::with_span_handler(span_diagnostic, codemap);
p_s.combine_tests = sopts.debugging_opts.combine_tests;
let default_sysroot = match sopts.maybe_sysroot {
Some(_) => None,
None => Some(filesearch::get_or_default_sysroot()),
Expand Down
21 changes: 20 additions & 1 deletion src/librustc_driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -847,12 +847,30 @@ pub fn phase_2_configure_and_expand_inner<'a, F>(sess: &'a Session,
});
}

if sess.opts.debugging_opts.ast_json_noexpand {
println!("\n\n\n\n\n\n\n\nPRE EXPAND:");
println!("{}", json::as_json(&krate));
}

krate = time(sess, "creating allocators", || {
allocator::expand::modify(&sess.parse_sess,
&mut resolver,
krate,
sess.diagnostic())
});
/*
if sess.opts.debugging_opts.submodules_crate_like {
krate = time(sess,
"Pretending submodules are crates",
|| rustc_passes::submodules_crate_like::modify_crate(krate));
eprintln!("expanded module");
}
*/
if sess.opts.debugging_opts.ast_json_noexpand {
println!("\n\n\n\n\n\n\n\nPOST EXPAND: {:#?}", krate);
println!("\n\n\n\n\n\n\n\nPOST EXPAND:");
println!("{}", json::as_json(&krate));
}

after_expand(&krate)?;

Expand Down Expand Up @@ -884,7 +902,8 @@ pub fn phase_2_configure_and_expand_inner<'a, F>(sess: &'a Session,
&sess.parse_sess,
&sess.features_untracked(),
&attributes,
sess.opts.unstable_features);
sess.opts.unstable_features,
sess.opts.debugging_opts.edition);
})
})?;

Expand Down
4 changes: 2 additions & 2 deletions src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -901,8 +901,8 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
}

if sess.opts.debugging_opts.parse_only ||
sess.opts.debugging_opts.show_span.is_some() ||
sess.opts.debugging_opts.ast_json_noexpand {
sess.opts.debugging_opts.show_span.is_some()/* ||
sess.opts.debugging_opts.ast_json_noexpand*/ {
control.after_parse.stop = Compilation::Stop;
}

Expand Down
1 change: 1 addition & 0 deletions src/librustdoc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ path = "lib.rs"
[dependencies]
pulldown-cmark = { version = "0.1.2", default-features = false }
tempdir = "0.3"
itertools = "0.7.6"
Loading