-
-
Notifications
You must be signed in to change notification settings - Fork 334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ignore fs.WalkDir errors in FindFiles #122
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -1017,11 +1017,22 @@ func TestFindFiles_RecursesIntoSubdirectories(t *testing.T) { | |||||
} | ||||||
} | ||||||
|
||||||
func TestFindFiles_InNonexistentPathReturnsError(t *testing.T) { | ||||||
// FindFiles has been updated to ignore all errors | ||||||
// see [github issue #99] | ||||||
// (https://github.com/bitfield/script/issues/99) | ||||||
func TestFindFiles_FailsSilently(t *testing.T) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think "fails silently" could be misinterpreted, couldn't it? Like "fails" suggests it's not working properly. What about something like:
Suggested change
But I'm not convinced this is the right behaviour, actually. I am convinced that if there's some error from |
||||||
t.Parallel() | ||||||
p := script.FindFiles("nonexistent_path") | ||||||
if p.Error() == nil { | ||||||
t.Fatal("want error for nonexistent path") | ||||||
want := "\n" | ||||||
p := script.FindFiles("testdata/nonexistent") | ||||||
if p.Error() != nil { | ||||||
t.Fatal(p.Error()) | ||||||
} | ||||||
got, err := p.String() | ||||||
if err != nil { | ||||||
t.Fatal(err) | ||||||
} | ||||||
if want != got { | ||||||
t.Error(cmp.Diff(want, got)) | ||||||
} | ||||||
} | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's a key part of
FindFiles
behaviour that it doesn't return an error for missing paths, shouldn't we have a test for that?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah great point, pushed up a test