Skip to content

Commit 83dd957

Browse files
committed
Better check for test directory not existing
It would work when using the embedded tests, but failed when using "-testdir tests". Fixes #117
1 parent 86317a3 commit 83dd957

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

runner.go

+6-9
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"errors"
1010
"fmt"
1111
"io/fs"
12-
"os"
1312
"os/exec"
1413
"path/filepath"
1514
"sort"
@@ -171,7 +170,12 @@ func (r Runner) Run() (Tests, error) {
171170

172171
// find all TOML files in 'path' relative to the test directory.
173172
func (r Runner) findTOML(path string, appendTo *[]string, exclude []string) error {
174-
err := fs.WalkDir(r.Files, path, func(path string, d fs.DirEntry, err error) error {
173+
// It's okay if the directory doesn't exist.
174+
if _, err := fs.Stat(r.Files, path); errors.Is(err, fs.ErrNotExist) {
175+
return nil
176+
}
177+
178+
return fs.WalkDir(r.Files, path, func(path string, d fs.DirEntry, err error) error {
175179
if err != nil {
176180
return err
177181
}
@@ -189,13 +193,6 @@ func (r Runner) findTOML(path string, appendTo *[]string, exclude []string) erro
189193
*appendTo = append(*appendTo, path)
190194
return nil
191195
})
192-
193-
// It's okay if the directory doesn't exist.
194-
var pErr *os.PathError
195-
if errors.As(err, &pErr) && pErr.Op == "open" && pErr.Path == path {
196-
return nil
197-
}
198-
return err
199196
}
200197

201198
// Expand RunTest glob patterns, or return all tests if RunTests if empty.

0 commit comments

Comments
 (0)