Skip to content

Commit 920e9f0

Browse files
committed
Move workspace test
1 parent 51dbbf3 commit 920e9f0

File tree

12 files changed

+109
-128
lines changed

12 files changed

+109
-128
lines changed

.github/workflows/clippy.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,6 @@ jobs:
7070
run: cargo test --features deny-warnings
7171
working-directory: clippy_dev
7272

73-
- name: Test cargo-clippy
74-
run: ../target/debug/cargo-clippy
75-
working-directory: clippy_workspace_tests
76-
77-
- name: Test cargo-clippy --fix
78-
run: ../target/debug/cargo-clippy clippy --fix
79-
working-directory: clippy_workspace_tests
80-
8173
- name: Test clippy-driver
8274
run: bash .github/driver.sh
8375
env:

.github/workflows/clippy_bors.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,6 @@ jobs:
133133
run: cargo test --features deny-warnings
134134
working-directory: clippy_dev
135135

136-
- name: Test cargo-clippy
137-
run: ../target/debug/cargo-clippy
138-
working-directory: clippy_workspace_tests
139-
140-
- name: Test cargo-clippy --fix
141-
run: ../target/debug/cargo-clippy clippy --fix
142-
working-directory: clippy_workspace_tests
143-
144136
- name: Test clippy-driver
145137
run: bash .github/driver.sh
146138
env:

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ out
1919
/target
2020
/clippy_lints/target
2121
/clippy_utils/target
22-
/clippy_workspace_tests/target
2322
/clippy_dev/target
2423
/lintcheck/target
2524
/rustc_tools_util/target

tests/dogfood.rs

Lines changed: 1 addition & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -47,102 +47,6 @@ fn dogfood_clippy() {
4747
assert!(output.status.success());
4848
}
4949

50-
fn test_no_deps_ignores_path_deps_in_workspaces() {
51-
if IS_RUSTC_TEST_SUITE {
52-
return;
53-
}
54-
let root = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
55-
let target_dir = root.join("target").join("dogfood");
56-
let cwd = root.join("clippy_workspace_tests");
57-
58-
// Make sure we start with a clean state
59-
Command::new("cargo")
60-
.current_dir(&cwd)
61-
.env("CARGO_TARGET_DIR", &target_dir)
62-
.arg("clean")
63-
.args(&["-p", "subcrate"])
64-
.args(&["-p", "path_dep"])
65-
.output()
66-
.unwrap();
67-
68-
// `path_dep` is a path dependency of `subcrate` that would trigger a denied lint.
69-
// Make sure that with the `--no-deps` argument Clippy does not run on `path_dep`.
70-
let output = Command::new(&*CARGO_CLIPPY_PATH)
71-
.current_dir(&cwd)
72-
.env("CARGO_INCREMENTAL", "0")
73-
.arg("clippy")
74-
.args(&["-p", "subcrate"])
75-
.arg("--no-deps")
76-
.arg("--")
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(&*CARGO_CLIPPY_PATH)
90-
.current_dir(&cwd)
91-
.env("CARGO_INCREMENTAL", "0")
92-
.arg("clippy")
93-
.args(&["-p", "subcrate"])
94-
.arg("--")
95-
.arg("-Cdebuginfo=0") // disable debuginfo to generate less data in the target dir
96-
.args(&["--cfg", r#"feature="primary_package_test""#])
97-
.output()
98-
.unwrap();
99-
println!("status: {}", output.status);
100-
println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
101-
println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
102-
103-
assert!(!output.status.success());
104-
assert!(
105-
String::from_utf8(output.stderr)
106-
.unwrap()
107-
.contains("error: empty `loop {}` wastes CPU cycles")
108-
);
109-
};
110-
111-
// Make sure Cargo is aware of the removal of `--no-deps`.
112-
lint_path_dep();
113-
114-
let successful_build = || {
115-
let output = Command::new(&*CARGO_CLIPPY_PATH)
116-
.current_dir(&cwd)
117-
.env("CARGO_INCREMENTAL", "0")
118-
.arg("clippy")
119-
.args(&["-p", "subcrate"])
120-
.arg("--")
121-
.arg("-Cdebuginfo=0") // disable debuginfo to generate less data in the target dir
122-
.output()
123-
.unwrap();
124-
println!("status: {}", output.status);
125-
println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
126-
println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
127-
128-
assert!(output.status.success());
129-
130-
output
131-
};
132-
133-
// Trigger a sucessful build, so Cargo would like to cache the build result.
134-
successful_build();
135-
136-
// Make sure there's no spurious rebuild when nothing changes.
137-
let stderr = String::from_utf8(successful_build().stderr).unwrap();
138-
assert!(!stderr.contains("Compiling"));
139-
assert!(!stderr.contains("Checking"));
140-
assert!(stderr.contains("Finished"));
141-
142-
// Make sure Cargo is aware of the new `--cfg` flag.
143-
lint_path_dep();
144-
}
145-
14650
#[test]
14751
fn dogfood_subprojects() {
14852
// run clippy on remaining subprojects and fail the test if lint warnings are reported
@@ -151,22 +55,9 @@ fn dogfood_subprojects() {
15155
}
15256

15357
// NOTE: `path_dep` crate is omitted on purpose here
154-
for project in &[
155-
"clippy_workspace_tests",
156-
"clippy_workspace_tests/src",
157-
"clippy_workspace_tests/subcrate",
158-
"clippy_workspace_tests/subcrate/src",
159-
"clippy_dev",
160-
"clippy_lints",
161-
"clippy_utils",
162-
"rustc_tools_util",
163-
] {
58+
for project in &["clippy_dev", "clippy_lints", "clippy_utils", "rustc_tools_util"] {
16459
run_clippy_for_project(project);
16560
}
166-
167-
// NOTE: Since tests run in parallel we can't run cargo commands on the same workspace at the
168-
// same time, so we test this immediately after the dogfood for workspaces.
169-
test_no_deps_ignores_path_deps_in_workspaces();
17061
}
17162

17263
#[test]

tests/workspace.rs

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
#![feature(once_cell)]
2+
3+
use std::path::PathBuf;
4+
use std::process::Command;
5+
use test_utils::{CARGO_CLIPPY_PATH, IS_RUSTC_TEST_SUITE};
6+
7+
mod test_utils;
8+
9+
#[test]
10+
fn test_no_deps_ignores_path_deps_in_workspaces() {
11+
if IS_RUSTC_TEST_SUITE {
12+
return;
13+
}
14+
let root = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
15+
let target_dir = root.join("target").join("workspace_test");
16+
let cwd = root.join("tests/workspace_test");
17+
18+
// Make sure we start with a clean state
19+
Command::new("cargo")
20+
.current_dir(&cwd)
21+
.env("CARGO_TARGET_DIR", &target_dir)
22+
.arg("clean")
23+
.args(&["-p", "subcrate"])
24+
.args(&["-p", "path_dep"])
25+
.output()
26+
.unwrap();
27+
28+
// `path_dep` is a path dependency of `subcrate` that would trigger a denied lint.
29+
// Make sure that with the `--no-deps` argument Clippy does not run on `path_dep`.
30+
let output = Command::new(&*CARGO_CLIPPY_PATH)
31+
.current_dir(&cwd)
32+
.env("CARGO_INCREMENTAL", "0")
33+
.env("CARGO_TARGET_DIR", &target_dir)
34+
.arg("clippy")
35+
.args(&["-p", "subcrate"])
36+
.arg("--no-deps")
37+
.arg("--")
38+
.arg("-Cdebuginfo=0") // disable debuginfo to generate less data in the target dir
39+
.args(&["--cfg", r#"feature="primary_package_test""#])
40+
.output()
41+
.unwrap();
42+
println!("status: {}", output.status);
43+
println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
44+
println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
45+
46+
assert!(output.status.success());
47+
48+
let lint_path_dep = || {
49+
// Test that without the `--no-deps` argument, `path_dep` is linted.
50+
let output = Command::new(&*CARGO_CLIPPY_PATH)
51+
.current_dir(&cwd)
52+
.env("CARGO_INCREMENTAL", "0")
53+
.env("CARGO_TARGET_DIR", &target_dir)
54+
.arg("clippy")
55+
.args(&["-p", "subcrate"])
56+
.arg("--")
57+
.arg("-Cdebuginfo=0") // disable debuginfo to generate less data in the target dir
58+
.args(&["--cfg", r#"feature="primary_package_test""#])
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+
assert!(
67+
String::from_utf8(output.stderr)
68+
.unwrap()
69+
.contains("error: empty `loop {}` wastes CPU cycles")
70+
);
71+
};
72+
73+
// Make sure Cargo is aware of the removal of `--no-deps`.
74+
lint_path_dep();
75+
76+
let successful_build = || {
77+
let output = Command::new(&*CARGO_CLIPPY_PATH)
78+
.current_dir(&cwd)
79+
.env("CARGO_INCREMENTAL", "0")
80+
.env("CARGO_TARGET_DIR", &target_dir)
81+
.arg("clippy")
82+
.args(&["-p", "subcrate"])
83+
.arg("--")
84+
.arg("-Cdebuginfo=0") // disable debuginfo to generate less data in the target dir
85+
.output()
86+
.unwrap();
87+
println!("status: {}", output.status);
88+
println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
89+
println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
90+
91+
assert!(output.status.success());
92+
93+
output
94+
};
95+
96+
// Trigger a sucessful build, so Cargo would like to cache the build result.
97+
successful_build();
98+
99+
// Make sure there's no spurious rebuild when nothing changes.
100+
let stderr = String::from_utf8(successful_build().stderr).unwrap();
101+
assert!(!stderr.contains("Compiling"));
102+
assert!(!stderr.contains("Checking"));
103+
assert!(stderr.contains("Finished"));
104+
105+
// Make sure Cargo is aware of the new `--cfg` flag.
106+
lint_path_dep();
107+
}

clippy_workspace_tests/Cargo.toml renamed to tests/workspace_test/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "clippy_workspace_tests"
2+
name = "workspace_test"
33
version = "0.1.0"
44
edition = "2018"
55

File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)