mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
cmd/evm: Add --single-test option to blocktest
This commit is contained in:
parent
58ae1df684
commit
ba928796db
1 changed files with 20 additions and 0 deletions
|
|
@ -30,11 +30,20 @@ import (
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var singleTestFlag = &cli.StringFlag{
|
||||||
|
Name: "single-test",
|
||||||
|
Value: "",
|
||||||
|
Usage: "Run a single test from the json file",
|
||||||
|
}
|
||||||
|
|
||||||
var blockTestCommand = &cli.Command{
|
var blockTestCommand = &cli.Command{
|
||||||
Action: blockTestCmd,
|
Action: blockTestCmd,
|
||||||
Name: "blocktest",
|
Name: "blocktest",
|
||||||
Usage: "executes the given blockchain tests",
|
Usage: "executes the given blockchain tests",
|
||||||
ArgsUsage: "<file>",
|
ArgsUsage: "<file>",
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
singleTestFlag,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func blockTestCmd(ctx *cli.Context) error {
|
func blockTestCmd(ctx *cli.Context) error {
|
||||||
|
|
@ -61,6 +70,17 @@ 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)
|
||||||
|
if singleTest != "" {
|
||||||
|
if test, ok := tests[singleTest]; ok {
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
// run them in order
|
// run them in order
|
||||||
var keys []string
|
var keys []string
|
||||||
for key := range tests {
|
for key := range tests {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue