Skip to content

Conversation

@sbentmar
Copy link
Contributor

@sbentmar sbentmar commented Dec 28, 2025

In #9752 several failures are caused by the error messages not matching GNU.

Some examples:

  • suf-5
  • suf-9
  • suf-10
  • suf-17
  • suf-18
  • ign-err-3
  • ign-err-4

This aligns the error message by adding a localization parameter for the incorrect suffix. It also checks whether the number would be valid if we were to remove the suffix, and returns a suffix error rather than a number error in those cases.

This lets the user know which specific suffix is invalid. If they for instance enter "5MS" it will tell them that the "S" is the invalid suffix, not the "M".

@sbentmar sbentmar marked this pull request as draft December 28, 2025 11:30
@github-actions
Copy link

GNU testsuite comparison:

Congrats! The gnu test tests/tail/follow-name is no longer failing!

@github-actions
Copy link

GNU testsuite comparison:

Congrats! The gnu test tests/tail/assert is no longer failing!

@sbentmar sbentmar marked this pull request as ready for review December 28, 2025 13:01
@github-actions
Copy link

GNU testsuite comparison:

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

@sbentmar sbentmar changed the title fix(numfmt): align error messages for suffixes numfmt: align error messages for suffixes Dec 28, 2025
@github-actions
Copy link

GNU testsuite comparison:

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

@github-actions
Copy link

GNU testsuite comparison:

Note: The gnu test tests/id/smack was skipped on 'main' but is now failing.
Note: The gnu test tests/mkdir/smack-no-root was skipped on 'main' but is now failing.
Note: The gnu test tests/mkdir/smack-root was skipped on 'main' but is now failing.

@sylvestre
Copy link
Contributor

please add tests in tests/by-util/test_numfmt.rs too

}
return Err(translate!("numfmt-error-invalid-suffix", "input" => s.quote()));

return Err(match parse_suffix(number_part) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Recursive call to parse_suffix() in error path - consider adding a comment explaining this won't cause stack overflow due to guaranteed termination

}

fn parse_suffix(s: &str) -> Result<(f64, Option<Suffix>)> {
fn find_numeric_beginning(s: &str) -> Option<&str> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This could be replaced with a regex, but I'm torn on whether it's worth pulling in an extra dependency for a fairly trivial task.

Copy link
Contributor

Choose a reason for hiding this comment

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

regex are slow

@github-actions
Copy link

GNU testsuite comparison:

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

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 30, 2025

CodSpeed Performance Report

Merging #9887 will not alter performance

Comparing sbentmar:fix-suf-errors (fdc93d1) with main (1eea517)

Summary

✅ 136 untouched
⏩ 24 skipped1

Footnotes

  1. 24 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@sbentmar sbentmar force-pushed the fix-suf-errors branch 2 times, most recently from 923bb5d to d307046 Compare December 30, 2025 17:24
@sylvestre
Copy link
Contributor

I guess parsing the numbers by hand regress the performances. I think we need to do better here

@sbentmar
Copy link
Contributor Author

I guess parsing the numbers by hand regress the performances. I think we need to do better here

I'll experiment a bit and see if I can improve it :)

@github-actions
Copy link

GNU testsuite comparison:

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

@github-actions
Copy link

GNU testsuite comparison:

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

@github-actions
Copy link

GNU testsuite comparison:

GNU test failed: tests/shuf/shuf-reservoir. tests/shuf/shuf-reservoir is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/sort/sort-stale-thread-mem. tests/sort/sort-stale-thread-mem is passing on 'main'. Maybe you have to rebase?
Congrats! The gnu test tests/tail/follow-name is no longer failing!

@sbentmar
Copy link
Contributor Author

I guess parsing the numbers by hand regress the performances. I think we need to do better here

It's bound to take longer since we need to look at the string, previously we only looked at the last character. I moved it out of the main flow though, so now it's only called when we want to generate an error message. Parsing manually is O(n), but since we need to know where the boundary between the valid and the invalid input is to generate compliant error messages, it's hard to avoid some performance regression.

@github-actions
Copy link

GNU testsuite comparison:

GNU test failed: tests/shuf/shuf-reservoir. tests/shuf/shuf-reservoir is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/sort/sort-stale-thread-mem. tests/sort/sort-stale-thread-mem is passing on 'main'. Maybe you have to rebase?
Congrats! The gnu test tests/cp/preserve-gid is no longer failing!

@github-actions
Copy link

GNU testsuite comparison:

GNU test failed: tests/shuf/shuf-reservoir. tests/shuf/shuf-reservoir is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/sort/sort-stale-thread-mem. tests/sort/sort-stale-thread-mem is passing on 'main'. Maybe you have to rebase?
Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)

@github-actions
Copy link

github-actions bot commented Jan 1, 2026

GNU testsuite comparison:

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

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