diff --git a/cmd/evm/blockrunner.go b/cmd/evm/blockrunner.go index 42be6726b..ff6557458 100644 --- a/cmd/evm/blockrunner.go +++ b/cmd/evm/blockrunner.go @@ -21,6 +21,7 @@ import ( "errors" "fmt" "os" + "regexp" "sort" "github.com/ethereum/go-ethereum/core/rawdb" @@ -30,11 +31,18 @@ import ( "github.com/urfave/cli/v2" ) +var RunFlag = &cli.StringFlag{ + Name: "run", + Value: ".*", + Usage: "Run only those tests matching the regular expression.", +} + var blockTestCommand = &cli.Command{ Action: blockTestCmd, Name: "blocktest", Usage: "executes the given blockchain tests", ArgsUsage: "", + Flags: []cli.Flag{RunFlag}, } func blockTestCmd(ctx *cli.Context) error { @@ -61,13 +69,21 @@ func blockTestCmd(ctx *cli.Context) error { if err = json.Unmarshal(src, &tests); err != nil { return err } - // run them in order + re, err := regexp.Compile(ctx.String(RunFlag.Name)) + if err != nil { + return fmt.Errorf("invalid regex -%s: %v", RunFlag.Name, err) + } + + // Run them in order var keys []string for key := range tests { keys = append(keys, key) } sort.Strings(keys) for _, name := range keys { + if !re.MatchString(name) { + continue + } test := tests[name] if err := test.Run(false, rawdb.HashScheme, tracer); err != nil { return fmt.Errorf("test %v: %w", name, err)