]> git.lizzy.rs Git - rust.git/commitdiff
Enable 64bit vs 32bit tests
authorOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Wed, 17 May 2017 16:15:21 +0000 (18:15 +0200)
committerOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Wed, 17 May 2017 16:15:21 +0000 (18:15 +0200)
tests/examples.rs

index 0b77b993ff6e073ab1972603adbc5fe260f00f24..3e05f42bcf5cd80f26a04dc0e48d010234494843 100644 (file)
@@ -1,6 +1,9 @@
 #[macro_use]
 extern crate duct;
 
+use std::io::{BufRead, BufReader};
+use std::fs::File;
+
 #[test]
 fn examples() {
     let mut error = false;
@@ -10,6 +13,16 @@ fn examples() {
         if file.extension().map_or(true, |file| file != "rs") {
             continue;
         }
+        print!("testing {}... ", file.file_stem().unwrap().to_str().unwrap());
+        let skip = BufReader::new(File::open(&file).unwrap()).lines().any(|line| {
+            let line = line.as_ref().unwrap().trim();
+            line == "// ignore-x86" && cfg!(target_pointer_width = "32") ||
+            line == "// ignore-x86_64" && cfg!(target_pointer_width = "64")
+        });
+        if skip {
+            println!("skipping");
+            continue;
+        }
         cmd!("touch", &file).run().unwrap();
         let output = file.with_extension("stderr");
         cmd!("cargo", "rustc", "-q", "--example", file.file_stem().unwrap(), "--", "-Dwarnings",
@@ -22,7 +35,6 @@ fn examples() {
             .dir("clippy_tests")
             .run()
             .unwrap();
-        print!("testing {}... ", file.file_stem().unwrap().to_str().unwrap());
         if cmd!("git", "diff", "--exit-code", output).run().is_err() {
             error = true;
             println!("ERROR");