mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
cmd/evm: run tests based on regexp in blockrunner
This commit is contained in:
parent
ba928796db
commit
a900186dbe
1 changed files with 14 additions and 18 deletions
|
|
@ -21,6 +21,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"regexp"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/core/rawdb"
|
"github.com/ethereum/go-ethereum/core/rawdb"
|
||||||
|
|
@ -30,10 +31,10 @@ import (
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
var singleTestFlag = &cli.StringFlag{
|
var RunFlag = &cli.StringFlag{
|
||||||
Name: "single-test",
|
Name: "run",
|
||||||
Value: "",
|
Value: ".*",
|
||||||
Usage: "Run a single test from the json file",
|
Usage: "Run only those tests matching the regular expression.",
|
||||||
}
|
}
|
||||||
|
|
||||||
var blockTestCommand = &cli.Command{
|
var blockTestCommand = &cli.Command{
|
||||||
|
|
@ -41,9 +42,7 @@ var blockTestCommand = &cli.Command{
|
||||||
Name: "blocktest",
|
Name: "blocktest",
|
||||||
Usage: "executes the given blockchain tests",
|
Usage: "executes the given blockchain tests",
|
||||||
ArgsUsage: "<file>",
|
ArgsUsage: "<file>",
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{RunFlag},
|
||||||
singleTestFlag,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func blockTestCmd(ctx *cli.Context) error {
|
func blockTestCmd(ctx *cli.Context) error {
|
||||||
|
|
@ -70,24 +69,21 @@ func blockTestCmd(ctx *cli.Context) error {
|
||||||
if err = json.Unmarshal(src, &tests); err != nil {
|
if err = json.Unmarshal(src, &tests); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
singleTest := ctx.String(singleTestFlag.Name)
|
re, err := regexp.Compile(ctx.String(RunFlag.Name))
|
||||||
if singleTest != "" {
|
if err != nil {
|
||||||
if test, ok := tests[singleTest]; ok {
|
return fmt.Errorf("invalid regex -%s: %v", RunFlag.Name, err)
|
||||||
if err := test.Run(false, rawdb.HashScheme, tracer); err != nil {
|
|
||||||
return fmt.Errorf("test %v: %w", singleTest, err)
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return fmt.Errorf("test %v not found", singleTest)
|
// Run them in order
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
// run them in order
|
|
||||||
var keys []string
|
var keys []string
|
||||||
for key := range tests {
|
for key := range tests {
|
||||||
keys = append(keys, key)
|
keys = append(keys, key)
|
||||||
}
|
}
|
||||||
sort.Strings(keys)
|
sort.Strings(keys)
|
||||||
for _, name := range keys {
|
for _, name := range keys {
|
||||||
|
if !re.MatchString(name) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
test := tests[name]
|
test := tests[name]
|
||||||
if err := test.Run(false, rawdb.HashScheme, tracer); err != nil {
|
if err := test.Run(false, rawdb.HashScheme, tracer); err != nil {
|
||||||
return fmt.Errorf("test %v: %w", name, err)
|
return fmt.Errorf("test %v: %w", name, err)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue