]> git.lizzy.rs Git - rust.git/blob - tests/dogfood.rs
tests: execute dogfood tests with incremental compilation disabled
[rust.git] / tests / dogfood.rs
1 #[test]
2 fn dogfood() {
3     if option_env!("RUSTC_TEST_SUITE").is_some() || cfg!(windows) {
4         return;
5     }
6     let root_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
7     let clippy_cmd = std::path::Path::new(&root_dir)
8         .join("target")
9         .join(env!("PROFILE"))
10         .join("cargo-clippy");
11
12     let output = std::process::Command::new(clippy_cmd)
13         .current_dir(root_dir)
14         .env("CLIPPY_DOGFOOD", "1")
15         .env("CARGO_INCREMENTAL", "0")
16         .arg("clippy-preview")
17         .arg("--all-targets")
18         .arg("--all-features")
19         .arg("--")
20         .args(&["-D", "clippy::all"])
21         .args(&["-D", "clippy::internal"])
22         .args(&["-D", "clippy::pedantic"])
23         .output()
24         .unwrap();
25     println!("status: {}", output.status);
26     println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
27     println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
28
29     assert!(output.status.success());
30 }
31
32 #[test]
33 fn dogfood_tests() {
34     if option_env!("RUSTC_TEST_SUITE").is_some() || cfg!(windows) {
35         return;
36     }
37     let root_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
38     let clippy_cmd = std::path::Path::new(&root_dir)
39         .join("target")
40         .join(env!("PROFILE"))
41         .join("cargo-clippy");
42
43     for d in &[
44         "clippy_workspace_tests",
45         "clippy_workspace_tests/src",
46         "clippy_workspace_tests/subcrate",
47         "clippy_workspace_tests/subcrate/src",
48         "clippy_dev",
49         "rustc_tools_util",
50     ] {
51         let output = std::process::Command::new(&clippy_cmd)
52             .current_dir(root_dir.join(d))
53             .env("CLIPPY_DOGFOOD", "1")
54             .env("CARGO_INCREMENTAL", "0")
55             .arg("clippy")
56             .arg("--")
57             .args(&["-D", "clippy::all"])
58             .args(&["-D", "clippy::pedantic"])
59             .output()
60             .unwrap();
61         println!("status: {}", output.status);
62         println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
63         println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
64
65         assert!(output.status.success());
66     }
67 }