about summary refs log tree commit diff
diff options
context:
space:
mode:
authorWayne Warren <wayne.warren.s@gmail.com>2018-11-21 09:14:42 -0600
committerWayne Warren <wayne.warren.s@gmail.com>2018-12-05 18:18:17 -0600
commit72247d8e2e6e14fd428d2334b67298dc889340e4 (patch)
tree305b48544a971131523af1dbcc1e059dc14a54b4
parent29bf75cd3147d4e34a5e70bd167898a8105f7e5d (diff)
downloadrust-72247d8e2e6e14fd428d2334b67298dc889340e4.tar.gz
rust-72247d8e2e6e14fd428d2334b67298dc889340e4.zip
Fix dogfood tests.
-rwxr-xr-xci/base-tests.sh20
-rw-r--r--tests/dogfood.rs55
2 files changed, 44 insertions, 31 deletions
diff --git a/ci/base-tests.sh b/ci/base-tests.sh
index a046d21c4be..2537f157ad9 100755
--- a/ci/base-tests.sh
+++ b/ci/base-tests.sh
@@ -27,23 +27,3 @@ cd clippy_dev && cargo test && cd ..
 # Perform various checks for lint registration
 ./util/dev update_lints --check
 cargo +nightly fmt --all -- --check
-
-# Add bin to PATH for windows
-PATH=$PATH:$(rustc --print sysroot)/bin
-
-CLIPPY="`pwd`/target/debug/cargo-clippy clippy"
-# run clippy on its own codebase...
-${CLIPPY} --all-targets --all-features -- -D clippy::all -D clippy::internal -Dclippy::pedantic
-# ... and some test directories
-for dir in clippy_workspace_tests clippy_workspace_tests/src clippy_workspace_tests/subcrate clippy_workspace_tests/subcrate/src clippy_dev rustc_tools_util
-do
-    cd ${dir}
-    ${CLIPPY} -- -D clippy::all -D clippy::pedantic
-    cd -
-done
-
-
-# test --manifest-path
-${CLIPPY} --manifest-path=clippy_workspace_tests/Cargo.toml -- -D clippy::all
-cd clippy_workspace_tests/subcrate && ${CLIPPY} --manifest-path=../Cargo.toml -- -D clippy::all && cd ../..
-set +x
diff --git a/tests/dogfood.rs b/tests/dogfood.rs
index e8f7a080c95..2f2b0cf50ac 100644
--- a/tests/dogfood.rs
+++ b/tests/dogfood.rs
@@ -12,18 +12,50 @@ fn dogfood() {
     if option_env!("RUSTC_TEST_SUITE").is_some() || cfg!(windows) {
         return;
     }
-    let root_dir = std::env::current_dir().unwrap();
-    for d in &[".", "clippy_lints", "rustc_tools_util", "clippy_dev"] {
+    let root_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
+    let clippy_cmd = std::path::Path::new(&root_dir).join("target/debug/cargo-clippy");
+
+    println!("{:?}", clippy_cmd);
+    let output = std::process::Command::new(clippy_cmd)
+        .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));
+
+    assert!(output.status.success());
+}
+
+#[test]
+fn dogfood_tests() {
+    if option_env!("RUSTC_TEST_SUITE").is_some() || cfg!(windows) {
+        return;
+    }
+    let root_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
+
+    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 clippy_cmd = std::path::Path::new(&root_dir)
+            .join("target/debug/cargo-clippy");
         std::env::set_current_dir(root_dir.join(d)).unwrap();
-        let output = std::process::Command::new("cargo")
-            .arg("run")
-            .arg("--bin")
-            .arg("cargo-clippy")
-            .arg("--all-features")
-            .arg("--manifest-path")
-            .arg(root_dir.join("Cargo.toml"))
-            .args(&["--", "-W clippy::internal -W clippy::pedantic"])
-            .env("CLIPPY_DOGFOOD", "true")
+        let output = std::process::Command::new(clippy_cmd)
+            .arg("clippy")
+            .arg("--")
+            .args(&["-D", "clippy::all"])
+            .args(&["-D", "clippy::pedantic"])
             .output()
             .unwrap();
         println!("status: {}", output.status);
@@ -32,4 +64,5 @@ fn dogfood() {
 
         assert!(output.status.success());
     }
+    std::env::set_current_dir(root_dir).unwrap();
 }