Skip to content

Commit 134dc33

Browse files
committed
Fix testing with unstable features disabled
1 parent 72e67c8 commit 134dc33

File tree

3 files changed

+44
-9
lines changed

3 files changed

+44
-9
lines changed

build_system/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ pub(crate) fn main() {
196196
&dirs,
197197
channel,
198198
sysroot_kind,
199+
use_unstable_features,
199200
&cg_clif_dylib,
200201
&bootstrap_host_compiler,
201202
rustup_toolchain_name.as_deref(),

build_system/tests.rs

+29-5
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ pub(crate) fn run_tests(
214214
dirs: &Dirs,
215215
channel: &str,
216216
sysroot_kind: SysrootKind,
217+
use_unstable_features: bool,
217218
cg_clif_dylib: &CodegenBackend,
218219
bootstrap_host_compiler: &Compiler,
219220
rustup_toolchain_name: Option<&str>,
@@ -233,6 +234,7 @@ pub(crate) fn run_tests(
233234
let runner = TestRunner::new(
234235
dirs.clone(),
235236
target_compiler,
237+
use_unstable_features,
236238
bootstrap_host_compiler.triple == target_triple,
237239
);
238240

@@ -262,6 +264,7 @@ pub(crate) fn run_tests(
262264
let runner = TestRunner::new(
263265
dirs.clone(),
264266
target_compiler,
267+
use_unstable_features,
265268
bootstrap_host_compiler.triple == target_triple,
266269
);
267270

@@ -282,12 +285,18 @@ pub(crate) fn run_tests(
282285
struct TestRunner {
283286
is_native: bool,
284287
jit_supported: bool,
288+
use_unstable_features: bool,
285289
dirs: Dirs,
286290
target_compiler: Compiler,
287291
}
288292

289293
impl TestRunner {
290-
fn new(dirs: Dirs, mut target_compiler: Compiler, is_native: bool) -> Self {
294+
fn new(
295+
dirs: Dirs,
296+
mut target_compiler: Compiler,
297+
use_unstable_features: bool,
298+
is_native: bool,
299+
) -> Self {
291300
if let Ok(rustflags) = env::var("RUSTFLAGS") {
292301
target_compiler.rustflags.push(' ');
293302
target_compiler.rustflags.push_str(&rustflags);
@@ -302,11 +311,12 @@ impl TestRunner {
302311
target_compiler.rustflags.push_str(" -Clink-arg=-undefined -Clink-arg=dynamic_lookup");
303312
}
304313

305-
let jit_supported = is_native
314+
let jit_supported = use_unstable_features
315+
&& is_native
306316
&& target_compiler.triple.contains("x86_64")
307317
&& !target_compiler.triple.contains("windows");
308318

309-
Self { is_native, jit_supported, dirs, target_compiler }
319+
Self { is_native, jit_supported, use_unstable_features, dirs, target_compiler }
310320
}
311321

312322
fn run_testsuite(&self, tests: &[TestCase]) {
@@ -325,10 +335,24 @@ impl TestRunner {
325335
match *cmd {
326336
TestCaseCmd::Custom { func } => func(self),
327337
TestCaseCmd::BuildLib { source, crate_types } => {
328-
self.run_rustc([source, "--crate-type", crate_types]);
338+
if self.use_unstable_features {
339+
self.run_rustc([source, "--crate-type", crate_types]);
340+
} else {
341+
self.run_rustc([
342+
source,
343+
"--crate-type",
344+
crate_types,
345+
"--cfg",
346+
"no_unstable_features",
347+
]);
348+
}
329349
}
330350
TestCaseCmd::BuildBinAndRun { source, args } => {
331-
self.run_rustc([source]);
351+
if self.use_unstable_features {
352+
self.run_rustc([source]);
353+
} else {
354+
self.run_rustc([source, "--cfg", "no_unstable_features"]);
355+
}
332356
self.run_out_command(
333357
source.split('/').last().unwrap().split('.').next().unwrap(),
334358
args,

example/mini_core_hello_world.rs

+14-4
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,12 @@ 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(
326+
not(jit),
327+
not(no_unstable_features),
328+
target_arch = "x86_64",
329+
any(target_os = "linux", target_os = "darwin")
330+
))]
326331
unsafe {
327332
global_asm_test();
328333
}
@@ -350,12 +355,17 @@ fn main() {
350355
let _a = f.0[0];
351356
}
352357

353-
#[cfg(all(not(jit), target_arch = "x86_64", any(target_os = "linux", target_os = "darwin")))]
358+
#[cfg(all(
359+
not(jit),
360+
not(no_unstable_features),
361+
target_arch = "x86_64",
362+
any(target_os = "linux", target_os = "darwin")
363+
))]
354364
extern "C" {
355365
fn global_asm_test();
356366
}
357367

358-
#[cfg(all(not(jit), target_arch = "x86_64", target_os = "linux"))]
368+
#[cfg(all(not(jit), not(no_unstable_features), target_arch = "x86_64", target_os = "linux"))]
359369
global_asm! {
360370
"
361371
.global global_asm_test
@@ -365,7 +375,7 @@ global_asm! {
365375
"
366376
}
367377

368-
#[cfg(all(not(jit), target_arch = "x86_64", target_os = "darwin"))]
378+
#[cfg(all(not(jit), not(no_unstable_features), target_arch = "x86_64", target_os = "darwin"))]
369379
global_asm! {
370380
"
371381
.global _global_asm_test

0 commit comments

Comments
 (0)