fix(stat): Collection of fixes for stat(1)#9078
Conversation
CodSpeed Performance ReportMerging #9078 will not alter performanceComparing Summary
Footnotes
|
|
I mean, that's not my fault lol. |
|
GNU testsuite comparison: |
|
I think it'd be better to add tests for the device number and the percent escape issues as well. For the percent escape issue, I propose the following addition to #[test]
fn test_double_percent() {
let ts = TestScenario::new(util_name!());
let result = ts.ucmd().args(&["-c", "%%m", "/"]).succeeds();
let output = result.stdout_str().trim();
assert!(!output.is_empty(), "Escaped percent should be present");
assert_eq!(output, "%m");
}For the device number format issue, I'd add |
|
Yeah I agree, I'll add a few tests :). Ngl, I was trying to cut that corner cuz tomorrow I got an exam, but it should be quick enough. |
|
Testing the value of these flags ( |
|
GNU testsuite comparison: |
|
Those CI fails are still not my fault :) Also, I'll probably be opening a few PRs with perf improvements, passes of clippy nightly, and I'll probably refactor stat's format parser so it's less spaghetti-y; iirc stat is not the only coreutil that does use percent escaping (ls, date, du and printf come to my mind) so I feel strongly like adding a general impl to |
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
|
a bunch of jobs are still failing |
|
GNU testsuite comparison: |
Correct me if I'm wrong, but it doesn't seem like any of the CI failures are related to the PR. Previously it was a bunch of cancelled jobs and a couple of network failures on rustup, and now it seems to be just a few unrelated failures? It's weird, because this does not touch uucore or anything that's shared across utils. |
|
@sylvestre You menace, CI is gonna be busy for hours LOL... (4h and still counting...) /jk |
Yeah, I rebased almost all pr |
|
See https://app.codecov.io/gh/uutils/coreutils/pull/9078?dropdown=coverage&src=pr&el=h1 for the tests improvements |
|
please update mknod.rs also |
There is also a makedev libc function, so it seems we can just use that. |
|
I'll get to the FreeBSD shenanigans in a minute, after I'm done writing the extra tests. |
c8064eb to
fca942a
Compare
|
GNU testsuite comparison: |
This comment was marked as resolved.
This comment was marked as resolved.
c056b65 to
07ade8b
Compare
This comment was marked as resolved.
This comment was marked as resolved.
|
GNU testsuite comparison: |
|
Should we add those two failing GNU tests ( |
Fixes issue uutils#9072, where some AppArmor profiles designed for GNU coreutils would break under uutils because we would fetch this info unnecessarily.
Fixes issue uutils#9071, where the default options for the `Device` field where incorrect, as well as several format flags that were not working as intended: %R, %Hr, %Lr, %Hd, %Ld, %t.
Previosuly, stat would ignore the next char after escaping it; e.g., "%%m" would become "%" instead of literally "%m".
Now uucore::fs reexports libc's major(), minor() and makedev() directives.
|
GNU testsuite comparison: |
|
@sylvestre do you think this is ready to be merged or would any like any other changes? Lmk if I can help in any way. |
|
@sylvestre I mean, it's done as an integration test in |
|
seems that the coverage isn't picking this then ? :) |
@sylvestre yeah, it does make sense because 613e9be tests the options as a raw string, tho I don't think there's really a better way to do this with the current stat codebase. It turns out that to do it as a unit test we have to construct a whole |
|
Ok |
|
Thanks! |
To you! I'm sorry I had unnecessarily made the PR harder to review on accident... Anyway, thanks for merging this! |
|
this seem to have solved a long standing issue I've had with |

This PR fixes #9071, #9072, as well as a few bugs found along the way.