]> git.lizzy.rs Git - rust.git/blobdiff - tests/integration.rs
Make tidy check for magic numbers that spell things
[rust.git] / tests / integration.rs
index 74f9a854dc1fa5e0776d75b072f3bd3ddba9fdbd..c64425fa01a42a36b8351e934ae81523d75b7129 100644 (file)
@@ -1,8 +1,9 @@
 #![cfg(feature = "integration")]
-
-use git2::Repository;
+#![cfg_attr(feature = "deny-warnings", deny(warnings))]
+#![warn(rust_2018_idioms, unused_lifetimes)]
 
 use std::env;
+use std::ffi::OsStr;
 use std::process::Command;
 
 #[cfg_attr(feature = "integration", test)]
@@ -14,12 +15,19 @@ fn integration_test() {
         .nth(1)
         .expect("repo name should have format `<org>/<name>`");
 
-    let repo_dir = tempfile::tempdir()
-        .expect("couldn't create temp dir")
-        .path()
-        .join(crate_name);
+    let mut repo_dir = tempfile::tempdir().expect("couldn't create temp dir").into_path();
+    repo_dir.push(crate_name);
 
-    Repository::clone(&repo_url, &repo_dir).expect("clone of repo failed");
+    let st = Command::new("git")
+        .args(&[
+            OsStr::new("clone"),
+            OsStr::new("--depth=1"),
+            OsStr::new(&repo_url),
+            OsStr::new(&repo_dir),
+        ])
+        .status()
+        .expect("unable to run git");
+    assert!(st.success());
 
     let root_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
     let target_dir = std::path::Path::new(&root_dir).join("target");
@@ -58,21 +66,24 @@ fn integration_test() {
     } else if stderr.contains("query stack during panic") {
         panic!("query stack during panic in the output");
     } else if stderr.contains("E0463") {
+        // Encountering E0463 (can't find crate for `x`) did _not_ cause the build to fail in the
+        // past. Even though it should have. That's why we explicitly panic here.
+        // See PR #3552 and issue #3523 for more background.
         panic!("error: E0463");
     } else if stderr.contains("E0514") {
         panic!("incompatible crate versions");
     } else if stderr.contains("failed to run `rustc` to learn about target-specific information") {
         panic!("couldn't find librustc_driver, consider setting `LD_LIBRARY_PATH`");
+    } else {
+        assert!(
+            !stderr.contains("toolchain") || !stderr.contains("is not installed"),
+            "missing required toolchain"
+        );
     }
 
     match output.status.code() {
-        Some(code) => {
-            if code == 0 {
-                println!("Compilation successful");
-            } else {
-                eprintln!("Compilation failed. Exit code: {}", code);
-            }
-        },
+        Some(0) => println!("Compilation successful"),
+        Some(code) => eprintln!("Compilation failed. Exit code: {}", code),
         None => panic!("Process terminated by signal"),
     }
 }