]> git.lizzy.rs Git - rust.git/commitdiff
Add fullmir tests
authorOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Wed, 21 Jun 2017 06:55:32 +0000 (08:55 +0200)
committerOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Wed, 21 Jun 2017 06:57:17 +0000 (08:57 +0200)
.travis.yml
tests/compiletest.rs
tests/run-pass-fullmir/loop-break-value.rs [new file with mode: 0644]
tests/run-pass/loop-break-value.rs [deleted file]

index 5a2a893196dc3cfe1e788160c93ac65b090a92e9..5bc7f291d7629e01389b38d93647c0b30f7e7e4c 100644 (file)
@@ -10,6 +10,11 @@ before_script:
 - cargo install xargo
 - export RUST_SYSROOT=$HOME/rust
 script:
+- |
+  # get ourselves a MIR-ful libstd
+  cd xargo &&
+  RUSTFLAGS='-Zalways-encode-mir' xargo build &&
+  cd ..
 - |
   # Test plain miri
   cargo build &&
@@ -22,11 +27,7 @@ script:
   cargo miri test &&
   cd ..
 - |
-  # get ourselves a MIR-ful libstd
-  cd xargo &&
-  RUSTFLAGS='-Zalways-encode-mir' xargo build &&
-  cd .. &&
-  # and run the tests with it
+  # and run all tests with full mir
   MIRI_SYSROOT=~/.xargo/HOST cargo test
 notifications:
   email:
index e6535ef0212b544418834d738dc092d79f6a1047..fe9cbd64790631ac64caa95a3d42ae2217b5f772 100644 (file)
@@ -27,13 +27,17 @@ fn run_pass() {
     compiletest::run_tests(&config);
 }
 
-fn miri_pass(path: &str, target: &str, host: &str) {
+fn miri_pass(path: &str, target: &str, host: &str, fullmir: bool) {
     let mut config = compiletest::default_config();
     config.mode = "mir-opt".parse().expect("Invalid mode");
     config.src_base = PathBuf::from(path);
     config.target = target.to_owned();
     config.host = host.to_owned();
     config.rustc_path = PathBuf::from("target/debug/miri");
+    if fullmir {
+        let sysroot = Path::new(&std::env::var("HOME").unwrap()).join(".xargo").join("HOST");
+        config.target_rustcflags = Some(format!("--sysroot {}", sysroot.to_str().unwrap()));
+    }
     // don't actually execute the final binary, it might be for other targets and we only care
     // about running miri, not the binary.
     config.runtool = Some("echo \"\" || ".to_owned());
@@ -116,6 +120,7 @@ fn compile_test() {
             let sysroot = libs.join("rustlib").join(&host).join("lib");
             let paths = std::env::join_paths(&[libs, sysroot]).unwrap();
             cmd.env(compiletest::procsrv::dylib_env_var(), paths);
+            cmd.env("MIRI_SYSROOT", Path::new(&std::env::var("HOME").unwrap()).join(".xargo").join("HOST"));
 
             match cmd.output() {
                 Ok(ref output) if output.status.success() => {
@@ -197,8 +202,9 @@ fn compile_test() {
     } else {
         run_pass();
         for_all_targets(sysroot, |target| {
-            miri_pass("tests/run-pass", &target, host);
+            miri_pass("tests/run-pass", &target, host, false);
         });
+        miri_pass("tests/run-pass-fullmir", host, host, true);
         compile_fail(sysroot);
     }
 }
diff --git a/tests/run-pass-fullmir/loop-break-value.rs b/tests/run-pass-fullmir/loop-break-value.rs
new file mode 100644 (file)
index 0000000..8631909
--- /dev/null
@@ -0,0 +1,141 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(never_type)]
+#![allow(unreachable_code)]
+
+#[allow(unused)]
+fn never_returns() {
+    loop {
+        break loop {};
+    }
+}
+
+pub fn main() {
+    let value = 'outer: loop {
+        if 1 == 1 {
+            break 13;
+        } else {
+            let _never: ! = loop {
+                break loop {
+                    break 'outer panic!();
+                }
+            };
+        }
+    };
+    assert_eq!(value, 13);
+
+    let x = [1, 3u32, 5];
+    let y = [17];
+    let z = [];
+    let coerced: &[_] = loop {
+        match 2 {
+            1 => break &x,
+            2 => break &y,
+            3 => break &z,
+            _ => (),
+        }
+    };
+    assert_eq!(coerced, &[17u32]);
+
+    let trait_unified = loop {
+        break if true {
+            break Default::default()
+        } else {
+            break [13, 14]
+        };
+    };
+    assert_eq!(trait_unified, [0, 0]);
+
+    let trait_unified_2 = loop {
+        if false {
+            break [String::from("Hello")]
+        } else {
+            break Default::default()
+        };
+    };
+    assert_eq!(trait_unified_2, [""]);
+
+    let trait_unified_3 = loop {
+        break if false {
+            break [String::from("Hello")]
+        } else {
+            ["Yes".into()]
+        };
+    };
+    assert_eq!(trait_unified_3, ["Yes"]);
+
+    let regular_break = loop {
+        if true {
+            break;
+        } else {
+            break break Default::default();
+        }
+    };
+    assert_eq!(regular_break, ());
+
+    let regular_break_2 = loop {
+        if true {
+            break Default::default();
+        } else {
+            break;
+        }
+    };
+    assert_eq!(regular_break_2, ());
+
+    let regular_break_3 = loop {
+        break if true {
+            Default::default()
+        } else {
+            break;
+        }
+    };
+    assert_eq!(regular_break_3, ());
+
+    let regular_break_4 = loop {
+        break ();
+        break;
+    };
+    assert_eq!(regular_break_4, ());
+
+    let regular_break_5 = loop {
+        break;
+        break ();
+    };
+    assert_eq!(regular_break_5, ());
+
+    let nested_break_value = 'outer2: loop {
+        let _a: u32 = 'inner: loop {
+            if true {
+                break 'outer2 "hello";
+            } else {
+                break 'inner 17;
+            }
+        };
+        panic!();
+    };
+    assert_eq!(nested_break_value, "hello");
+
+    let break_from_while_cond = loop {
+        'inner_loop: while break 'inner_loop {
+            panic!();
+        }
+        break 123;
+    };
+    assert_eq!(break_from_while_cond, 123);
+
+    let break_from_while_to_outer = 'outer_loop: loop {
+        while break 'outer_loop 567 {
+            panic!("from_inner");
+        }
+        panic!("from outer");
+    };
+    assert_eq!(break_from_while_to_outer, 567);
+}
diff --git a/tests/run-pass/loop-break-value.rs b/tests/run-pass/loop-break-value.rs
deleted file mode 100644 (file)
index 8631909..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#![feature(never_type)]
-#![allow(unreachable_code)]
-
-#[allow(unused)]
-fn never_returns() {
-    loop {
-        break loop {};
-    }
-}
-
-pub fn main() {
-    let value = 'outer: loop {
-        if 1 == 1 {
-            break 13;
-        } else {
-            let _never: ! = loop {
-                break loop {
-                    break 'outer panic!();
-                }
-            };
-        }
-    };
-    assert_eq!(value, 13);
-
-    let x = [1, 3u32, 5];
-    let y = [17];
-    let z = [];
-    let coerced: &[_] = loop {
-        match 2 {
-            1 => break &x,
-            2 => break &y,
-            3 => break &z,
-            _ => (),
-        }
-    };
-    assert_eq!(coerced, &[17u32]);
-
-    let trait_unified = loop {
-        break if true {
-            break Default::default()
-        } else {
-            break [13, 14]
-        };
-    };
-    assert_eq!(trait_unified, [0, 0]);
-
-    let trait_unified_2 = loop {
-        if false {
-            break [String::from("Hello")]
-        } else {
-            break Default::default()
-        };
-    };
-    assert_eq!(trait_unified_2, [""]);
-
-    let trait_unified_3 = loop {
-        break if false {
-            break [String::from("Hello")]
-        } else {
-            ["Yes".into()]
-        };
-    };
-    assert_eq!(trait_unified_3, ["Yes"]);
-
-    let regular_break = loop {
-        if true {
-            break;
-        } else {
-            break break Default::default();
-        }
-    };
-    assert_eq!(regular_break, ());
-
-    let regular_break_2 = loop {
-        if true {
-            break Default::default();
-        } else {
-            break;
-        }
-    };
-    assert_eq!(regular_break_2, ());
-
-    let regular_break_3 = loop {
-        break if true {
-            Default::default()
-        } else {
-            break;
-        }
-    };
-    assert_eq!(regular_break_3, ());
-
-    let regular_break_4 = loop {
-        break ();
-        break;
-    };
-    assert_eq!(regular_break_4, ());
-
-    let regular_break_5 = loop {
-        break;
-        break ();
-    };
-    assert_eq!(regular_break_5, ());
-
-    let nested_break_value = 'outer2: loop {
-        let _a: u32 = 'inner: loop {
-            if true {
-                break 'outer2 "hello";
-            } else {
-                break 'inner 17;
-            }
-        };
-        panic!();
-    };
-    assert_eq!(nested_break_value, "hello");
-
-    let break_from_while_cond = loop {
-        'inner_loop: while break 'inner_loop {
-            panic!();
-        }
-        break 123;
-    };
-    assert_eq!(break_from_while_cond, 123);
-
-    let break_from_while_to_outer = 'outer_loop: loop {
-        while break 'outer_loop 567 {
-            panic!("from_inner");
-        }
-        panic!("from outer");
-    };
-    assert_eq!(break_from_while_to_outer, 567);
-}