-
Notifications
You must be signed in to change notification settings - Fork 479
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Always read from all
CFLAGS
-style flags (#1401)
- Loading branch information
Showing
3 changed files
with
110 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,39 @@ | ||
//! This test is in its own module because it modifies the environment and would affect other tests | ||
//! when run in parallel with them. | ||
mod support; | ||
|
||
use crate::support::Test; | ||
use std::env; | ||
|
||
/// This test is in its own module because it modifies the environment and would affect other tests | ||
/// when run in parallel with them. | ||
#[test] | ||
fn cflags() { | ||
gnu_no_warnings_if_cflags(); | ||
cflags_order(); | ||
} | ||
|
||
fn gnu_no_warnings_if_cflags() { | ||
env::set_var("CFLAGS", "-arbitrary"); | ||
let test = Test::gnu(); | ||
test.gcc().file("foo.c").compile("foo"); | ||
|
||
test.cmd(0).must_not_have("-Wall").must_not_have("-Wextra"); | ||
} | ||
|
||
/// Test the ordering of `CFLAGS*` variables. | ||
fn cflags_order() { | ||
unsafe { env::set_var("CFLAGS", "-arbitrary1") }; | ||
unsafe { env::set_var("HOST_CFLAGS", "-arbitrary2") }; | ||
unsafe { env::set_var("TARGET_CFLAGS", "-arbitrary2") }; | ||
unsafe { env::set_var("CFLAGS_x86_64_unknown_none", "-arbitrary3") }; | ||
unsafe { env::set_var("CFLAGS_x86_64-unknown-none", "-arbitrary4") }; | ||
let test = Test::gnu(); | ||
test.gcc() | ||
.target("x86_64-unknown-none") | ||
.file("foo.c") | ||
.compile("foo"); | ||
|
||
test.cmd(0) | ||
.must_have_in_order("-arbitrary1", "-arbitrary2") | ||
.must_have_in_order("-arbitrary2", "-arbitrary3") | ||
.must_have_in_order("-arbitrary3", "-arbitrary4"); | ||
} |