Skip to content

Commit 1516087

Browse files
committed
add negative tests for OS X LLVM target changes
1 parent 758dc9a commit 1516087

File tree

4 files changed

+63
-0
lines changed

4 files changed

+63
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//
2+
// Checks that we leave the target alone MACOSX_DEPLOYMENT_TARGET is unset.
3+
// See issue #60235.
4+
5+
// compile-flags: -O --target=i686-apple-darwin --crate-type=rlib
6+
// unset-rustc-env:MACOSX_DEPLOYMENT_TARGET
7+
#![feature(no_core, lang_items)]
8+
#![no_core]
9+
10+
#[lang="sized"]
11+
trait Sized { }
12+
#[lang="freeze"]
13+
trait Freeze { }
14+
#[lang="copy"]
15+
trait Copy { }
16+
17+
#[repr(C)]
18+
pub struct Bool {
19+
b: bool,
20+
}
21+
22+
// CHECK: target triple = "i686-apple-darwin"
23+
#[no_mangle]
24+
pub extern "C" fn structbool() -> Bool {
25+
Bool { b: true }
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//
2+
// Checks that we leave the target alone when MACOSX_DEPLOYMENT_TARGET is unset.
3+
// See issue #60235.
4+
5+
// compile-flags: -O --target=x86_64-apple-darwin --crate-type=rlib
6+
// unset-rustc-env:MACOSX_DEPLOYMENT_TARGET
7+
#![feature(no_core, lang_items)]
8+
#![no_core]
9+
10+
#[lang="sized"]
11+
trait Sized { }
12+
#[lang="freeze"]
13+
trait Freeze { }
14+
#[lang="copy"]
15+
trait Copy { }
16+
17+
#[repr(C)]
18+
pub struct Bool {
19+
b: bool,
20+
}
21+
22+
// CHECK: target triple = "x86_64-apple-darwin"
23+
#[no_mangle]
24+
pub extern "C" fn structbool() -> Bool {
25+
Bool { b: true }
26+
}

src/tools/compiletest/src/header.rs

+8
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,9 @@ pub struct TestProps {
305305
pub extern_private: Vec<String>,
306306
// Environment settings to use for compiling
307307
pub rustc_env: Vec<(String, String)>,
308+
// Environment variables to unset prior to compiling.
309+
// Variables are unset before applying 'rustc_env'.
310+
pub unset_rustc_env: Vec<String>,
308311
// Environment settings to use during execution
309312
pub exec_env: Vec<(String, String)>,
310313
// Lines to check if they appear in the expected debugger output
@@ -373,6 +376,7 @@ impl TestProps {
373376
extern_private: vec![],
374377
revisions: vec![],
375378
rustc_env: vec![],
379+
unset_rustc_env: vec![],
376380
exec_env: vec![],
377381
check_lines: vec![],
378382
build_aux_docs: false,
@@ -499,6 +503,10 @@ impl TestProps {
499503
self.rustc_env.push(ee);
500504
}
501505

506+
if let Some(ev) = config.parse_name_value_directive(ln, "unset-rustc-env") {
507+
self.unset_rustc_env.push(ev);
508+
}
509+
502510
if let Some(cl) = config.parse_check_line(ln) {
503511
self.check_lines.push(cl);
504512
}

src/tools/compiletest/src/runtest.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1692,6 +1692,9 @@ impl<'test> TestCx<'test> {
16921692
add_extern_priv(&private_lib, true);
16931693
}
16941694

1695+
self.props.unset_rustc_env.clone()
1696+
.iter()
1697+
.fold(&mut rustc, |rustc, v| rustc.env_remove(v));
16951698
rustc.envs(self.props.rustc_env.clone());
16961699
self.compose_and_run(
16971700
rustc,

0 commit comments

Comments
 (0)