]> git.lizzy.rs Git - rust.git/blob - tests/dogfood.rs
Merge remote-tracking branch 'upstream/rust-1.38.0' into backport_merge
[rust.git] / tests / dogfood.rs
1 #[test]
2 fn dogfood_clippy() {
3     // run clippy on itself and fail the test if lint warnings are reported
4     if option_env!("RUSTC_TEST_SUITE").is_some() || cfg!(windows) {
5         return;
6     }
7     let root_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
8     let clippy_binary = std::path::Path::new(&root_dir)
9         .join("target")
10         .join(env!("PROFILE"))
11         .join("cargo-clippy");
12
13     let output = std::process::Command::new(clippy_binary)
14         .current_dir(root_dir)
15         .env("CLIPPY_DOGFOOD", "1")
16         .env("CARGO_INCREMENTAL", "0")
17         .arg("clippy-preview")
18         .arg("--all-targets")
19         .arg("--all-features")
20         .arg("--")
21         .args(&["-D", "clippy::all"])
22         .args(&["-D", "clippy::internal"])
23         .args(&["-D", "clippy::pedantic"])
24         .arg("-Cdebuginfo=0") // disable debuginfo to generate less data in the target dir
25         .output()
26         .unwrap();
27     println!("status: {}", output.status);
28     println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
29     println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
30
31     assert!(output.status.success());
32 }
33
34 #[test]
35 fn dogfood_subprojects() {
36     // run clippy on remaining subprojects and fail the test if lint warnings are reported
37     if option_env!("RUSTC_TEST_SUITE").is_some() || cfg!(windows) {
38         return;
39     }
40     let root_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
41     let clippy_binary = std::path::Path::new(&root_dir)
42         .join("target")
43         .join(env!("PROFILE"))
44         .join("cargo-clippy");
45
46     for d in &[
47         "clippy_workspace_tests",
48         "clippy_workspace_tests/src",
49         "clippy_workspace_tests/subcrate",
50         "clippy_workspace_tests/subcrate/src",
51         "clippy_dev",
52         "rustc_tools_util",
53     ] {
54         let output = std::process::Command::new(&clippy_binary)
55             .current_dir(root_dir.join(d))
56             .env("CLIPPY_DOGFOOD", "1")
57             .env("CARGO_INCREMENTAL", "0")
58             .arg("clippy")
59             .arg("--")
60             .args(&["-D", "clippy::all"])
61             .args(&["-D", "clippy::pedantic"])
62             .arg("-Cdebuginfo=0") // disable debuginfo to generate less data in the target dir
63             .output()
64             .unwrap();
65         println!("status: {}", output.status);
66         println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
67         println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
68
69         assert!(output.status.success());
70     }
71 }