Skip to content

Commit 91e9073

Browse files
committed
Auto merge of #33625 - alexcrichton:rustbuild-moar-tests, r=aturon
rustbuild: Touch up some test suites This adds in some missing test suites, primarily a few pretty suites. It also starts optimizing tests by default as the current test suite does, but also recognizes `--disable-optimize-tests`. Currently the optimization of tests isn't recognized by crate tests because Cargo doesn't support the ability to compile an unoptimized test suite against an optimized library. Perhaps a feature to add, though!
2 parents 500e5c1 + 5f295f2 commit 91e9073

File tree

11 files changed

+225
-67
lines changed

11 files changed

+225
-67
lines changed

src/bootstrap/build/check.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,18 @@ pub fn compiletest(build: &Build,
105105
cmd.arg("--host").arg(compiler.host);
106106
cmd.arg("--llvm-filecheck").arg(build.llvm_filecheck(&build.config.build));
107107

108+
let mut flags = format!("-Crpath");
109+
if build.config.rust_optimize_tests {
110+
flags.push_str(" -O");
111+
}
112+
if build.config.rust_debuginfo_tests {
113+
flags.push_str(" -g");
114+
}
115+
116+
cmd.arg("--host-rustcflags").arg(&flags);
117+
108118
let linkflag = format!("-Lnative={}", build.test_helpers_out(target).display());
109-
cmd.arg("--host-rustcflags").arg("-Crpath");
110-
cmd.arg("--target-rustcflags").arg(format!("-Crpath {}", linkflag));
119+
cmd.arg("--target-rustcflags").arg(format!("{} {}", flags, linkflag));
111120

112121
// FIXME: needs android support
113122
cmd.arg("--android-cross-path").arg("");

src/bootstrap/build/config.rs

+9
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ pub struct Config {
5959
pub rust_rpath: bool,
6060
pub rustc_default_linker: Option<String>,
6161
pub rustc_default_ar: Option<String>,
62+
pub rust_optimize_tests: bool,
63+
pub rust_debuginfo_tests: bool,
6264

6365
pub build: String,
6466
pub host: Vec<String>,
@@ -136,6 +138,8 @@ struct Rust {
136138
channel: Option<String>,
137139
musl_root: Option<String>,
138140
rpath: Option<bool>,
141+
optimize_tests: Option<bool>,
142+
debuginfo_tests: Option<bool>,
139143
}
140144

141145
/// TOML representation of how each build target is configured.
@@ -154,6 +158,7 @@ impl Config {
154158
config.llvm_optimize = true;
155159
config.use_jemalloc = true;
156160
config.rust_optimize = true;
161+
config.rust_optimize_tests = true;
157162
config.submodules = true;
158163
config.docs = true;
159164
config.rust_rpath = true;
@@ -219,6 +224,8 @@ impl Config {
219224
set(&mut config.rust_debug_assertions, rust.debug_assertions);
220225
set(&mut config.rust_debuginfo, rust.debuginfo);
221226
set(&mut config.rust_optimize, rust.optimize);
227+
set(&mut config.rust_optimize_tests, rust.optimize_tests);
228+
set(&mut config.rust_debuginfo_tests, rust.debuginfo_tests);
222229
set(&mut config.rust_rpath, rust.rpath);
223230
set(&mut config.debug_jemalloc, rust.debug_jemalloc);
224231
set(&mut config.use_jemalloc, rust.use_jemalloc);
@@ -306,6 +313,8 @@ impl Config {
306313
("JEMALLOC", self.use_jemalloc),
307314
("DEBUG_JEMALLOC", self.debug_jemalloc),
308315
("RPATH", self.rust_rpath),
316+
("OPTIMIZE_TESTS", self.rust_optimize_tests),
317+
("DEBUGINFO_TESTS", self.rust_debuginfo_tests),
309318
}
310319

311320
match key {

src/bootstrap/build/mod.rs

+32-8
Original file line numberDiff line numberDiff line change
@@ -318,10 +318,18 @@ impl Build {
318318
check::compiletest(self, &compiler, target.target,
319319
"run-pass", "run-pass");
320320
}
321+
CheckRPassFull { compiler } => {
322+
check::compiletest(self, &compiler, target.target,
323+
"run-pass", "run-pass-fulldeps");
324+
}
321325
CheckCFail { compiler } => {
322326
check::compiletest(self, &compiler, target.target,
323327
"compile-fail", "compile-fail");
324328
}
329+
CheckCFailFull { compiler } => {
330+
check::compiletest(self, &compiler, target.target,
331+
"compile-fail", "compile-fail-fulldeps")
332+
}
325333
CheckPFail { compiler } => {
326334
check::compiletest(self, &compiler, target.target,
327335
"parse-fail", "parse-fail");
@@ -330,10 +338,34 @@ impl Build {
330338
check::compiletest(self, &compiler, target.target,
331339
"run-fail", "run-fail");
332340
}
341+
CheckRFailFull { compiler } => {
342+
check::compiletest(self, &compiler, target.target,
343+
"run-fail", "run-fail-fulldeps");
344+
}
333345
CheckPretty { compiler } => {
334346
check::compiletest(self, &compiler, target.target,
335347
"pretty", "pretty");
336348
}
349+
CheckPrettyRPass { compiler } => {
350+
check::compiletest(self, &compiler, target.target,
351+
"pretty", "run-pass");
352+
}
353+
CheckPrettyRPassFull { compiler } => {
354+
check::compiletest(self, &compiler, target.target,
355+
"pretty", "run-pass-fulldeps");
356+
}
357+
CheckPrettyRFail { compiler } => {
358+
check::compiletest(self, &compiler, target.target,
359+
"pretty", "run-fail");
360+
}
361+
CheckPrettyRFailFull { compiler } => {
362+
check::compiletest(self, &compiler, target.target,
363+
"pretty", "run-fail-fulldeps");
364+
}
365+
CheckPrettyRPassValgrind { compiler } => {
366+
check::compiletest(self, &compiler, target.target,
367+
"pretty", "run-pass-valgrind");
368+
}
337369
CheckCodegen { compiler } => {
338370
check::compiletest(self, &compiler, target.target,
339371
"codegen", "codegen");
@@ -370,14 +402,6 @@ impl Build {
370402
check::compiletest(self, &compiler, target.target,
371403
"run-pass-valgrind", "run-pass-valgrind");
372404
}
373-
CheckRPassFull { compiler } => {
374-
check::compiletest(self, &compiler, target.target,
375-
"run-pass", "run-pass-fulldeps");
376-
}
377-
CheckCFailFull { compiler } => {
378-
check::compiletest(self, &compiler, target.target,
379-
"compile-fail", "compile-fail-fulldeps")
380-
}
381405
CheckDocs { compiler } => {
382406
check::docs(self, &compiler);
383407
}

src/bootstrap/build/step.rs

+25-7
Original file line numberDiff line numberDiff line change
@@ -106,19 +106,25 @@ macro_rules! targets {
106106
(check_cargotest, CheckCargoTest { stage: u32 }),
107107
(check_tidy, CheckTidy { stage: u32 }),
108108
(check_rpass, CheckRPass { compiler: Compiler<'a> }),
109+
(check_rpass_full, CheckRPassFull { compiler: Compiler<'a> }),
110+
(check_rpass_valgrind, CheckRPassValgrind { compiler: Compiler<'a> }),
109111
(check_rfail, CheckRFail { compiler: Compiler<'a> }),
112+
(check_rfail_full, CheckRFailFull { compiler: Compiler<'a> }),
110113
(check_cfail, CheckCFail { compiler: Compiler<'a> }),
114+
(check_cfail_full, CheckCFailFull { compiler: Compiler<'a> }),
111115
(check_pfail, CheckPFail { compiler: Compiler<'a> }),
116+
(check_pretty, CheckPretty { compiler: Compiler<'a> }),
117+
(check_pretty_rpass, CheckPrettyRPass { compiler: Compiler<'a> }),
118+
(check_pretty_rpass_full, CheckPrettyRPassFull { compiler: Compiler<'a> }),
119+
(check_pretty_rfail, CheckPrettyRFail { compiler: Compiler<'a> }),
120+
(check_pretty_rfail_full, CheckPrettyRFailFull { compiler: Compiler<'a> }),
121+
(check_pretty_rpass_valgrind, CheckPrettyRPassValgrind { compiler: Compiler<'a> }),
112122
(check_codegen, CheckCodegen { compiler: Compiler<'a> }),
113123
(check_codegen_units, CheckCodegenUnits { compiler: Compiler<'a> }),
114124
(check_incremental, CheckIncremental { compiler: Compiler<'a> }),
115125
(check_ui, CheckUi { compiler: Compiler<'a> }),
116126
(check_debuginfo, CheckDebuginfo { compiler: Compiler<'a> }),
117127
(check_rustdoc, CheckRustdoc { compiler: Compiler<'a> }),
118-
(check_pretty, CheckPretty { compiler: Compiler<'a> }),
119-
(check_rpass_valgrind, CheckRPassValgrind { compiler: Compiler<'a> }),
120-
(check_rpass_full, CheckRPassFull { compiler: Compiler<'a> }),
121-
(check_cfail_full, CheckCFailFull { compiler: Compiler<'a> }),
122128
(check_docs, CheckDocs { compiler: Compiler<'a> }),
123129
(check_error_index, CheckErrorIndex { compiler: Compiler<'a> }),
124130
(check_rmake, CheckRMake { compiler: Compiler<'a> }),
@@ -378,8 +384,11 @@ impl<'a> Step<'a> {
378384
Source::Check { stage, compiler } => {
379385
vec![
380386
self.check_rpass(compiler),
381-
self.check_cfail(compiler),
387+
self.check_rpass_full(compiler),
382388
self.check_rfail(compiler),
389+
self.check_rfail_full(compiler),
390+
self.check_cfail(compiler),
391+
self.check_cfail_full(compiler),
383392
self.check_pfail(compiler),
384393
self.check_incremental(compiler),
385394
self.check_ui(compiler),
@@ -391,9 +400,12 @@ impl<'a> Step<'a> {
391400
self.check_debuginfo(compiler),
392401
self.check_rustdoc(compiler),
393402
self.check_pretty(compiler),
403+
self.check_pretty_rpass(compiler),
404+
self.check_pretty_rpass_full(compiler),
405+
self.check_pretty_rfail(compiler),
406+
self.check_pretty_rfail_full(compiler),
407+
self.check_pretty_rpass_valgrind(compiler),
394408
self.check_rpass_valgrind(compiler),
395-
self.check_rpass_full(compiler),
396-
self.check_cfail_full(compiler),
397409
self.check_error_index(compiler),
398410
self.check_docs(compiler),
399411
self.check_rmake(compiler),
@@ -412,6 +424,8 @@ impl<'a> Step<'a> {
412424
Source::CheckTidy { stage } => {
413425
vec![self.tool_tidy(stage)]
414426
}
427+
Source::CheckPrettyRPass { compiler } |
428+
Source::CheckPrettyRFail { compiler } |
415429
Source::CheckRFail { compiler } |
416430
Source::CheckPFail { compiler } |
417431
Source::CheckCodegen { compiler } |
@@ -438,7 +452,11 @@ impl<'a> Step<'a> {
438452
]
439453
}
440454
Source::CheckRPassFull { compiler } |
455+
Source::CheckRFailFull { compiler } |
441456
Source::CheckCFailFull { compiler } |
457+
Source::CheckPrettyRPassFull { compiler } |
458+
Source::CheckPrettyRFailFull { compiler } |
459+
Source::CheckPrettyRPassValgrind { compiler } |
442460
Source::CheckRMake { compiler } => {
443461
vec![self.librustc(compiler),
444462
self.tool_compiletest(compiler.stage)]

src/bootstrap/config.toml.example

+5
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@
122122
# desired in distributions, for example.
123123
#rpath = true
124124

125+
# Flag indicating whether tests are compiled with optimizations (the -O flag) or
126+
# with debuginfo (the -g flag)
127+
#optimize-tests = true
128+
#debuginfo-tests = true
129+
125130
# =============================================================================
126131
# Options for specific targets
127132
#

src/librustc_bitflags/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@ version = "0.0.0"
66
[lib]
77
name = "rustc_bitflags"
88
path = "lib.rs"
9-
test = false
109
doctest = false

0 commit comments

Comments
 (0)