Skip to content

Commit 7f58f22

Browse files
author
tac0turtle
committed
add short flag to benchmarks
1 parent 29dee0a commit 7f58f22

File tree

4 files changed

+53
-11
lines changed

4 files changed

+53
-11
lines changed

da/compression/benchmark_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ import (
1212

1313
// TestLargeBlobCompressionEfficiency tests compression efficiency for blob sizes from 20KB to 2MB
1414
func TestLargeBlobCompressionEfficiency(t *testing.T) {
15+
if testing.Short() {
16+
t.Skip("Skipping large blob compression test in short mode")
17+
}
18+
1519
config := DefaultConfig()
1620
compressor, err := NewCompressibleDA(nil, config)
1721
require.NoError(t, err)
@@ -54,7 +58,7 @@ func TestLargeBlobCompressionEfficiency(t *testing.T) {
5458
},
5559
}
5660

57-
fmt.Printf("\n=== Large Blob Compression Efficiency Test ===\n")
61+
fmt.Printf("\n=== Blob Compression Efficiency Test ===\n")
5862
fmt.Printf("%-15s %-10s %-12s %-12s %-10s %-15s\n",
5963
"Data Type", "Size", "Compressed", "Saved", "Ratio", "Compression")
6064
fmt.Printf("%-15s %-10s %-12s %-12s %-10s %-15s\n",

scripts/test.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"flag"
45
"fmt"
56
"log"
67
"os"
@@ -10,6 +11,10 @@ import (
1011
)
1112

1213
func main() {
14+
// Parse command line flags
15+
shortMode := flag.Bool("short", true, "Run tests in short mode (skip long-running tests)")
16+
flag.Parse()
17+
1318
rootDir := "." // Start from the current directory
1419
var testFailures bool
1520
err := filepath.WalkDir(rootDir, func(path string, d os.DirEntry, err error) error {
@@ -28,8 +33,16 @@ func main() {
2833
// or adjust logic if root tests are also desired.
2934
// For this example, we'll run tests in all directories with go.mod.
3035

31-
fmt.Printf("--> Running tests in: %s\n", modDir)
32-
cmd := exec.Command("go", "test", "./...", "-cover")
36+
// Build test command with optional -short flag
37+
testArgs := []string{"test", "./...", "-cover"}
38+
if *shortMode {
39+
testArgs = append([]string{"test", "./...", "-short", "-cover"}, testArgs[3:]...)
40+
fmt.Printf("--> Running tests in short mode in: %s\n", modDir)
41+
} else {
42+
fmt.Printf("--> Running full tests in: %s\n", modDir)
43+
}
44+
45+
cmd := exec.Command("go", testArgs...)
3346
cmd.Dir = modDir // Set the working directory for the command
3447
cmd.Stdout = os.Stdout
3548
cmd.Stderr = os.Stderr

scripts/test.mk

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,18 @@ clean-testcache:
44
@go clean --testcache
55
.PHONY: clean-testcache
66

7-
## test: Running unit tests for all go.mods
7+
## test: Running unit tests for all go.mods (fast mode with -short flag)
88
test:
9-
@echo "--> Running unit tests"
10-
@go run -tags='run integration' scripts/test.go
9+
@echo "--> Running unit tests (fast mode)"
10+
@go run -tags='run integration' scripts/test.go -short
1111
.PHONY: test
1212

13+
## test-full: Running full unit tests for all go.mods (includes long-running tests)
14+
test-full:
15+
@echo "--> Running full unit tests (including long-running tests)"
16+
@go run -tags='run integration' scripts/test.go -short=false
17+
.PHONY: test-full
18+
1319
## test-all: Running all tests including Docker E2E
1420
test-all: test test-docker-e2e
1521
@echo "--> All tests completed"
@@ -33,12 +39,18 @@ test-integration-cover:
3339
@cd node && go test -mod=readonly -failfast -timeout=15m -tags='integration' -coverprofile=coverage.txt -covermode=atomic ./...
3440
.PHONY: test-integration-cover
3541

36-
## test-cover: generate code coverage report.
42+
## test-cover: generate code coverage report (fast mode with -short flag).
3743
test-cover:
38-
@echo "--> Running unit tests"
39-
@go run -tags=cover scripts/test_cover.go
44+
@echo "--> Running unit tests with coverage (fast mode)"
45+
@go run -tags=cover scripts/test_cover.go -short
4046
.PHONY: test-cover
4147

48+
## test-cover-full: generate code coverage report with all tests.
49+
test-cover-full:
50+
@echo "--> Running full unit tests with coverage"
51+
@go run -tags=cover scripts/test_cover.go -short=false
52+
.PHONY: test-cover-full
53+
4254
## test-evm: Running EVM tests
4355
test-evm:
4456
@echo "--> Running EVM tests"

scripts/test_cover.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package main
55

66
import (
77
"bufio"
8+
"flag"
89
"fmt"
910
"log"
1011
"os"
@@ -14,6 +15,10 @@ import (
1415
)
1516

1617
func main() {
18+
// Parse command line flags
19+
shortMode := flag.Bool("short", true, "Run tests in short mode (skip long-running tests)")
20+
flag.Parse()
21+
1722
rootDir := "."
1823

1924
var coverFiles []string
@@ -38,8 +43,16 @@ func main() {
3843
fullCoverProfilePath := filepath.Join(modDir, "cover.out")
3944
relativeCoverProfileArg := "cover.out"
4045

41-
fmt.Printf("--> Running tests with coverage in: %s (profile: %s)\n", modDir, relativeCoverProfileArg)
42-
cmd := exec.Command("go", "test", "./...", "-race", "-coverprofile="+relativeCoverProfileArg, "-covermode=atomic")
46+
// Build test command with optional -short flag
47+
testArgs := []string{"test", "./...", "-race", "-coverprofile=" + relativeCoverProfileArg, "-covermode=atomic"}
48+
if *shortMode {
49+
testArgs = []string{"test", "./...", "-short", "-race", "-coverprofile=" + relativeCoverProfileArg, "-covermode=atomic"}
50+
fmt.Printf("--> Running tests with coverage in short mode in: %s (profile: %s)\n", modDir, relativeCoverProfileArg)
51+
} else {
52+
fmt.Printf("--> Running full tests with coverage in: %s (profile: %s)\n", modDir, relativeCoverProfileArg)
53+
}
54+
55+
cmd := exec.Command("go", testArgs...)
4356
cmd.Dir = modDir
4457
cmd.Stdout = os.Stdout
4558
cmd.Stderr = os.Stderr

0 commit comments

Comments
 (0)