mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-21 18:38:08 +01:00
Prepend regerror() messages with "regexp error: "
The exact error messages returned by regerror() aren't standardized; relying on them isn't portable. Thus, add a a prefix to make clear that the subsequent message is a regexp parsing error, and only look for this prefix in the test suite, ignoring the rest of the message.
This commit is contained in:
parent
a1e649276e
commit
9f7e851263
2 changed files with 4 additions and 4 deletions
|
@ -35,9 +35,9 @@ compile_regex (regex_t ®exp, const char *str)
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
size_t len = regerror (err, ®exp, NULL, 0);
|
size_t len = regerror (err, ®exp, NULL, 0);
|
||||||
char *buffer = new char[len];
|
char *buffer = new char[len];
|
||||||
std::string msg;
|
std::string msg = "Regexp error: ";
|
||||||
(void) regerror (err, ®exp, buffer, len);
|
(void) regerror (err, ®exp, buffer, len);
|
||||||
msg.assign (buffer, len);
|
msg.append (buffer, len);
|
||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
|
|
||||||
throw Xapian::QueryParserError (msg);
|
throw Xapian::QueryParserError (msg);
|
||||||
|
|
|
@ -137,10 +137,10 @@ EOF
|
||||||
test_expect_equal_file EXPECTED OUTPUT
|
test_expect_equal_file EXPECTED OUTPUT
|
||||||
|
|
||||||
test_begin_subtest "regexp error reporting"
|
test_begin_subtest "regexp error reporting"
|
||||||
notmuch search 'from:/unbalanced[/' 1>OUTPUT 2>&1
|
notmuch search 'from:/unbalanced[/' 2>&1 | sed -e '/^A Xapian/ s/[^:]*$//' > OUTPUT
|
||||||
cat <<EOF > EXPECTED
|
cat <<EOF > EXPECTED
|
||||||
notmuch search: A Xapian exception occurred
|
notmuch search: A Xapian exception occurred
|
||||||
A Xapian exception occurred parsing query: Invalid regular expression
|
A Xapian exception occurred parsing query: Regexp error:
|
||||||
Query string was: from:/unbalanced[/
|
Query string was: from:/unbalanced[/
|
||||||
EOF
|
EOF
|
||||||
test_expect_equal_file EXPECTED OUTPUT
|
test_expect_equal_file EXPECTED OUTPUT
|
||||||
|
|
Loading…
Reference in a new issue