]> git.lizzy.rs Git - rust.git/blobdiff - tests/dogfood.rs
Change explicit_counter_loop's message to add parentheses if necessary
[rust.git] / tests / dogfood.rs
index 83b2acf7d815bbade57d0d821101aa138e642469..27a3d84da4127a972ce3c912550354b97234ad4d 100644 (file)
@@ -1,49 +1,65 @@
-#![feature(test, plugin)]
-#![plugin(clippy)]
-#![deny(clippy, clippy_pedantic)]
-
-extern crate compiletest_rs as compiletest;
-extern crate test;
-
-use std::env::{var, set_var};
-use std::path::PathBuf;
-use test::TestPaths;
-
 #[test]
 fn dogfood() {
-    // don't run dogfood on travis, cargo-clippy already runs clippy on itself
-    if let Ok(travis) = var("TRAVIS") {
-        if travis == "true" {
-            return;
-        }
+    if option_env!("RUSTC_TEST_SUITE").is_some() {
+        return;
     }
+    let root_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
+    let clippy_cmd = std::path::Path::new(&root_dir)
+        .join("target")
+        .join(env!("PROFILE"))
+        .join("cargo-clippy");
 
-    let mut config = compiletest::default_config();
-
-    let cfg_mode = "run-fail".parse().expect("Invalid mode");
-    let mut s = String::new();
-    s.push_str(" -L target/debug/");
-    s.push_str(" -L target/debug/deps");
-    s.push_str(" -Zextra-plugins=clippy -Ltarget_recur/debug -Dwarnings -Dclippy_pedantic -Dclippy -Dclippy_internal");
-    config.target_rustcflags = Some(s);
-    if let Ok(name) = var("TESTNAME") {
-        config.filter = Some(name.to_owned())
-    }
+    let output = std::process::Command::new(clippy_cmd)
+        .current_dir(root_dir)
+        .env("CLIPPY_DOGFOOD", "1")
+        .arg("clippy")
+        .arg("--all-targets")
+        .arg("--all-features")
+        .arg("--")
+        .args(&["-D", "clippy::all"])
+        .args(&["-D", "clippy::internal"])
+        .args(&["-D", "clippy::pedantic"])
+        .output()
+        .unwrap();
+    println!("status: {}", output.status);
+    println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
+    println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
 
-    config.mode = cfg_mode;
-    config.verbose = true;
-
-    let files = ["src/main.rs", "src/lib.rs", "clippy_lints/src/lib.rs"];
+    assert!(output.status.success());
+}
 
-    for file in &files {
-        let paths = TestPaths {
-            base: PathBuf::new(),
-            file: PathBuf::from(file),
-            relative_dir: PathBuf::new(),
-        };
+#[test]
+fn dogfood_tests() {
+    if option_env!("RUSTC_TEST_SUITE").is_some() {
+        return;
+    }
+    let root_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
+    let clippy_cmd = std::path::Path::new(&root_dir)
+        .join("target")
+        .join(env!("PROFILE"))
+        .join("cargo-clippy");
 
-        set_var("CLIPPY_DOGFOOD", "tastes like chicken");
+    for d in &[
+        "clippy_workspace_tests",
+        "clippy_workspace_tests/src",
+        "clippy_workspace_tests/subcrate",
+        "clippy_workspace_tests/subcrate/src",
+        "clippy_dev",
+        "rustc_tools_util",
+    ] {
+        let output = std::process::Command::new(&clippy_cmd)
+            .current_dir(root_dir.join(d))
+            .env("CLIPPY_DOGFOOD", "1")
+            .arg("clippy")
+            .arg("--")
+            .args(&["-D", "clippy::all"])
+            .args(&["-D", "clippy::pedantic"])
+            .output()
+            .unwrap();
+        println!("status: {}", output.status);
+        println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
+        println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
 
-        compiletest::runtest::run(config.clone(), &paths);
+        assert!(output.status.success());
     }
 }