mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-05 12:41:14 +00:00
Merge pull request #916 from gzliudan/quick-test
build: add command `make quick-test` to save test time
This commit is contained in:
commit
95c7b224af
3 changed files with 16 additions and 7 deletions
4
Makefile
4
Makefile
|
|
@ -54,6 +54,10 @@ all:
|
||||||
test: all
|
test: all
|
||||||
go run build/ci.go test
|
go run build/ci.go test
|
||||||
|
|
||||||
|
#? quick-test: Run the tests except time-consuming tests.
|
||||||
|
quick-test: all
|
||||||
|
go run build/ci.go test --quick
|
||||||
|
|
||||||
#? lint: Run certain pre-selected linters.
|
#? lint: Run certain pre-selected linters.
|
||||||
lint: ## Run linters.
|
lint: ## Run linters.
|
||||||
$(GORUN) build/ci.go lint
|
$(GORUN) build/ci.go lint
|
||||||
|
|
|
||||||
|
|
@ -219,10 +219,10 @@ func goToolArch(arch string, cc string, subcmd string, args ...string) *exec.Cmd
|
||||||
// Running The Tests
|
// Running The Tests
|
||||||
//
|
//
|
||||||
// "tests" also includes static analysis tools such as vet.
|
// "tests" also includes static analysis tools such as vet.
|
||||||
|
|
||||||
func doTest(cmdline []string) {
|
func doTest(cmdline []string) {
|
||||||
coverage := flag.Bool("coverage", false, "Whether to record code coverage")
|
coverage := flag.Bool("coverage", false, "Whether to record code coverage")
|
||||||
verbose := flag.Bool("v", false, "Whether to log verbosely")
|
verbose := flag.Bool("v", false, "Whether to log verbosely")
|
||||||
|
quick := flag.Bool("quick", false, "Whether to skip long time test")
|
||||||
flag.CommandLine.Parse(cmdline)
|
flag.CommandLine.Parse(cmdline)
|
||||||
env := build.Env()
|
env := build.Env()
|
||||||
|
|
||||||
|
|
@ -231,7 +231,7 @@ func doTest(cmdline []string) {
|
||||||
packages = flag.CommandLine.Args()
|
packages = flag.CommandLine.Args()
|
||||||
} else {
|
} else {
|
||||||
// added all files in all packages (except vendor) to coverage report files count, even there is no test file in the package
|
// added all files in all packages (except vendor) to coverage report files count, even there is no test file in the package
|
||||||
packages = build.ExpandPackagesNoVendor(packages)
|
packages = build.ExpandPackages(packages, *quick)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run analysis tools before the tests.
|
// Run analysis tools before the tests.
|
||||||
|
|
|
||||||
|
|
@ -136,9 +136,9 @@ func GoTool(tool string, args ...string) *exec.Cmd {
|
||||||
return exec.Command(filepath.Join(runtime.GOROOT(), "bin", "go"), args...)
|
return exec.Command(filepath.Join(runtime.GOROOT(), "bin", "go"), args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExpandPackagesNoVendor expands a cmd/go import path pattern, skipping
|
// ExpandPackages expands a cmd/go import path pattern, skip vendor
|
||||||
// vendored packages.
|
// packages, and skip time-consuming tests according to quick flag.
|
||||||
func ExpandPackagesNoVendor(patterns []string) []string {
|
func ExpandPackages(patterns []string, quick bool) []string {
|
||||||
expand := false
|
expand := false
|
||||||
for _, pkg := range patterns {
|
for _, pkg := range patterns {
|
||||||
if strings.Contains(pkg, "...") {
|
if strings.Contains(pkg, "...") {
|
||||||
|
|
@ -153,9 +153,14 @@ func ExpandPackagesNoVendor(patterns []string) []string {
|
||||||
}
|
}
|
||||||
var packages []string
|
var packages []string
|
||||||
for _, line := range strings.Split(string(out), "\n") {
|
for _, line := range strings.Split(string(out), "\n") {
|
||||||
if !strings.Contains(line, "/vendor/") {
|
if strings.Contains(line, "/vendor/") {
|
||||||
packages = append(packages, strings.TrimSpace(line))
|
continue
|
||||||
}
|
}
|
||||||
|
if quick && strings.Contains(line, "/consensus/tests/engine_v2_tests") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
packages = append(packages, strings.TrimSpace(line))
|
||||||
|
|
||||||
}
|
}
|
||||||
return packages
|
return packages
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue