Skip to content

Commit 92b5009

Browse files
committed
test_file_conditions does not need access to TestStatus
1 parent f06625f commit 92b5009

File tree

2 files changed

+23
-26
lines changed

2 files changed

+23
-26
lines changed

src/config.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,28 @@ impl Config {
286286
Condition::OnHost => self.host_matches(target),
287287
}
288288
}
289+
290+
/// Returns whether according to the in-file conditions, this file should be run.
291+
pub fn test_file_conditions(&self, comments: &Comments, revision: &str) -> bool {
292+
if comments
293+
.for_revision(revision)
294+
.flat_map(|r| r.ignore.iter())
295+
.any(|c| self.test_condition(c))
296+
{
297+
return self.run_only_ignored;
298+
}
299+
if comments
300+
.for_revision(revision)
301+
.any(|r| r.needs_asm_support && !self.has_asm_support())
302+
{
303+
return self.run_only_ignored;
304+
}
305+
comments
306+
.for_revision(revision)
307+
.flat_map(|r| r.only.iter())
308+
.all(|c| self.test_condition(c))
309+
^ self.run_only_ignored
310+
}
289311
}
290312

291313
#[derive(Debug, Clone)]

src/lib.rs

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ fn parse_and_test_file(
389389
.map(|revision| {
390390
let status = status.for_revision(revision);
391391
// Ignore file if only/ignore rules do (not) apply
392-
if !status.test_file_conditions(&comments, &config) {
392+
if !config.test_file_conditions(&comments, revision) {
393393
return TestRun {
394394
result: Ok(TestOk::Ignored),
395395
status,
@@ -1211,31 +1211,6 @@ fn output_path(
12111211
path.with_extension(kind)
12121212
}
12131213

1214-
impl dyn TestStatus {
1215-
/// Returns whether according to the in-file conditions, this file should be run.
1216-
fn test_file_conditions(&self, comments: &Comments, config: &Config) -> bool {
1217-
let revision = self.revision();
1218-
if comments
1219-
.for_revision(revision)
1220-
.flat_map(|r| r.ignore.iter())
1221-
.any(|c| config.test_condition(c))
1222-
{
1223-
return config.run_only_ignored;
1224-
}
1225-
if comments
1226-
.for_revision(revision)
1227-
.any(|r| r.needs_asm_support && !config.has_asm_support())
1228-
{
1229-
return config.run_only_ignored;
1230-
}
1231-
comments
1232-
.for_revision(revision)
1233-
.flat_map(|r| r.only.iter())
1234-
.all(|c| config.test_condition(c))
1235-
^ config.run_only_ignored
1236-
}
1237-
}
1238-
12391214
// Taken 1:1 from compiletest-rs
12401215
fn get_pointer_width(triple: &str) -> u8 {
12411216
if (triple.contains("64") && !triple.ends_with("gnux32") && !triple.ends_with("gnu_ilp32"))

0 commit comments

Comments
 (0)