Skip to content

Commit 87c682a

Browse files
committed
Auto merge of #6743 - rust-lang:update-compiletest, r=Manishearth
Upgrade compiletest-rs to 0.6 and tester to 0.9 These updates allow us to specify multiple testnames for `TESTNAME` by providing a comma separated list of testnames. The new version of compiletest-rs also includes `bless` support, but is not enabled with this PR. cc #5394 changelog: none
2 parents 2f19f5f + 7226291 commit 87c682a

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ tempfile = { version = "3.1.0", optional = true }
3737

3838
[dev-dependencies]
3939
cargo_metadata = "0.12"
40-
compiletest_rs = { version = "0.5.0", features = ["tmp"] }
41-
tester = "0.7"
40+
compiletest_rs = { version = "0.6.0", features = ["tmp"] }
41+
tester = "0.9"
4242
clippy-mini-macro-test = { version = "0.2", path = "mini-macro" }
4343
serde = { version = "1.0", features = ["derive"] }
4444
derive-new = "0.5"

doc/adding_lints.md

+3
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ should only commit files changed by `cargo dev bless` for the
108108
specific lint you are creating/editing. Note that if the generated files are
109109
empty, they should be removed.
110110

111+
Note that you can run multiple test files by specifying a comma separated list:
112+
`TESTNAME=foo_functions,test2,test3`.
113+
111114
### Cargo lints
112115

113116
For cargo lints, the process of testing differs in that we are interested in

tests/compile-test.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ fn third_party_crates() -> String {
6666
fn default_config() -> compiletest::Config {
6767
let mut config = compiletest::Config::default();
6868

69-
if let Ok(name) = env::var("TESTNAME") {
70-
config.filter = Some(name);
69+
if let Ok(filters) = env::var("TESTNAME") {
70+
config.filters = filters.split(',').map(std::string::ToString::to_string).collect();
7171
}
7272

7373
if let Some(path) = option_env!("RUSTC_LIB_PATH") {
@@ -167,7 +167,7 @@ fn run_ui_toml(config: &mut compiletest::Config) {
167167
fn run_ui_cargo(config: &mut compiletest::Config) {
168168
fn run_tests(
169169
config: &compiletest::Config,
170-
filter: &Option<String>,
170+
filters: &[String],
171171
mut tests: Vec<tester::TestDescAndFn>,
172172
) -> Result<bool, io::Error> {
173173
let mut result = true;
@@ -181,9 +181,10 @@ fn run_ui_cargo(config: &mut compiletest::Config) {
181181

182182
// Use the filter if provided
183183
let dir_path = dir.path();
184-
match &filter {
185-
Some(name) if !dir_path.ends_with(name) => continue,
186-
_ => {},
184+
for filter in filters {
185+
if !dir_path.ends_with(filter) {
186+
continue;
187+
}
187188
}
188189

189190
for case in fs::read_dir(&dir_path)? {
@@ -243,8 +244,7 @@ fn run_ui_cargo(config: &mut compiletest::Config) {
243244

244245
let current_dir = env::current_dir().unwrap();
245246
let conf_dir = var("CLIPPY_CONF_DIR").unwrap_or_default();
246-
let filter = env::var("TESTNAME").ok();
247-
let res = run_tests(&config, &filter, tests);
247+
let res = run_tests(&config, &config.filters, tests);
248248
env::set_current_dir(current_dir).unwrap();
249249
set_var("CLIPPY_CONF_DIR", conf_dir);
250250

0 commit comments

Comments
 (0)