]> git.lizzy.rs Git - rust.git/blob - tests/dogfood.rs
Merge remote-tracking branch 'upstream/master'
[rust.git] / tests / dogfood.rs
1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
3 //
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
9
10 #[test]
11 fn dogfood() {
12     if option_env!("RUSTC_TEST_SUITE").is_some() || cfg!(windows) {
13         return;
14     }
15     let root_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
16     let clippy_cmd = std::path::Path::new(&root_dir)
17         .join("target")
18         .join(env!("PROFILE"))
19         .join("cargo-clippy");
20
21     let output = std::process::Command::new(clippy_cmd)
22         .current_dir(root_dir)
23         .env("CLIPPY_DOGFOOD", "1")
24         .arg("clippy")
25         .arg("--all-targets")
26         .arg("--all-features")
27         .arg("--")
28         .args(&["-D", "clippy::all"])
29         .args(&["-D", "clippy::internal"])
30         .args(&["-D", "clippy::pedantic"])
31         .output()
32         .unwrap();
33     println!("status: {}", output.status);
34     println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
35     println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
36
37     assert!(output.status.success());
38 }
39
40 #[test]
41 fn dogfood_tests() {
42     if option_env!("RUSTC_TEST_SUITE").is_some() || cfg!(windows) {
43         return;
44     }
45     let root_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
46     let clippy_cmd = std::path::Path::new(&root_dir)
47         .join("target")
48         .join(env!("PROFILE"))
49         .join("cargo-clippy");
50
51     for d in &[
52         "clippy_workspace_tests",
53         "clippy_workspace_tests/src",
54         "clippy_workspace_tests/subcrate",
55         "clippy_workspace_tests/subcrate/src",
56         "clippy_dev",
57         "rustc_tools_util",
58     ] {
59         let output = std::process::Command::new(&clippy_cmd)
60             .current_dir(root_dir.join(d))
61             .env("CLIPPY_DOGFOOD", "1")
62             .arg("clippy")
63             .arg("--")
64             .args(&["-D", "clippy::all"])
65             .args(&["-D", "clippy::pedantic"])
66             .output()
67             .unwrap();
68         println!("status: {}", output.status);
69         println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
70         println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
71
72         assert!(output.status.success());
73     }
74 }