Skip to content

Commit 72247d8

Browse files
committed
Fix dogfood tests.
1 parent 29bf75c commit 72247d8

File tree

2 files changed

+44
-31
lines changed

2 files changed

+44
-31
lines changed

ci/base-tests.sh

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,3 @@ cd clippy_dev && cargo test && cd ..
2727
# Perform various checks for lint registration
2828
./util/dev update_lints --check
2929
cargo +nightly fmt --all -- --check
30-
31-
# Add bin to PATH for windows
32-
PATH=$PATH:$(rustc --print sysroot)/bin
33-
34-
CLIPPY="`pwd`/target/debug/cargo-clippy clippy"
35-
# run clippy on its own codebase...
36-
${CLIPPY} --all-targets --all-features -- -D clippy::all -D clippy::internal -Dclippy::pedantic
37-
# ... and some test directories
38-
for dir in clippy_workspace_tests clippy_workspace_tests/src clippy_workspace_tests/subcrate clippy_workspace_tests/subcrate/src clippy_dev rustc_tools_util
39-
do
40-
cd ${dir}
41-
${CLIPPY} -- -D clippy::all -D clippy::pedantic
42-
cd -
43-
done
44-
45-
46-
# test --manifest-path
47-
${CLIPPY} --manifest-path=clippy_workspace_tests/Cargo.toml -- -D clippy::all
48-
cd clippy_workspace_tests/subcrate && ${CLIPPY} --manifest-path=../Cargo.toml -- -D clippy::all && cd ../..
49-
set +x

tests/dogfood.rs

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,50 @@ fn dogfood() {
1212
if option_env!("RUSTC_TEST_SUITE").is_some() || cfg!(windows) {
1313
return;
1414
}
15-
let root_dir = std::env::current_dir().unwrap();
16-
for d in &[".", "clippy_lints", "rustc_tools_util", "clippy_dev"] {
15+
let root_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
16+
let clippy_cmd = std::path::Path::new(&root_dir).join("target/debug/cargo-clippy");
17+
18+
println!("{:?}", clippy_cmd);
19+
let output = std::process::Command::new(clippy_cmd)
20+
.arg("clippy")
21+
.arg("--all-targets")
22+
.arg("--all-features")
23+
.arg("--")
24+
.args(&["-D", "clippy::all"])
25+
.args(&["-D", "clippy::internal"])
26+
.args(&["-D", "clippy::pedantic"])
27+
.output()
28+
.unwrap();
29+
println!("status: {}", output.status);
30+
println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
31+
println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
32+
33+
assert!(output.status.success());
34+
}
35+
36+
#[test]
37+
fn dogfood_tests() {
38+
if option_env!("RUSTC_TEST_SUITE").is_some() || cfg!(windows) {
39+
return;
40+
}
41+
let root_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
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 clippy_cmd = std::path::Path::new(&root_dir)
52+
.join("target/debug/cargo-clippy");
1753
std::env::set_current_dir(root_dir.join(d)).unwrap();
18-
let output = std::process::Command::new("cargo")
19-
.arg("run")
20-
.arg("--bin")
21-
.arg("cargo-clippy")
22-
.arg("--all-features")
23-
.arg("--manifest-path")
24-
.arg(root_dir.join("Cargo.toml"))
25-
.args(&["--", "-W clippy::internal -W clippy::pedantic"])
26-
.env("CLIPPY_DOGFOOD", "true")
54+
let output = std::process::Command::new(clippy_cmd)
55+
.arg("clippy")
56+
.arg("--")
57+
.args(&["-D", "clippy::all"])
58+
.args(&["-D", "clippy::pedantic"])
2759
.output()
2860
.unwrap();
2961
println!("status: {}", output.status);
@@ -32,4 +64,5 @@ fn dogfood() {
3264

3365
assert!(output.status.success());
3466
}
67+
std::env::set_current_dir(root_dir).unwrap();
3568
}

0 commit comments

Comments
 (0)