Skip to content

Commit 98ef12e

Browse files
committed
run global filters before file local filters
1 parent 6386512 commit 98ef12e

File tree

12 files changed

+56
-38
lines changed

12 files changed

+56
-38
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515

1616
### Removed
1717

18+
## [0.26.2] - 2024-09-08
19+
20+
### Added
21+
22+
### Fixed
23+
24+
* The order of normalizations and other settings is now that individual tests' normalizations get applied after the global normalizations.
25+
26+
### Changed
27+
28+
### Removed
29+
1830
## [0.26.0] - 2024-09-07
1931

2032
### Added

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ui_test"
3-
version = "0.26.1"
3+
version = "0.26.2"
44
edition = "2021"
55
license = "MIT OR Apache-2.0"
66
description = "A test framework for testing rustc diagnostics output"

src/parser.rs

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,11 @@ impl Comments {
8585

8686
/// Returns an iterator over all revisioned comments that match the revision.
8787
pub fn for_revision<'a>(&'a self, revision: &'a str) -> impl Iterator<Item = &'a Revisioned> {
88-
self.revisioned.iter().filter_map(move |(k, v)| {
89-
if k.is_empty() || k.iter().any(|rev| rev == revision) {
90-
Some(v)
91-
} else {
92-
None
93-
}
94-
})
88+
[&self.revisioned[&[][..]]].into_iter().chain(
89+
self.revisioned
90+
.iter()
91+
.filter_map(move |(k, v)| k.iter().any(|rev| rev == revision).then_some(v)),
92+
)
9593
}
9694

9795
/// The comments set for all revisions
@@ -319,7 +317,9 @@ impl CommentParser<Comments> {
319317
}
320318

321319
fn parse(mut self, content: Spanned<&[u8]>) -> std::result::Result<Comments, Vec<Error>> {
322-
let defaults = std::mem::take(self.comments.revisioned.get_mut(&[][..]).unwrap());
320+
// We take out the existing flags so that we can ensure every test only sets them once
321+
// by checking that they haven't already been set.
322+
let mut defaults = std::mem::take(self.comments.revisioned.get_mut(&[][..]).unwrap());
323323

324324
let mut delayed_fallthrough = Vec::new();
325325
let mut fallthrough_to = None; // The line that a `|` will refer to.
@@ -422,36 +422,42 @@ impl CommentParser<Comments> {
422422
require_annotations,
423423
diagnostic_code_prefix,
424424
custom,
425-
} = self.comments.base();
425+
} = &mut defaults;
426+
427+
// We insert into the defaults so that the defaults are first in case of sorted lists
428+
// like `normalize_stderr`, `compile_flags`, or `env_vars`
429+
let base = std::mem::take(self.comments.base());
426430
if span.is_dummy() {
427-
*span = defaults.span;
431+
*span = base.span;
428432
}
429-
ignore.extend(defaults.ignore);
430-
only.extend(defaults.only);
431-
*stderr_per_bitwidth |= defaults.stderr_per_bitwidth;
432-
compile_flags.extend(defaults.compile_flags);
433-
env_vars.extend(defaults.env_vars);
434-
normalize_stderr.extend(defaults.normalize_stderr);
435-
normalize_stdout.extend(defaults.normalize_stdout);
436-
error_in_other_files.extend(defaults.error_in_other_files);
437-
error_matches.extend(defaults.error_matches);
438-
if require_annotations_for_level.is_none() {
439-
*require_annotations_for_level = defaults.require_annotations_for_level;
433+
ignore.extend(base.ignore);
434+
only.extend(base.only);
435+
*stderr_per_bitwidth |= base.stderr_per_bitwidth;
436+
compile_flags.extend(base.compile_flags);
437+
env_vars.extend(base.env_vars);
438+
normalize_stderr.extend(base.normalize_stderr);
439+
normalize_stdout.extend(base.normalize_stdout);
440+
error_in_other_files.extend(base.error_in_other_files);
441+
error_matches.extend(base.error_matches);
442+
if base.require_annotations_for_level.is_some() {
443+
*require_annotations_for_level = base.require_annotations_for_level;
440444
}
441-
if exit_status.is_none() {
442-
*exit_status = defaults.exit_status;
445+
if base.exit_status.is_some() {
446+
*exit_status = base.exit_status;
443447
}
444-
if require_annotations.is_none() {
445-
*require_annotations = defaults.require_annotations;
448+
if base.require_annotations.is_some() {
449+
*require_annotations = base.require_annotations;
446450
}
447-
if diagnostic_code_prefix.is_none() {
448-
*diagnostic_code_prefix = defaults.diagnostic_code_prefix;
451+
if base.diagnostic_code_prefix.is_some() {
452+
*diagnostic_code_prefix = base.diagnostic_code_prefix;
449453
}
450454

451-
for (k, v) in defaults.custom {
455+
for (k, v) in base.custom {
452456
custom.entry(k).or_insert(v);
453457
}
454458

459+
*self.base() = defaults;
460+
455461
if self.errors.is_empty() {
456462
Ok(self.comments)
457463
} else {

tests/integrations/basic-bin/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/integrations/basic-fail-mode/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/integrations/basic-fail/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/integrations/basic-fail/tests/actual_tests_bless/normalization_override.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0425]: cannot find value `asdf` in this scope
2-
--> tests/actual_tests_bless/NORMALIZATION_OVERRIDE.rs:6:5
2+
--> tests/actual_tests_bless/SUCCESS.rs:6:5
33
|
44
6 | asdf
55
| ^^^^ not found in this scope

tests/integrations/basic/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/integrations/cargo-run/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)