]> git.proxmox.com Git - rustc.git/blobdiff - src/vendor/cc/tests/cc_env.rs
New upstream version 1.26.0+dfsg1
[rustc.git] / src / vendor / cc / tests / cc_env.rs
index 8ffe651a6655ba382e88b94539cd824f1d1bcd53..f9386d7f59b5cf8d3775c088c2a5a132d6f4db5b 100644 (file)
@@ -14,6 +14,10 @@ fn main() {
     distcc();
     ccache_spaces();
     ccache_env_flags();
+    leading_spaces();
+    extra_flags();
+    path_to_ccache();
+    more_spaces();
 }
 
 fn ccache() {
@@ -71,3 +75,45 @@ fn ccache_env_flags() {
 
     env::set_var("CC", "");
 }
+
+fn leading_spaces() {
+    let test = Test::gnu();
+    test.shim("ccache");
+
+    env::set_var("CC", " test ");
+    let compiler = test.gcc().file("foo.c").get_compiler();
+    assert_eq!(compiler.path(), Path::new("test"));
+
+    env::set_var("CC", "");
+}
+
+fn extra_flags() {
+    let test = Test::gnu();
+    test.shim("ccache");
+
+    env::set_var("CC", "ccache cc -m32");
+    let compiler = test.gcc().file("foo.c").get_compiler();
+    assert_eq!(compiler.path(), Path::new("cc"));
+}
+
+fn path_to_ccache() {
+    let test = Test::gnu();
+    test.shim("ccache");
+
+    env::set_var("CC", "/path/to/ccache.exe cc -m32");
+    let compiler = test.gcc().file("foo.c").get_compiler();
+    assert_eq!(compiler.path(), Path::new("cc"));
+    assert_eq!(
+        compiler.cc_env(),
+        OsString::from("/path/to/ccache.exe cc -m32"),
+    );
+}
+
+fn more_spaces() {
+    let test = Test::gnu();
+    test.shim("ccache");
+
+    env::set_var("CC", "cc -m32");
+    let compiler = test.gcc().file("foo.c").get_compiler();
+    assert_eq!(compiler.path(), Path::new("cc"));
+}