Skip to content

Commit 289b279

Browse files
authored
Quote output strings & skip the vendor directory (#2)
* Quote output strings * Ignore the vendor dir * Ignore other modules * Re-ignore vendor
1 parent 43d3225 commit 289b279

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

internal/collect.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ type testf struct {
2020
Name string
2121
}
2222

23+
func isGoModule(path string) bool {
24+
_, err := os.Lstat(filepath.Join(path, "go.mod"))
25+
if os.IsNotExist(err) {
26+
return false
27+
}
28+
if err != nil {
29+
panic(err)
30+
}
31+
return true
32+
}
33+
2334
func Collect(root string) ([]testf, error) {
2435
tests := []testf{}
2536
err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
@@ -28,7 +39,9 @@ func Collect(root string) ([]testf, error) {
2839
}
2940

3041
// Don't collect testdata directories.
31-
if info.IsDir() && filepath.Base(info.Name()) == "testdata" {
42+
if info.IsDir() &&
43+
(filepath.Base(info.Name()) == "testdata" || filepath.Base(info.Name()) == "vendor" ||
44+
(info.Name() != root && isGoModule(info.Name()))) {
3245
return filepath.SkipDir
3346
}
3447

main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ func (p prog) run() (string, error) {
6868

6969
switch p.output {
7070
case "env":
71-
return fmt.Sprintf("SHARD_TESTS=%s\nSHARD_PATHS=%s", pattern, strings.Join(paths, " ")), nil
71+
return fmt.Sprintf(`SHARD_TESTS="%s"\nSHARD_PATHS="%s"`, pattern, strings.Join(paths, " ")), nil
7272
default:
73-
return fmt.Sprintf("-run %s %s", pattern, strings.Join(paths, " ")), nil
73+
return fmt.Sprintf(`-run "%s" %s`, pattern, strings.Join(paths, " ")), nil
7474
}
7575
}

0 commit comments

Comments
 (0)