summaryrefslogtreecommitdiff
path: root/cc/tests/test.rs
diff options
context:
space:
mode:
authorDaniel Mueller <deso@posteo.net>2018-12-10 21:02:04 -0800
committerDaniel Mueller <deso@posteo.net>2018-12-10 21:02:04 -0800
commit8898de1f97aff9965e1518ca5abb554275183a14 (patch)
treeac7deb92599ec56d67432766b2cf4cd63388833a /cc/tests/test.rs
parente2604a756aaddcd5919ee2f1b9cc0055d200f846 (diff)
downloadnitrocli-8898de1f97aff9965e1518ca5abb554275183a14.tar.gz
nitrocli-8898de1f97aff9965e1518ca5abb554275183a14.tar.bz2
Update cc crate to 1.0.25
This change updates the cc crate to version 1.0.25. Import subrepo cc/:cc at fe0a7acb6d3e22e03bf83bcbf89367be888b5448
Diffstat (limited to 'cc/tests/test.rs')
-rw-r--r--cc/tests/test.rs142
1 files changed, 76 insertions, 66 deletions
diff --git a/cc/tests/test.rs b/cc/tests/test.rs
index 7e5a28d..820072f 100644
--- a/cc/tests/test.rs
+++ b/cc/tests/test.rs
@@ -1,6 +1,7 @@
extern crate cc;
extern crate tempdir;
+use std::env;
use support::Test;
mod support;
@@ -8,9 +9,7 @@ mod support;
#[test]
fn gnu_smoke() {
let test = Test::gnu();
- test.gcc()
- .file("foo.c")
- .compile("foo");
+ test.gcc().file("foo.c").compile("foo");
test.cmd(0)
.must_have("-O2")
@@ -25,23 +24,15 @@ fn gnu_smoke() {
#[test]
fn gnu_opt_level_1() {
let test = Test::gnu();
- test.gcc()
- .opt_level(1)
- .file("foo.c")
- .compile("foo");
+ test.gcc().opt_level(1).file("foo.c").compile("foo");
- test.cmd(0)
- .must_have("-O1")
- .must_not_have("-O2");
+ test.cmd(0).must_have("-O1").must_not_have("-O2");
}
#[test]
fn gnu_opt_level_s() {
let test = Test::gnu();
- test.gcc()
- .opt_level_str("s")
- .file("foo.c")
- .compile("foo");
+ test.gcc().opt_level_str("s").file("foo.c").compile("foo");
test.cmd(0)
.must_have("-Os")
@@ -54,10 +45,7 @@ fn gnu_opt_level_s() {
#[test]
fn gnu_debug() {
let test = Test::gnu();
- test.gcc()
- .debug(true)
- .file("foo.c")
- .compile("foo");
+ test.gcc().debug(true).file("foo.c").compile("foo");
test.cmd(0).must_have("-g");
}
@@ -81,8 +69,33 @@ fn gnu_warnings() {
.file("foo.c")
.compile("foo");
- test.cmd(0).must_have("-Wall")
- .must_have("-Wextra");
+ test.cmd(0).must_have("-Wall").must_have("-Wextra");
+}
+
+#[test]
+fn gnu_extra_warnings0() {
+ let test = Test::gnu();
+ test.gcc()
+ .warnings(true)
+ .extra_warnings(false)
+ .flag("-Wno-missing-field-initializers")
+ .file("foo.c")
+ .compile("foo");
+
+ test.cmd(0).must_have("-Wall").must_not_have("-Wextra");
+}
+
+#[test]
+fn gnu_extra_warnings1() {
+ let test = Test::gnu();
+ test.gcc()
+ .warnings(false)
+ .extra_warnings(true)
+ .flag("-Wno-missing-field-initializers")
+ .file("foo.c")
+ .compile("foo");
+
+ test.cmd(0).must_not_have("-Wall").must_have("-Wextra");
}
#[test]
@@ -94,7 +107,32 @@ fn gnu_warnings_overridable() {
.file("foo.c")
.compile("foo");
- test.cmd(0).must_have_in_order("-Wall", "-Wno-missing-field-initializers");
+ test.cmd(0)
+ .must_have_in_order("-Wall", "-Wno-missing-field-initializers");
+}
+
+#[test]
+fn gnu_no_warnings_if_cflags() {
+ env::set_var("CFLAGS", "-Wflag-does-not-exist");
+ let test = Test::gnu();
+ test.gcc()
+ .file("foo.c")
+ .compile("foo");
+
+ test.cmd(0).must_not_have("-Wall").must_not_have("-Wextra");
+ env::set_var("CFLAGS", "");
+}
+
+#[test]
+fn gnu_no_warnings_if_cxxflags() {
+ env::set_var("CXXFLAGS", "-Wflag-does-not-exist");
+ let test = Test::gnu();
+ test.gcc()
+ .file("foo.c")
+ .compile("foo");
+
+ test.cmd(0).must_not_have("-Wall").must_not_have("-Wextra");
+ env::set_var("CXXFLAGS", "");
}
#[test]
@@ -108,9 +146,7 @@ fn gnu_x86_64() {
.file("foo.c")
.compile("foo");
- test.cmd(0)
- .must_have("-fPIC")
- .must_have("-m64");
+ test.cmd(0).must_have("-fPIC").must_have("-m64");
}
}
@@ -141,8 +177,7 @@ fn gnu_i686() {
.file("foo.c")
.compile("foo");
- test.cmd(0)
- .must_have("-m32");
+ test.cmd(0).must_have("-m32");
}
}
@@ -176,10 +211,7 @@ fn gnu_set_stdlib() {
#[test]
fn gnu_include() {
let test = Test::gnu();
- test.gcc()
- .include("foo/bar")
- .file("foo.c")
- .compile("foo");
+ test.gcc().include("foo/bar").file("foo.c").compile("foo");
test.cmd(0).must_have("-I").must_have("foo/bar");
}
@@ -199,9 +231,7 @@ fn gnu_define() {
#[test]
fn gnu_compile_assembly() {
let test = Test::gnu();
- test.gcc()
- .file("foo.S")
- .compile("foo");
+ test.gcc().file("foo.S").compile("foo");
test.cmd(0).must_have("foo.S");
}
@@ -214,25 +244,25 @@ fn gnu_shared() {
.static_flag(false)
.compile("foo");
- test.cmd(0)
- .must_have("-shared")
- .must_not_have("-static");
+ test.cmd(0).must_have("-shared").must_not_have("-static");
}
#[test]
fn gnu_flag_if_supported() {
if cfg!(windows) {
- return
+ return;
}
let test = Test::gnu();
test.gcc()
.file("foo.c")
+ .flag("-v")
.flag_if_supported("-Wall")
.flag_if_supported("-Wflag-does-not-exist")
.flag_if_supported("-std=c++11")
.compile("foo");
test.cmd(0)
+ .must_have("-v")
.must_have("-Wall")
.must_not_have("-Wflag-does-not-exist")
.must_not_have("-std=c++11");
@@ -241,7 +271,7 @@ fn gnu_flag_if_supported() {
#[test]
fn gnu_flag_if_supported_cpp() {
if cfg!(windows) {
- return
+ return;
}
let test = Test::gnu();
test.gcc()
@@ -250,8 +280,7 @@ fn gnu_flag_if_supported_cpp() {
.flag_if_supported("-std=c++11")
.compile("foo");
- test.cmd(0)
- .must_have("-std=c++11");
+ test.cmd(0).must_have("-std=c++11");
}
#[test]
@@ -263,17 +292,13 @@ fn gnu_static() {
.static_flag(true)
.compile("foo");
- test.cmd(0)
- .must_have("-static")
- .must_not_have("-shared");
+ test.cmd(0).must_have("-static").must_not_have("-shared");
}
#[test]
fn msvc_smoke() {
let test = Test::msvc();
- test.gcc()
- .file("foo.c")
- .compile("foo");
+ test.gcc().file("foo.c").compile("foo");
test.cmd(0)
.must_have("/O2")
@@ -287,10 +312,7 @@ fn msvc_smoke() {
#[test]
fn msvc_opt_level_0() {
let test = Test::msvc();
- test.gcc()
- .opt_level(0)
- .file("foo.c")
- .compile("foo");
+ test.gcc().opt_level(0).file("foo.c").compile("foo");
test.cmd(0).must_not_have("/O2");
}
@@ -298,20 +320,14 @@ fn msvc_opt_level_0() {
#[test]
fn msvc_debug() {
let test = Test::msvc();
- test.gcc()
- .debug(true)
- .file("foo.c")
- .compile("foo");
+ test.gcc().debug(true).file("foo.c").compile("foo");
test.cmd(0).must_have("/Z7");
}
#[test]
fn msvc_include() {
let test = Test::msvc();
- test.gcc()
- .include("foo/bar")
- .file("foo.c")
- .compile("foo");
+ test.gcc().include("foo/bar").file("foo.c").compile("foo");
test.cmd(0).must_have("/I").must_have("foo/bar");
}
@@ -331,10 +347,7 @@ fn msvc_define() {
#[test]
fn msvc_static_crt() {
let test = Test::msvc();
- test.gcc()
- .static_crt(true)
- .file("foo.c")
- .compile("foo");
+ test.gcc().static_crt(true).file("foo.c").compile("foo");
test.cmd(0).must_have("/MT");
}
@@ -342,10 +355,7 @@ fn msvc_static_crt() {
#[test]
fn msvc_no_static_crt() {
let test = Test::msvc();
- test.gcc()
- .static_crt(false)
- .file("foo.c")
- .compile("foo");
+ test.gcc().static_crt(false).file("foo.c").compile("foo");
test.cmd(0).must_have("/MD");
}