Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hivesim: only log test and suite skips at high log levels #923

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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