Skip to content

Commit 6f02010

Browse files
committed
build: add command make quick-test to save test time
1 parent 9236458 commit 6f02010

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ all:
5454
test: all
5555
go run build/ci.go test
5656

57+
#? quick-test: Run the tests except time-consuming tests.
58+
quick-test: all
59+
go run build/ci.go test --quick
60+
5761
#? lint: Run certain pre-selected linters.
5862
lint: ## Run linters.
5963
$(GORUN) build/ci.go lint

build/ci.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,10 @@ func goToolArch(arch string, cc string, subcmd string, args ...string) *exec.Cmd
219219
// Running The Tests
220220
//
221221
// "tests" also includes static analysis tools such as vet.
222-
223222
func doTest(cmdline []string) {
224223
coverage := flag.Bool("coverage", false, "Whether to record code coverage")
225224
verbose := flag.Bool("v", false, "Whether to log verbosely")
225+
quick := flag.Bool("quick", false, "Whether to skip long time test")
226226
flag.CommandLine.Parse(cmdline)
227227
env := build.Env()
228228

@@ -231,7 +231,7 @@ func doTest(cmdline []string) {
231231
packages = flag.CommandLine.Args()
232232
} else {
233233
// added all files in all packages (except vendor) to coverage report files count, even there is no test file in the package
234-
packages = build.ExpandPackagesNoVendor(packages)
234+
packages = build.ExpandPackages(packages, *quick)
235235
}
236236

237237
// Run analysis tools before the tests.

internal/build/util.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ func GoTool(tool string, args ...string) *exec.Cmd {
136136
return exec.Command(filepath.Join(runtime.GOROOT(), "bin", "go"), args...)
137137
}
138138

139-
// ExpandPackagesNoVendor expands a cmd/go import path pattern, skipping
140-
// vendored packages.
141-
func ExpandPackagesNoVendor(patterns []string) []string {
139+
// ExpandPackages expands a cmd/go import path pattern, skip vendor
140+
// packages, and skip time-consuming tests according to quick flag.
141+
func ExpandPackages(patterns []string, quick bool) []string {
142142
expand := false
143143
for _, pkg := range patterns {
144144
if strings.Contains(pkg, "...") {
@@ -153,9 +153,14 @@ func ExpandPackagesNoVendor(patterns []string) []string {
153153
}
154154
var packages []string
155155
for _, line := range strings.Split(string(out), "\n") {
156-
if !strings.Contains(line, "/vendor/") {
157-
packages = append(packages, strings.TrimSpace(line))
156+
if strings.Contains(line, "/vendor/") {
157+
continue
158158
}
159+
if quick && strings.Contains(line, "/consensus/tests/engine_v2_tests") {
160+
continue
161+
}
162+
packages = append(packages, strings.TrimSpace(line))
163+
159164
}
160165
return packages
161166
}

0 commit comments

Comments
 (0)