Skip to content

Commit

Permalink
syntax: move error test to syntax crate
Browse files Browse the repository at this point in the history
The problem with putting it in the regex crate proper is that it
requires the regex crate to bump its minimal regex-syntax crate version.
While this isn't necessarily an issue, since we can't enable Cargo's
minimal version check because of the `rand` dependency, this winds up
being a hazard. Plus, having it in the regex crate doesn't buy us too
much. It's just as well to have the tests in regex-syntax.

Fixes #593
  • Loading branch information
BurntSushi committed Jul 6, 2019
1 parent 5b773b1 commit 886a7e7
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 23 deletions.
15 changes: 12 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
1.1.9 (2019-07-06)
==================
This release contains a bug fix that caused regex's tests to fail, due to a
dependency on an unreleased behavior in regex-syntax.

* [BUG #593](https://github.com/rust-lang/regex/issues/593):
Move an integration-style test on error messages into regex-syntax.


1.1.8 (2019-07-04)
==================
This release contains a few small internal refactorings. One of which fixes
an instance of undefined behavior in a part of the SIMD code.

Bug fixes:

* [BUG #545](https://github.com/rust-lang/regex/pull/545):
* [BUG #545](https://github.com/rust-lang/regex/issues/545):
Improves error messages when a repetition operator is used without a number.
* [BUG #588](https://github.com/rust-lang/regex/pull/588):
* [BUG #588](https://github.com/rust-lang/regex/issues/588):
Removes use of a repr(Rust) union used for type punning in the Teddy matcher.
* [BUG #591](https://github.com/rust-lang/regex/pull/591):
* [BUG #591](https://github.com/rust-lang/regex/issues/591):
Update docs for running benchmarks and improve failure modes.


Expand Down
23 changes: 23 additions & 0 deletions regex-syntax/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,34 @@ fn repeat_char(c: char, count: usize) -> String {
mod tests {
use ast::parse::Parser;

fn assert_panic_message(pattern: &str, expected_msg: &str) -> () {
let result = Parser::new().parse(pattern);
match result {
Ok(_) => {
panic!("regex should not have parsed");
}
Err(err) => {
assert_eq!(err.to_string(), expected_msg.trim());
}
}
}

// See: https://github.com/rust-lang/regex/issues/464
#[test]
fn regression_464() {
let err = Parser::new().parse("a{\n").unwrap_err();
// This test checks that the error formatter doesn't panic.
assert!(!err.to_string().is_empty());
}

// See: https://github.com/rust-lang/regex/issues/545
#[test]
fn repetition_quantifier_expects_a_valid_decimal() {
assert_panic_message(r"\\u{[^}]*}", r#"
regex parse error:
\\u{[^}]*}
^
error: repetition quantifier expects a valid decimal
"#);
}
}
19 changes: 0 additions & 19 deletions tests/error_messages.rs

This file was deleted.

1 change: 0 additions & 1 deletion tests/test_default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ mod suffix_reverse;
mod unicode;
mod word_boundary;
mod word_boundary_unicode;
mod error_messages;

#[test]
fn disallow_non_utf8() {
Expand Down

0 comments on commit 886a7e7

Please sign in to comment.