Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 2d53b6b

Browse files
author
hyd-dev
committed
Move test_no_deps_ignores_path_deps_in_workspaces() out of dogfood_subprojects()
1 parent 2d07c33 commit 2d53b6b

File tree

1 file changed

+79
-79
lines changed

1 file changed

+79
-79
lines changed

tests/dogfood.rs

Lines changed: 79 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -46,38 +46,81 @@ fn dogfood_clippy() {
4646
assert!(output.status.success());
4747
}
4848

49-
#[test]
50-
fn dogfood_subprojects() {
51-
fn test_no_deps_ignores_path_deps_in_workspaces() {
52-
if cargo::is_rustc_test_suite() {
53-
return;
54-
}
55-
let root = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
56-
let target_dir = root.join("target").join("dogfood");
57-
let cwd = root.join("clippy_workspace_tests");
58-
59-
// Make sure we start with a clean state
60-
Command::new("cargo")
49+
fn test_no_deps_ignores_path_deps_in_workspaces() {
50+
if cargo::is_rustc_test_suite() {
51+
return;
52+
}
53+
let root = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
54+
let target_dir = root.join("target").join("dogfood");
55+
let cwd = root.join("clippy_workspace_tests");
56+
57+
// Make sure we start with a clean state
58+
Command::new("cargo")
59+
.current_dir(&cwd)
60+
.env("CARGO_TARGET_DIR", &target_dir)
61+
.arg("clean")
62+
.args(&["-p", "subcrate"])
63+
.args(&["-p", "path_dep"])
64+
.output()
65+
.unwrap();
66+
67+
// `path_dep` is a path dependency of `subcrate` that would trigger a denied lint.
68+
// Make sure that with the `--no-deps` argument Clippy does not run on `path_dep`.
69+
let output = Command::new(&*CLIPPY_PATH)
70+
.current_dir(&cwd)
71+
.env("CLIPPY_DOGFOOD", "1")
72+
.env("CARGO_INCREMENTAL", "0")
73+
.arg("clippy")
74+
.args(&["-p", "subcrate"])
75+
.arg("--")
76+
.arg("--no-deps")
77+
.arg("-Cdebuginfo=0") // disable debuginfo to generate less data in the target dir
78+
.args(&["--cfg", r#"feature="primary_package_test""#])
79+
.output()
80+
.unwrap();
81+
println!("status: {}", output.status);
82+
println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
83+
println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
84+
85+
assert!(output.status.success());
86+
87+
let lint_path_dep = || {
88+
// Test that without the `--no-deps` argument, `path_dep` is linted.
89+
let output = Command::new(&*CLIPPY_PATH)
6190
.current_dir(&cwd)
62-
.env("CARGO_TARGET_DIR", &target_dir)
63-
.arg("clean")
91+
.env("CLIPPY_DOGFOOD", "1")
92+
.env("CARGO_INCREMENTAL", "0")
93+
.arg("clippy")
6494
.args(&["-p", "subcrate"])
65-
.args(&["-p", "path_dep"])
95+
.arg("--")
96+
.arg("-Cdebuginfo=0") // disable debuginfo to generate less data in the target dir
97+
.args(&["--cfg", r#"feature="primary_package_test""#])
6698
.output()
6799
.unwrap();
100+
println!("status: {}", output.status);
101+
println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
102+
println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
103+
104+
assert!(!output.status.success());
105+
assert!(
106+
String::from_utf8(output.stderr)
107+
.unwrap()
108+
.contains("error: empty `loop {}` wastes CPU cycles")
109+
);
110+
};
111+
112+
// Make sure Cargo is aware of the removal of `--no-deps`.
113+
lint_path_dep();
68114

69-
// `path_dep` is a path dependency of `subcrate` that would trigger a denied lint.
70-
// Make sure that with the `--no-deps` argument Clippy does not run on `path_dep`.
115+
let successful_build = || {
71116
let output = Command::new(&*CLIPPY_PATH)
72117
.current_dir(&cwd)
73118
.env("CLIPPY_DOGFOOD", "1")
74119
.env("CARGO_INCREMENTAL", "0")
75120
.arg("clippy")
76121
.args(&["-p", "subcrate"])
77122
.arg("--")
78-
.arg("--no-deps")
79123
.arg("-Cdebuginfo=0") // disable debuginfo to generate less data in the target dir
80-
.args(&["--cfg", r#"feature="primary_package_test""#])
81124
.output()
82125
.unwrap();
83126
println!("status: {}", output.status);
@@ -86,67 +129,24 @@ fn dogfood_subprojects() {
86129

87130
assert!(output.status.success());
88131

89-
let lint_path_dep = || {
90-
// Test that without the `--no-deps` argument, `path_dep` is linted.
91-
let output = Command::new(&*CLIPPY_PATH)
92-
.current_dir(&cwd)
93-
.env("CLIPPY_DOGFOOD", "1")
94-
.env("CARGO_INCREMENTAL", "0")
95-
.arg("clippy")
96-
.args(&["-p", "subcrate"])
97-
.arg("--")
98-
.arg("-Cdebuginfo=0") // disable debuginfo to generate less data in the target dir
99-
.args(&["--cfg", r#"feature="primary_package_test""#])
100-
.output()
101-
.unwrap();
102-
println!("status: {}", output.status);
103-
println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
104-
println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
105-
106-
assert!(!output.status.success());
107-
assert!(
108-
String::from_utf8(output.stderr)
109-
.unwrap()
110-
.contains("error: empty `loop {}` wastes CPU cycles")
111-
);
112-
};
113-
114-
// Make sure Cargo is aware of the removal of `--no-deps`.
115-
lint_path_dep();
116-
117-
let successful_build = || {
118-
let output = Command::new(&*CLIPPY_PATH)
119-
.current_dir(&cwd)
120-
.env("CLIPPY_DOGFOOD", "1")
121-
.env("CARGO_INCREMENTAL", "0")
122-
.arg("clippy")
123-
.args(&["-p", "subcrate"])
124-
.arg("--")
125-
.arg("-Cdebuginfo=0") // disable debuginfo to generate less data in the target dir
126-
.output()
127-
.unwrap();
128-
println!("status: {}", output.status);
129-
println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
130-
println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
131-
132-
assert!(output.status.success());
133-
134-
output
135-
};
136-
137-
// Trigger a sucessful build, so Cargo would like to cache the build result.
138-
successful_build();
139-
140-
// Make sure there's no spurious rebuild when nothing changes.
141-
let stderr = String::from_utf8(successful_build().stderr).unwrap();
142-
assert!(!stderr.contains("Compiling"));
143-
assert!(!stderr.contains("Checking"));
144-
assert!(stderr.contains("Finished"));
145-
146-
// Make sure Cargo is aware of the new `--cfg` flag.
147-
lint_path_dep();
148-
}
132+
output
133+
};
134+
135+
// Trigger a sucessful build, so Cargo would like to cache the build result.
136+
successful_build();
137+
138+
// Make sure there's no spurious rebuild when nothing changes.
139+
let stderr = String::from_utf8(successful_build().stderr).unwrap();
140+
assert!(!stderr.contains("Compiling"));
141+
assert!(!stderr.contains("Checking"));
142+
assert!(stderr.contains("Finished"));
149143

144+
// Make sure Cargo is aware of the new `--cfg` flag.
145+
lint_path_dep();
146+
}
147+
148+
#[test]
149+
fn dogfood_subprojects() {
150150
// run clippy on remaining subprojects and fail the test if lint warnings are reported
151151
if cargo::is_rustc_test_suite() {
152152
return;

0 commit comments

Comments
 (0)