Skip to content

Commit

Permalink
hivesim: only log test and suite skips at high log levels (#923)
Browse files Browse the repository at this point in the history
  • Loading branch information
spencer-tb authored Oct 31, 2023
1 parent c4e42b9 commit 77664fa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
9 changes: 7 additions & 2 deletions hivesim/hive.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"net/http"
"os"
"path/filepath"
"strconv"
"strings"

"github.com/ethereum/go-ethereum/p2p/enode"
Expand All @@ -20,8 +21,9 @@ import (

// Simulation wraps the simulation HTTP API provided by hive.
type Simulation struct {
url string
m testMatcher
url string
m testMatcher
ll int
}

// New looks up the hive host URI using the HIVE_SIMULATOR environment variable
Expand All @@ -42,6 +44,9 @@ func New() *Simulation {
}
sim.m = m
}
if ll := os.Getenv("HIVE_LOGLEVEL"); ll != "" {
sim.ll, _ = strconv.Atoi(ll)
}
return sim
}

Expand Down
15 changes: 9 additions & 6 deletions hivesim/testapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ func MustRun(host *Simulation, suites ...Suite) {
// RunSuite runs all tests in a suite.
func RunSuite(host *Simulation, suite Suite) error {
if !host.m.match(suite.Name, "") {
fmt.Fprintf(os.Stderr, "skipping suite %q because it doesn't match test pattern %s\n", suite.Name, host.m.pattern)
if host.ll > 3 { // hive log level > 3
fmt.Fprintf(os.Stderr, "skipping suite %q because it doesn't match test pattern %s\n", suite.Name, host.m.pattern)
}
return nil
}

Expand Down Expand Up @@ -82,13 +84,12 @@ func MustRunSuite(host *Simulation, suite Suite) {
// Using this test type doesn't launch any clients by default. To interact with clients,
// you can launch them using the t.Client method:
//
// c := t.Client()
// c.RPC().Call(...)
// c := t.Client()
// c.RPC().Call(...)
//
// or run a subtest using t.RunClientTest():
//
// t.RunClientTest(hivesim.ClientTestSpec{...})
//
// t.RunClientTest(hivesim.ClientTestSpec{...})
type TestSpec struct {
// These fields are displayed in the UI. Be sure to add
// a meaningful description here.
Expand Down Expand Up @@ -306,7 +307,9 @@ type testSpec struct {

func runTest(host *Simulation, test testSpec, runit func(t *T)) error {
if !test.alwaysRun && !host.m.match(test.suite.Name, test.name) {
fmt.Fprintf(os.Stderr, "skipping test %q because it doesn't match test pattern %s\n", test.name, host.m.pattern)
if host.ll > 3 { // hive log level > 3
fmt.Fprintf(os.Stderr, "skipping test %q because it doesn't match test pattern %s\n", test.name, host.m.pattern)
}
return nil
}

Expand Down

0 comments on commit 77664fa

Please sign in to comment.