test(df): make POSIX/PT/-h row parsing resilient to whitespace in source/mountpoint#265
Merged
Conversation
…in source/mountpoint
AlexandreYang
marked this pull request as ready for review
May 19, 2026 14:10
AlexandreYang
requested review from
astuyve,
julesmcrt,
matt-dz,
thieman and
val06
as code owners
May 19, 2026 14:10
julesmcrt
approved these changes
May 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TestDfDataRowsAreNumeric_POSIX,TestDfPercentFormat,TestDfTotalSumIsConsistent) parsed rows withstrings.Fields()+fields[len(fields)-N]indexing. That counts tokens from the end, so any row whose source (Mntfromname) or mount point (Mntonname) contains whitespace silently mis-attributes column values.blocks used avail capacitynumeric quartet. The anchor doesn't care how many tokens the source or mount point split into, so column identities stay correct regardless of embedded whitespace.-PT(TestDfTypeFilterMatchesAtLeastOne,TestDfExcludeTypeRemovesRows) and-h(TestDfHumanReadableHasNoDigits_AtLargeSizes) sibling tests that used the same fragile indexing.TestDfTotalSumIsConsistentnow skips (rather than fails) if any data row is non-standard, since the per-row sum can't be bounded against the implementation's total when some rows aren't parseable.Test plan
go test -race -timeout 60s ./builtins/df/passes locally on macOSmap auto_home(space in source), hypothesized Cryptex shapes (space in source and/or mountpath), sources with embedded digits (/dev/disk1s5),-capacity sentinel, total row,-PTrows with the fstype columnmake fmtclean