Skip to content

Conversation

@charlievieth
Copy link
Owner

@charlievieth charlievieth commented Aug 30, 2025

This change removes the platform specific integer parsing logic from internal/dirent and replaces it with binary.NativeEndian which is well tested and removes the need for us to maintain platform specific code. Additionally, it sets the minimum supported Go version to 1.21 which is required to use binary.NativeEndian.

Fixes: #61

This change removes the platform specific integer parsing logic from
internal/dirent and replaces it with binary.NativeEndian which is well
tested and removes the need for us to maintain platform specific code.

Fixes: #61
@codecov-commenter
Copy link

codecov-commenter commented Aug 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.20%. Comparing base (9a3941f) to head (743e1a7).

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #63      +/-   ##
==========================================
- Coverage   60.19%   59.20%   -1.00%     
==========================================
  Files          14       12       -2     
  Lines         824      804      -20     
==========================================
- Hits          496      476      -20     
  Misses        314      314              
  Partials       14       14              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

@QuLogic QuLogic left a comment

Choose a reason for hiding this comment

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

@charlievieth charlievieth merged commit c9ad02f into master Sep 2, 2025
17 checks passed
@QuLogic
Copy link

QuLogic commented Sep 3, 2025

Ah, unfortunately, the last commit pushed after I tested doesn't pass now.

github.com/charlievieth/fastwalk/internal/dirent
--- FAIL: TestReadInt (0.02s)
    --- FAIL: TestReadInt/1 (0.01s)
        dirent_test.go:38: readInt("\x00\x00\x00\x00\x00\x00\x00R", 0, 1) = 0, true; want: 82, true
        dirent_test.go:38: readInt("\x00\x00\x00\x00\x00\x00\x00O", 0, 1) = 0, true; want: 79, true
        dirent_test.go:38: readInt("\x00\x00\x00\x00\x00\x00\x00\x1d", 0, 1) = 0, true; want: 29, true
        dirent_test.go:38: readInt("\x00\x00\x00\x00\x00\x00\x00\x03", 0, 1) = 0, true; want: 3, true
        dirent_test.go:38: readInt("\x00\x00\x00\x00\x00\x00\x00\xd1", 0, 1) = 0, true; want: 209, true
        dirent_test.go:38: readInt("\x00\x00\x00\x00\x00\x00\x00\xd8", 0, 1) = 0, true; want: 216, true
        dirent_test.go:38: readInt("\x00\x00\x00\x00\x00\x00\x00\x1e", 0, 1) = 0, true; want: 30, true
        dirent_test.go:38: readInt("\x00\x00\x00\x00\x00\x00\x00\x94", 0, 1) = 0, true; want: 148, true
        dirent_test.go:38: readInt("\x00\x00\x00\x00\x00\x00\x00\xa0", 0, 1) = 0, true; want: 160, true
        dirent_test.go:38: readInt("\x00\x00\x00\x00\x00\x00\x00\x99", 0, 1) = 0, true; want: 153, true
        dirent_test.go:41: too many errors: 10
    --- FAIL: TestReadInt/2 (0.00s)
        dirent_test.go:38: readInt("\x00\x00\x00\x00\x00\x00\xd4\xd5", 0, 2) = 0, true; want: 54485, true
        dirent_test.go:38: readInt("\x00\x00\x00\x00\x00\x00\x88\x00", 0, 2) = 0, true; want: 34816, true
        dirent_test.go:38: readInt("\x00\x00\x00\x00\x00\x00{\x8a", 0, 2) = 0, true; want: 31626, true
        dirent_test.go:38: readInt("\x00\x00\x00\x00\x00\x004\x13", 0, 2) = 0, true; want: 13331, true
        dirent_test.go:38: readInt("\x00\x00\x00\x00\x00\x00\xe8s", 0, 2) = 0, true; want: 59507, true
        dirent_test.go:38: readInt("\x00\x00\x00\x00\x00\x00\x9fe", 0, 2) = 0, true; want: 40805, true
        dirent_test.go:38: readInt("\x00\x00\x00\x00\x00\x00L\xd4", 0, 2) = 0, true; want: 19668, true
        dirent_test.go:38: readInt("\x00\x00\x00\x00\x00\x00\xdc\r", 0, 2) = 0, true; want: 56333, true
        dirent_test.go:38: readInt("\x00\x00\x00\x00\x00\x00\xccz", 0, 2) = 0, true; want: 52346, true
        dirent_test.go:38: readInt("\x00\x00\x00\x00\x00\x00r_", 0, 2) = 0, true; want: 29279, true
        dirent_test.go:41: too many errors: 10
    --- FAIL: TestReadInt/4 (0.00s)
        dirent_test.go:38: readInt("\x00\x00\x00\x00Ub\x7fs", 0, 4) = 0, true; want: 1432518515, true
        dirent_test.go:38: readInt("\x00\x00\x00\x00ס\xb0^", 0, 4) = 0, true; want: 3617697886, true
        dirent_test.go:38: readInt("\x00\x00\x00\x00\xbb\xa5\xbf\xe4", 0, 4) = 0, true; want: 3148201956, true
        dirent_test.go:38: readInt("\x00\x00\x00\x00\xb3T\x80\xbe", 0, 4) = 0, true; want: 3008659646, true
        dirent_test.go:38: readInt("\x00\x00\x00\x00\x80!hR", 0, 4) = 0, true; want: 2149673042, true
        dirent_test.go:38: readInt("\x00\x00\x00\x00e\a:^", 0, 4) = 0, true; want: 1694972510, true
        dirent_test.go:38: readInt("\x00\x00\x00\x00\x81|\xcbW", 0, 4) = 0, true; want: 2172439383, true
        dirent_test.go:38: readInt("\x00\x00\x00\x006ͥ@", 0, 4) = 0, true; want: 919446848, true
        dirent_test.go:38: readInt("\x00\x00\x00\x00E\x92\x86\xe8", 0, 4) = 0, true; want: 1167230696, true
        dirent_test.go:38: readInt("\x00\x00\x00\x00?\"3=", 0, 4) = 0, true; want: 1059205949, true
        dirent_test.go:41: too many errors: 10
FAIL

Comment on lines +34 to +35
binary.NativeEndian.PutUint64(buf[:], want)
got, ok := readInt(buf, 0, uintptr(sz))
Copy link

Choose a reason for hiding this comment

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

This is going to be the wrong spot; on big-endian, the PutUint64 will write non-zero to the ending bytes but the read is on the starting bytes.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Ah, thank you for pointing this out - will fix.

Copy link
Owner Author

Choose a reason for hiding this comment

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

@QuLogic I created #65 to fix this issue and remove the offending test. Thank you again for reporting this!

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.

TestReadInt fails on s390x (big-endian)

4 participants