Skip to content

Commit 162e2ff

Browse files
committed
[nextest-runner] update aho-corasick to 1.0.0
1 parent 96b4f0a commit 162e2ff

File tree

8 files changed

+48
-27
lines changed

8 files changed

+48
-27
lines changed

Cargo.lock

Lines changed: 2 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cargo-nextest/src/dispatch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ impl TestBuildFilter {
531531
self.partition.clone(),
532532
&patterns,
533533
filter_exprs,
534-
))
534+
)?)
535535
}
536536

537537
fn merge_test_binary_args(

cargo-nextest/src/errors.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ pub enum ExpectedError {
6262
#[from]
6363
err: ConfigParseError,
6464
},
65+
#[error("test filter build error")]
66+
TestFilterBuilderError {
67+
#[from]
68+
err: TestFilterBuilderError,
69+
},
6570
#[error("unknown host platform")]
6671
UnknownHostPlatform {
6772
#[from]
@@ -325,6 +330,7 @@ impl ExpectedError {
325330
| Self::RootManifestNotFound { .. }
326331
| Self::CargoConfigError { .. }
327332
| Self::ConfigParseError { .. }
333+
| Self::TestFilterBuilderError { .. }
328334
| Self::UnknownHostPlatform { .. }
329335
| Self::ArgumentFileReadError { .. }
330336
| Self::UnknownArchiveFormat { .. }
@@ -476,6 +482,10 @@ impl ExpectedError {
476482
}
477483
}
478484
}
485+
Self::TestFilterBuilderError { err } => {
486+
log::error!("{err}");
487+
err.source()
488+
}
479489
Self::UnknownHostPlatform { err } => {
480490
log::error!("the host platform was unknown to nextest");
481491
Some(err as &dyn Error)

nextest-runner/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ rust-version = "1.66"
1313

1414
[dependencies]
1515
atomicwrites = "0.4.1"
16-
aho-corasick = "0.7.20"
16+
aho-corasick = "1.0.1"
1717
async-scoped = { version = "0.7.1", features = ["use-tokio"] }
1818
future-queue = "0.3.0"
1919
bytes = "1.4.0"

nextest-runner/src/errors.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,19 @@ impl fmt::Display for PartitionerBuilderParseError {
300300
}
301301
}
302302

303+
/// An error that occures while operating on a
304+
/// [`TestFilterBuilder`](crate::test_filter::TestFilterBuilder).
305+
#[derive(Clone, Debug, Error)]
306+
pub enum TestFilterBuilderError {
307+
/// An error that occured while constructing test filters.
308+
#[error("error constructing test filters")]
309+
Construct {
310+
/// The underlying error.
311+
#[from]
312+
error: aho_corasick::BuildError,
313+
},
314+
}
315+
303316
/// An error occurred in [`PathMapper::new`](crate::reuse_build::PathMapper::new).
304317
#[derive(Debug, Error)]
305318
pub enum PathMapperConstructError {

nextest-runner/src/list/test_list.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,8 @@ mod tests {
970970
iter::empty::<String>(),
971971
// Test against the platform() predicate because this is the most important one here.
972972
vec![FilteringExpr::parse("platform(target)", &PACKAGE_GRAPH_FIXTURE).unwrap()],
973-
);
973+
)
974+
.unwrap();
974975
let fake_cwd: Utf8PathBuf = "/fake/cwd".into();
975976
let fake_binary_name = "fake-binary".to_owned();
976977
let fake_binary_id = RustBinaryId::new("fake-package::fake-binary");

nextest-runner/src/test_filter.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
// result
1111

1212
use crate::{
13+
errors::TestFilterBuilderError,
1314
helpers::convert_build_platform,
1415
list::RustTestArtifact,
1516
partition::{Partitioner, PartitionerBuilder},
@@ -77,24 +78,24 @@ impl TestFilterBuilder {
7778
partitioner_builder: Option<PartitionerBuilder>,
7879
patterns: impl IntoIterator<Item = impl Into<String>>,
7980
exprs: Vec<FilteringExpr>,
80-
) -> Self {
81+
) -> Result<Self, TestFilterBuilderError> {
8182
let mut patterns: Vec<_> = patterns.into_iter().map(|s| s.into()).collect();
8283
patterns.sort_unstable();
8384

8485
let name_match = if patterns.is_empty() {
8586
NameMatch::EmptyPatterns
8687
} else {
87-
let matcher = Box::new(AhoCorasick::new_auto_configured(&patterns));
88+
let matcher = Box::new(AhoCorasick::new(&patterns)?);
8889

8990
NameMatch::MatchSet { patterns, matcher }
9091
};
9192

92-
Self {
93+
Ok(Self {
9394
run_ignored,
9495
partitioner_builder,
9596
name_match,
9697
exprs,
97-
}
98+
})
9899
}
99100

100101
/// Creates a new `TestFilterBuilder` that matches any pattern by name.
@@ -315,7 +316,7 @@ mod tests {
315316
#[test]
316317
fn proptest_empty(test_names in vec(any::<String>(), 0..16)) {
317318
let patterns: &[String] = &[];
318-
let test_filter = TestFilterBuilder::new(RunIgnored::Default, None, patterns, Vec::new());
319+
let test_filter = TestFilterBuilder::new(RunIgnored::Default, None, patterns, Vec::new()).unwrap();
319320
let single_filter = test_filter.build();
320321
for test_name in test_names {
321322
prop_assert!(single_filter.filter_name_match(&test_name).is_match());
@@ -325,7 +326,7 @@ mod tests {
325326
// Test that exact names match.
326327
#[test]
327328
fn proptest_exact(test_names in vec(any::<String>(), 0..16)) {
328-
let test_filter = TestFilterBuilder::new(RunIgnored::Default, None, &test_names, Vec::new());
329+
let test_filter = TestFilterBuilder::new(RunIgnored::Default, None, &test_names, Vec::new()).unwrap();
329330
let single_filter = test_filter.build();
330331
for test_name in test_names {
331332
prop_assert!(single_filter.filter_name_match(&test_name).is_match());
@@ -344,7 +345,7 @@ mod tests {
344345
patterns.push(substring);
345346
}
346347

347-
let test_filter = TestFilterBuilder::new(RunIgnored::Default, None, &patterns, Vec::new());
348+
let test_filter = TestFilterBuilder::new(RunIgnored::Default, None, &patterns, Vec::new()).unwrap();
348349
let single_filter = test_filter.build();
349350
for test_name in test_names {
350351
prop_assert!(single_filter.filter_name_match(&test_name).is_match());
@@ -360,7 +361,7 @@ mod tests {
360361
) {
361362
prop_assume!(!substring.is_empty() && !(prefix.is_empty() && suffix.is_empty()));
362363
let pattern = prefix + &substring + &suffix;
363-
let test_filter = TestFilterBuilder::new(RunIgnored::Default, None, [pattern], Vec::new());
364+
let test_filter = TestFilterBuilder::new(RunIgnored::Default, None, [pattern], Vec::new()).unwrap();
364365
let single_filter = test_filter.build();
365366
prop_assert!(!single_filter.filter_name_match(&substring).is_match());
366367
}

nextest-runner/tests/integration/basic.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ fn test_run_ignored() -> Result<()> {
189189
None,
190190
Vec::<String>::new(),
191191
vec![expr],
192-
);
192+
)
193+
.unwrap();
193194
let test_list = FIXTURE_TARGETS.make_test_list(&test_filter, &TargetRunner::empty());
194195
let config = load_config();
195196
let profile = config
@@ -264,7 +265,8 @@ fn test_filter_expr_with_string_filters() -> Result<()> {
264265
None,
265266
["call_dylib_add_two", "test_flaky_mod_4"],
266267
vec![expr],
267-
);
268+
)
269+
.unwrap();
268270
let test_list = FIXTURE_TARGETS.make_test_list(&test_filter, &TargetRunner::empty());
269271
for test in test_list.iter_tests() {
270272
if test.name == "tests::call_dylib_add_two" {
@@ -322,7 +324,8 @@ fn test_filter_expr_without_string_filters() -> Result<()> {
322324
.expect("filter expression is valid");
323325

324326
let test_filter =
325-
TestFilterBuilder::new(RunIgnored::Default, None, Vec::<String>::new(), vec![expr]);
327+
TestFilterBuilder::new(RunIgnored::Default, None, Vec::<String>::new(), vec![expr])
328+
.unwrap();
326329
let test_list = FIXTURE_TARGETS.make_test_list(&test_filter, &TargetRunner::empty());
327330
for test in test_list.iter_tests() {
328331
if test.name.contains("test_multiply_two") || test.name == "tests::call_dylib_add_two" {
@@ -350,7 +353,8 @@ fn test_string_filters_without_filter_expr() -> Result<()> {
350353
None,
351354
vec!["test_multiply_two", "tests::call_dylib_add_two"],
352355
vec![],
353-
);
356+
)
357+
.unwrap();
354358
let test_list = FIXTURE_TARGETS.make_test_list(&test_filter, &TargetRunner::empty());
355359
for test in test_list.iter_tests() {
356360
if test.name.contains("test_multiply_two")
@@ -528,7 +532,8 @@ fn test_termination() -> Result<()> {
528532
None,
529533
Vec::<String>::new(),
530534
vec![expr],
531-
);
535+
)
536+
.unwrap();
532537

533538
let test_list = FIXTURE_TARGETS.make_test_list(&test_filter, &TargetRunner::empty());
534539
let config = load_config();

0 commit comments

Comments
 (0)