Skip to content

Conversation

drinkcat
Copy link
Collaborator

@drinkcat drinkcat commented Jul 23, 2025

Fixes #8357 (there's... a third part, basename has been fixed already)

The gnu test tests/df/problematic-chars is no longer failing!

I can't easily add a unit test for df --output=target "$mnt" though, as that require mounting a filesystem in a weird location, but at least some fsext test should cover some part of that.

The Windows implementation needs to be fixed as well, but at least it's not worse now, than it used to be.

Quite a bit of surgery in df needed to make it print bytes...


df: table: Add test for non-Unicode printing

test_df: Use lossy stdout string

The tests fail when a non-UTF8 path is mounted, that's... not a
common case, but using a lossy string works just as well for the
tests, so let's use that.

df: table: Print raw bytes

Final step, let's just print the raw bytes now.

df: table: Move from fmt to a non-standard write_to

Will allow us to write u8 slices directly.

Also move the last \n print to the function, simplifying the loop.

df: table: Collect byte slices for Cell element

Also pre-record the cell width as getting it back in the printing
function would require some conversion back to a String.

uucore: fsext: Fix Windows/Mac

Windows handling can be done more properly, but I don't have
a machine to test this.

fsext: Add parsing test for non-unicode mount point

uucore: fsext: Change MountInfo's mount_root/dir to OsString

This is necessary to fix handling of non-Unicode filepath in df.

Note that other field might also need to be modified in the future.

df: Move to use OsString

This allows us to handle non-Unicode parameters.

@drinkcat drinkcat changed the title df: Move to using OsString df: Move to using OsString (DRAFT) Jul 23, 2025
@drinkcat
Copy link
Collaborator Author

Just noticed that I need to fix the output too, right now it's mangled:

[drinkcat@mydrinkcat coreutils]$ cargo run df --output=target "$mnt" | hexdump -C
00000000  4d 6f 75 6e 74 65 64 20  6f 6e 0a 2f 68 6f 6d 65  |Mounted on./home|
00000010  2f 64 72 69 6e 6b 63 61  74 2f 64 65 76 2f 63 6f  |/drinkcat/dev/co|
00000020  72 65 75 74 69 6c 73 2f  63 6f 72 65 75 74 69 6c  |reutils/coreutil|
00000030  73 2f 6d ef bf bd 75 6e  74 20 70 ef bf bd 69 6e  |s/m...unt p...in| <<< here, 3 chars
00000040  74 0a                                             |t.|
00000042
[drinkcat@mydrinkcat coreutils]$ df --output=target "$mnt" | hexdump -C
00000000  4d 6f 75 6e 74 65 64 20  6f 6e 0a 2f 68 6f 6d 65  |Mounted on./home|
00000010  2f 64 72 69 6e 6b 63 61  74 2f 64 65 76 2f 63 6f  |/drinkcat/dev/co|
00000020  72 65 75 74 69 6c 73 2f  63 6f 72 65 75 74 69 6c  |reutils/coreutil|
00000030  73 2f 6d f3 75 6e 74 20  70 f3 69 6e 74 0a        |s/m.unt p.int.| <<< here, only 0xf3 as expected
0000003e

Copy link

GNU testsuite comparison:

GNU test failed: tests/df/problematic-chars. tests/df/problematic-chars 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)

Copy link

GNU testsuite comparison:

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

drinkcat added 4 commits July 24, 2025 09:26
This allows us to handle non-Unicode parameters.
This is necessary to fix handling of non-Unicode filepath in `df`.

Note that other field might also need to be modified in the future.
Windows handling can be done more properly, but I don't have
a machine to test this.
drinkcat added 5 commits July 24, 2025 09:39
Also pre-record the cell width as getting it back in the printing
function would require some conversion back to a String.
Will allow us to write u8 slices directly.

Also move the last \n print to the function, simplifying the loop.
Final step, let's just print the raw bytes now.
The tests fail when a non-UTF8 path is mounted, that's... not a
common case, but using a lossy string works just as well for the
tests, so let's use that.
Copy link

GNU testsuite comparison:

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

@drinkcat drinkcat changed the title df: Move to using OsString (DRAFT) df: Move to using OsString Jul 24, 2025
@drinkcat
Copy link
Collaborator Author

Should be good to go (just did a little bit of commit message cleanup, and added some tests)

Copy link

GNU testsuite comparison:

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

@cakebaker cakebaker merged commit d1ec00f into uutils:main Jul 24, 2025
116 of 117 checks passed
@cakebaker
Copy link
Contributor

Congrats! The gnu test tests/df/problematic-chars is no longer failing!

Kudos, and thanks!

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.

df/problematic-chars skip/fail (mkdir+df issues)
2 participants