Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expr: Fix assorted test errors in tests/expr/expr.pl #6134

Merged
merged 10 commits into from
Jan 19, 2025

Conversation

sargas
Copy link
Contributor

@sargas sargas commented Mar 26, 2024

This PR makes several changes to expr:

  1. Instead of giving a "missing argument" error if a closing parenthesis could not be found (through the ? operator on a call to .next()), this PR gives an error indicating that we were looking for a missing closing parenthesis. We also now say when a parenthesis should have been seen if that's not the end of the arguments.
  2. If we are matching a pattern that doesn't match yet is optional (e.g., with a ? or *), then the regex does match but there's no captured groups; causing a panic in the current logic. This PR changes the behavior to treat an empty match as the empty string.
  3. Regular expressions in match expressions are scanned for some validation errors, including by directly parsing any intervals to be sure the same error message is displayed.

These changes fix many of the test failures in GNU's tests/expr/expr.pl.

There's other test failures due to the regular expressions not matching correctly, but the oniguruma library should have fixes for that in the next release[1][2].

@sargas sargas force-pushed the expr-error-messages branch from 85f838b to 613ab2a Compare March 26, 2024 03:19
@sylvestre sylvestre force-pushed the expr-error-messages branch from f4d7a06 to c2d17a1 Compare March 30, 2024 21:51
Copy link

GNU testsuite comparison:

GNU test failed: tests/timeout/timeout. tests/timeout/timeout is passing on 'main'. Maybe you have to rebase?

@sargas sargas marked this pull request as draft March 31, 2024 04:13
@sargas sargas force-pushed the expr-error-messages branch 2 times, most recently from 419ee88 to 036e428 Compare April 4, 2024 04:48
@sargas sargas changed the title expr: Fix non-regex related test errors in tests/expr/expr.pl expr: Fix assorted test errors in tests/expr/expr.pl Apr 4, 2024
@sargas sargas marked this pull request as ready for review April 4, 2024 04:54
Copy link

github-actions bot commented Apr 4, 2024

GNU testsuite comparison:

Skip an intermittent issue tests/tail/inotify-dir-recreate (fails in this run but passes in the 'main' branch)

/// differently from the oniguruma library used by the regex crate.
/// This method attempts to do these checks manually in one pass
/// through the regular expression.
fn validate_regex(pattern: &str) -> ExprResult<()> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there isn't any crate doing it already ?

Copy link
Contributor Author

@sargas sargas Apr 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so? Regex (and related) crates don't use posix syntax. tests/expr/expr.pl does check that \{ and { are treated opposite of how they would be in the regex crate

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe rename this function to make it more specific ?
like
validate_regex_posix?

@sargas sargas force-pushed the expr-error-messages branch from 764a06c to 6e38843 Compare April 4, 2024 13:54
Copy link

github-actions bot commented Apr 4, 2024

GNU testsuite comparison:

Skip an intermittent issue tests/rm/rm1 (fails in this run but passes in the 'main' branch)

@sargas sargas force-pushed the expr-error-messages branch from 6e38843 to 7de320c Compare April 5, 2024 04:02
Copy link

github-actions bot commented Apr 5, 2024

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)

@sargas sargas force-pushed the expr-error-messages branch from 7de320c to e166030 Compare April 5, 2024 05:31
Copy link

github-actions bot commented Apr 5, 2024

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)

@sargas sargas force-pushed the expr-error-messages branch from e166030 to abaf93d Compare April 9, 2024 03:02
let mut repetition = repeating_pattern_text[..repeating_pattern_text.len() - 1]
.splitn(2, |x| x == ',');
match (repetition.next(), repetition.next()) {
(None, None) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i see 3 paths that the code coverage can't reach, is it possible to add tests to cover it? thanks

@sargas sargas force-pushed the expr-error-messages branch from abaf93d to 72ba10c Compare May 15, 2024 02:35
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)

Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/tail/inotify-dir-recreate (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/timeout/timeout is no longer failing!

@sargas sargas force-pushed the expr-error-messages branch from 6b7e932 to 8c27c7f Compare January 19, 2025 11:19
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)

@sylvestre
Copy link
Contributor

crap, i forgot about this PR when I worked on this: github.com//pull/7119
I will close mine and see what I can salvage

@sylvestre sylvestre merged commit 34421f5 into uutils:main Jan 19, 2025
65 checks passed
@sargas
Copy link
Contributor Author

sargas commented Jan 19, 2025

@sylvestre hah, I should have checked if there was any expr PRs in progress before updating this too! There are at least two test failures that should be fixed with the version of Oniguruma released a few weeks ago FWIW

@sylvestre
Copy link
Contributor

@sargas no worries, I wrote enough code on this project :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants