From 77664fad37e15e976066f9c2c9eb873b6ce09f6b Mon Sep 17 00:00:00 2001 From: spencer Date: Tue, 31 Oct 2023 05:08:50 -0600 Subject: [PATCH] hivesim: only log test and suite skips at high log levels (#923) --- hivesim/hive.go | 9 +++++++-- hivesim/testapi.go | 15 +++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/hivesim/hive.go b/hivesim/hive.go index c70c4d445b..ba29d5d2f1 100644 --- a/hivesim/hive.go +++ b/hivesim/hive.go @@ -12,6 +12,7 @@ import ( "net/http" "os" "path/filepath" + "strconv" "strings" "github.com/ethereum/go-ethereum/p2p/enode" @@ -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 @@ -42,6 +44,9 @@ func New() *Simulation { } sim.m = m } + if ll := os.Getenv("HIVE_LOGLEVEL"); ll != "" { + sim.ll, _ = strconv.Atoi(ll) + } return sim } diff --git a/hivesim/testapi.go b/hivesim/testapi.go index 9485f33c8d..4b4f052a63 100644 --- a/hivesim/testapi.go +++ b/hivesim/testapi.go @@ -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 } @@ -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. @@ -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 }