Repository navigation
fix: make TestExistsErrorIncludesFilePath pass in every environment - #350
Merged
Merged
Conversation
## Summary Make `TestExistsErrorIncludesFilePath` pass in every environment, including containers where /proc/1/fd can be read. ## What changes - Root cause: the test assumed `stat /proc/1/fd/does-not-exist/child` fails with EACCES. In this nspawn sandbox it returns ENOENT, even as uid 1000, and `exists` maps ENOENT to (false, nil). `exists` itself (template.go:19) is correct. - Fix: stat `<t.TempDir>/file/child`, where `file` is a regular file. The stat fails with ENOTDIR for any user, including root, so the test needs no root skip. Chosen over a mode-0 directory because root ignores mode bits. ## Testing `go test -count=1 -run TestExistsErrorIncludesFilePath.`: fails on master in this sandbox and passes on the branch, both as the user and with sudo. `go test -count=1./...` passes. `make lint` needs golangci-lint on PATH (installed under GOPATH/bin).
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
Make
TestExistsErrorIncludesFilePathpass in every environment, including containers where /proc/1/fd can be read.What changes
stat /proc/1/fd/does-not-exist/childfails with EACCES. In this nspawn sandbox it returns ENOENT, even as uid 1000, andexistsmaps ENOENT to (false, nil).existsitself (template.go:19) is correct.<t.TempDir>/file/child, wherefileis a regular file. The stat fails with ENOTDIR for any user, including root, so the test needs no root skip. Chosen over a mode-0 directory because root ignores mode bits.Testing
go test -count=1 -run TestExistsErrorIncludesFilePath.: fails on master in this sandbox and passes on the branch, both as the user and with sudo.go test -count=1./...passes.make lintneeds golangci-lint on PATH (installed under GOPATH/bin).