mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 09:23:48 +00:00
fix: no test file issue
This commit is contained in:
parent
58f65c60c2
commit
47da47105a
1 changed files with 20 additions and 3 deletions
23
build/ci.go
23
build/ci.go
|
|
@ -323,10 +323,27 @@ func doTest(cmdline []string) {
|
||||||
gotest.Args = append(gotest.Args, "-short")
|
gotest.Args = append(gotest.Args, "-short")
|
||||||
}
|
}
|
||||||
|
|
||||||
packages := []string{"./..."}
|
// List only packages that contain test files
|
||||||
if len(flag.CommandLine.Args()) > 0 {
|
cmd := exec.Command("go", "list", "-f", "{{if .TestGoFiles}}{{.ImportPath}}{{end}}", "./...")
|
||||||
packages = flag.CommandLine.Args()
|
out, err := cmd.Output()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("failed to list testable packages: %v", err)
|
||||||
}
|
}
|
||||||
|
packages := strings.Fields(string(out))
|
||||||
|
|
||||||
|
// List only testable user-specified packages
|
||||||
|
if len(flag.CommandLine.Args()) > 0 {
|
||||||
|
userPackages := flag.CommandLine.Args()
|
||||||
|
userCmd := exec.Command("go", append([]string{"list", "-f", "{{if .TestGoFiles}}{{.ImportPath}}{{end}}"}, userPackages...)...)
|
||||||
|
userOut, _ := userCmd.Output()
|
||||||
|
filteredPackages := strings.Fields(string(userOut))
|
||||||
|
|
||||||
|
if len(filteredPackages) == 0 {
|
||||||
|
log.Fatalf("No test files found in the specified packages: %v", userPackages)
|
||||||
|
}
|
||||||
|
packages = filteredPackages
|
||||||
|
}
|
||||||
|
|
||||||
gotest.Args = append(gotest.Args, packages...)
|
gotest.Args = append(gotest.Args, packages...)
|
||||||
build.MustRun(gotest)
|
build.MustRun(gotest)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue