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.
This commit is contained in:
parent
06dfb42365
commit
1321a42525
|
@ -50,7 +50,7 @@ func blockTestCmd(ctx *cli.Context) error {
|
||||||
return errors.New("path argument required")
|
return errors.New("path argument required")
|
||||||
}
|
}
|
||||||
var (
|
var (
|
||||||
collected = collectJSONFiles(path)
|
collected = collectFiles(path)
|
||||||
results []testResult
|
results []testResult
|
||||||
)
|
)
|
||||||
for _, fname := range collected {
|
for _, fname := range collected {
|
||||||
|
|
|
@ -262,10 +262,15 @@ func tracerFromFlags(ctx *cli.Context) *tracing.Hooks {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// collectJSONFiles walks the given path and accumulates all files with json
|
// collectFiles walks the given path. If the path is a directory, it will
|
||||||
// extension.
|
// return a list of all accumulates all files with json extension.
|
||||||
func collectJSONFiles(path string) []string {
|
// Otherwise (if path points to a file), it will return the path.
|
||||||
|
func collectFiles(path string) []string {
|
||||||
var out []string
|
var out []string
|
||||||
|
if info, err := os.Stat(path); err == nil && !info.IsDir() {
|
||||||
|
// User explicitly pointed out a file, ignore extension.
|
||||||
|
return []string{path}
|
||||||
|
}
|
||||||
err := filepath.Walk(path, func(path string, info fs.FileInfo, err error) error {
|
err := filepath.Walk(path, func(path string, info fs.FileInfo, err error) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -63,7 +63,7 @@ func stateTestCmd(ctx *cli.Context) error {
|
||||||
// If path is provided, run the tests at that path.
|
// If path is provided, run the tests at that path.
|
||||||
if len(path) != 0 {
|
if len(path) != 0 {
|
||||||
var (
|
var (
|
||||||
collected = collectJSONFiles(path)
|
collected = collectFiles(path)
|
||||||
results []testResult
|
results []testResult
|
||||||
)
|
)
|
||||||
for _, fname := range collected {
|
for _, fname := range collected {
|
||||||
|
|
Loading…
Reference in New Issue