Browse Source

Merge pull request #248 from illicitonion/override-warnings

Add custom flags after -Wall
cl-test
Alex Crichton 7 years ago
committed by GitHub
parent
commit
3f11be75c9
  1. 12
      src/lib.rs
  2. 10
      tests/support/mod.rs
  3. 13
      tests/test.rs

12
src/lib.rs

@ -1093,6 +1093,12 @@ impl Build {
cmd.args.push(directory.into());
}
if self.warnings {
for flag in cmd.family.warnings_flags().iter() {
cmd.args.push(flag.into());
}
}
for flag in self.flags.iter() {
cmd.args.push(flag.into());
}
@ -1112,12 +1118,6 @@ impl Build {
}
}
if self.warnings {
for flag in cmd.family.warnings_flags().iter() {
cmd.args.push(flag.into());
}
}
if self.warnings_into_errors {
cmd.args.push(cmd.family.warnings_to_errors_flag().into());
}

10
tests/support/mod.rs

@ -109,4 +109,14 @@ impl Execution {
pub fn has(&self, p: &OsStr) -> bool {
self.args.iter().any(|arg| OsStr::new(arg) == p)
}
pub fn must_have_in_order(&self, before: &str, after: &str) -> &Execution {
let before_position = self.args.iter().rposition(|x| OsStr::new(x) == OsStr::new(before));
let after_position = self.args.iter().rposition(|x| OsStr::new(x) == OsStr::new(after));
match (before_position, after_position) {
(Some(b), Some(a)) if b < a => {},
(b, a) => { panic!("{:?} (last position: {:?}) did not appear before {:?} (last position: {:?})", before, b, after, a) },
};
self
}
}

13
tests/test.rs

@ -77,6 +77,7 @@ fn gnu_warnings() {
let test = Test::gnu();
test.gcc()
.warnings(true)
.flag("-Wno-missing-field-initializers")
.file("foo.c")
.compile("foo");
@ -84,6 +85,18 @@ fn gnu_warnings() {
.must_have("-Wextra");
}
#[test]
fn gnu_warnings_overridable() {
let test = Test::gnu();
test.gcc()
.warnings(true)
.flag("-Wno-missing-field-initializers")
.file("foo.c")
.compile("foo");
test.cmd(0).must_have_in_order("-Wall", "-Wno-missing-field-initializers");
}
#[test]
fn gnu_x86_64() {
for vendor in &["unknown-linux-gnu", "apple-darwin"] {

Loading…
Cancel
Save