Skip to content

Commit 8b86a80

Browse files
committed
Fix testing with unstable features disabled
1 parent 7045352 commit 8b86a80

File tree

3 files changed

+34
-9
lines changed

3 files changed

+34
-9
lines changed

build_system/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ pub(crate) fn main() {
168168
&dirs,
169169
channel,
170170
sysroot_kind,
171+
use_unstable_features,
171172
&cg_clif_dylib,
172173
&bootstrap_host_compiler,
173174
target_triple.clone(),

build_system/tests.rs

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ pub(crate) fn run_tests(
215215
dirs: &Dirs,
216216
channel: &str,
217217
sysroot_kind: SysrootKind,
218+
use_unstable_features: bool,
218219
cg_clif_dylib: &Path,
219220
bootstrap_host_compiler: &Compiler,
220221
target_triple: String,
@@ -232,6 +233,7 @@ pub(crate) fn run_tests(
232233
let runner = TestRunner::new(
233234
dirs.clone(),
234235
target_compiler,
236+
use_unstable_features,
235237
bootstrap_host_compiler.triple == target_triple,
236238
);
237239

@@ -260,6 +262,7 @@ pub(crate) fn run_tests(
260262
let runner = TestRunner::new(
261263
dirs.clone(),
262264
target_compiler,
265+
use_unstable_features,
263266
bootstrap_host_compiler.triple == target_triple,
264267
);
265268

@@ -280,12 +283,18 @@ pub(crate) fn run_tests(
280283
struct TestRunner {
281284
is_native: bool,
282285
jit_supported: bool,
286+
use_unstable_features: bool,
283287
dirs: Dirs,
284288
target_compiler: Compiler,
285289
}
286290

287291
impl TestRunner {
288-
fn new(dirs: Dirs, mut target_compiler: Compiler, is_native: bool) -> Self {
292+
fn new(
293+
dirs: Dirs,
294+
mut target_compiler: Compiler,
295+
use_unstable_features: bool,
296+
is_native: bool,
297+
) -> Self {
289298
if let Ok(rustflags) = env::var("RUSTFLAGS") {
290299
target_compiler.rustflags.push(' ');
291300
target_compiler.rustflags.push_str(&rustflags);
@@ -300,11 +309,12 @@ impl TestRunner {
300309
target_compiler.rustflags.push_str(" -Clink-arg=-undefined -Clink-arg=dynamic_lookup");
301310
}
302311

303-
let jit_supported = is_native
312+
let jit_supported = use_unstable_features
313+
&& is_native
304314
&& target_compiler.triple.contains("x86_64")
305315
&& !target_compiler.triple.contains("windows");
306316

307-
Self { is_native, jit_supported, dirs, target_compiler }
317+
Self { is_native, jit_supported, use_unstable_features, dirs, target_compiler }
308318
}
309319

310320
fn run_testsuite(&self, tests: &[TestCase]) {
@@ -323,10 +333,24 @@ impl TestRunner {
323333
match *cmd {
324334
TestCaseCmd::Custom { func } => func(self),
325335
TestCaseCmd::BuildLib { source, crate_types } => {
326-
self.run_rustc([source, "--crate-type", crate_types]);
336+
if self.use_unstable_features {
337+
self.run_rustc([source, "--crate-type", crate_types]);
338+
} else {
339+
self.run_rustc([
340+
source,
341+
"--crate-type",
342+
crate_types,
343+
"--cfg",
344+
"no_unstable_features",
345+
]);
346+
}
327347
}
328348
TestCaseCmd::BuildBinAndRun { source, args } => {
329-
self.run_rustc([source]);
349+
if self.use_unstable_features {
350+
self.run_rustc([source]);
351+
} else {
352+
self.run_rustc([source, "--cfg", "no_unstable_features"]);
353+
}
330354
self.run_out_command(
331355
source.split('/').last().unwrap().split('.').next().unwrap(),
332356
args,

example/mini_core_hello_world.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ fn main() {
322322
#[cfg(all(not(jit), not(all(windows, target_env = "gnu"))))]
323323
test_tls();
324324

325-
#[cfg(all(not(jit), target_arch = "x86_64", any(target_os = "linux", target_os = "darwin")))]
325+
#[cfg(all(not(jit), not(no_unstable_features), target_arch = "x86_64", any(target_os = "linux", target_os = "darwin")))]
326326
unsafe {
327327
global_asm_test();
328328
}
@@ -350,12 +350,12 @@ fn main() {
350350
let _a = f.0[0];
351351
}
352352

353-
#[cfg(all(not(jit), target_arch = "x86_64", any(target_os = "linux", target_os = "darwin")))]
353+
#[cfg(all(not(jit), not(no_unstable_features), target_arch = "x86_64", any(target_os = "linux", target_os = "darwin")))]
354354
extern "C" {
355355
fn global_asm_test();
356356
}
357357

358-
#[cfg(all(not(jit), target_arch = "x86_64", target_os = "linux"))]
358+
#[cfg(all(not(jit), not(no_unstable_features), target_arch = "x86_64", target_os = "linux"))]
359359
global_asm! {
360360
"
361361
.global global_asm_test
@@ -365,7 +365,7 @@ global_asm! {
365365
"
366366
}
367367

368-
#[cfg(all(not(jit), target_arch = "x86_64", target_os = "darwin"))]
368+
#[cfg(all(not(jit), not(no_unstable_features), target_arch = "x86_64", target_os = "darwin"))]
369369
global_asm! {
370370
"
371371
.global _global_asm_test

0 commit comments

Comments
 (0)