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: improve the detection of errors #7119

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

sylvestre
Copy link
Contributor

Reduces the number of remaining issues in tests/expr/expr.pl

Copy link

GNU testsuite comparison:

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

@sylvestre sylvestre marked this pull request as draft January 11, 2025 12:09
@sylvestre sylvestre force-pushed the expr_pl branch 2 times, most recently from 535c98c to 980b287 Compare January 11, 2025 12:23
Copy link

GNU testsuite comparison:

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

@sylvestre sylvestre force-pushed the expr_pl branch 5 times, most recently from d21dbe6 to 8fae3c2 Compare January 11, 2025 15:33
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)

Copy link

GNU testsuite comparison:

Congrats! The gnu test tests/misc/stdbuf is no longer failing!
Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)

parts[1].trim().parse::<u32>(),
) {
// Ensure both numbers are within valid range and first <= second
first <= second && first <= 32767 && second <= 32767
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure whether this is an improvement, but from a logical point of view the middle check is not necessary.

Suggested change
first <= second && first <= 32767 && second <= 32767
first <= second && second <= 32767

@@ -197,6 +208,93 @@ const PRECEDENCE: &[&[(&str, BinOp)]] = &[
&[(":", BinOp::String(StringOp::Match))],
];

fn check_brace_content_and_matching(s: &str) -> BraceContent {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this parser is not completely correct. It returns BraceContent::Invalid for the following edge cases whereas they seem to work with GNU expr:

$ expr ab : "\\{\\(\\}\\)"

$ expr ab : "\\(\\{\\)\\}"

$ cargo run -q expr ab : "\\{\\(\\}\\)"
expr: Invalid content of \{\}
$ cargo run -q expr ab : "\\(\\{\\)\\}"
expr: Invalid content of \{\}

But I think it's something for a future PR.

Copy link
Contributor

@cakebaker cakebaker left a comment

Choose a reason for hiding this comment

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

Overall it looks good.

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/misc/stdbuf is no longer failing!

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/timeout/timeout (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)

@sylvestre
Copy link
Contributor Author

comments fixed

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.

2 participants