Skip to content

Commit 1321a42

Browse files
authored
cmd/evm: make evm statetest accept non-json files (#30927)
This fixes a regression introduced recently. Without this fix, it's not possible to use statetests without `.json` suffix. This is problematic for goevmlab `minimizer`, which appends the suffix `.min` during processing.
1 parent 06dfb42 commit 1321a42

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

cmd/evm/blockrunner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func blockTestCmd(ctx *cli.Context) error {
5050
return errors.New("path argument required")
5151
}
5252
var (
53-
collected = collectJSONFiles(path)
53+
collected = collectFiles(path)
5454
results []testResult
5555
)
5656
for _, fname := range collected {

cmd/evm/main.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,15 @@ func tracerFromFlags(ctx *cli.Context) *tracing.Hooks {
262262
}
263263
}
264264

265-
// collectJSONFiles walks the given path and accumulates all files with json
266-
// extension.
267-
func collectJSONFiles(path string) []string {
265+
// collectFiles walks the given path. If the path is a directory, it will
266+
// return a list of all accumulates all files with json extension.
267+
// Otherwise (if path points to a file), it will return the path.
268+
func collectFiles(path string) []string {
268269
var out []string
270+
if info, err := os.Stat(path); err == nil && !info.IsDir() {
271+
// User explicitly pointed out a file, ignore extension.
272+
return []string{path}
273+
}
269274
err := filepath.Walk(path, func(path string, info fs.FileInfo, err error) error {
270275
if err != nil {
271276
return err

cmd/evm/staterunner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func stateTestCmd(ctx *cli.Context) error {
6363
// If path is provided, run the tests at that path.
6464
if len(path) != 0 {
6565
var (
66-
collected = collectJSONFiles(path)
66+
collected = collectFiles(path)
6767
results []testResult
6868
)
6969
for _, fname := range collected {

0 commit comments

Comments
 (0)