mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-24 08:49:29 +00:00
cmd/evm: add --ndjson flag for streaming JSON output
This commit is contained in:
parent
ffc5899bad
commit
6f0ae114ab
5 changed files with 19 additions and 1 deletions
|
|
@ -42,6 +42,7 @@ var blockTestCommand = &cli.Command{
|
|||
Flags: slices.Concat([]cli.Flag{
|
||||
DumpFlag,
|
||||
HumanReadableFlag,
|
||||
NDJSONFlag,
|
||||
RunFlag,
|
||||
WitnessCrossCheckFlag,
|
||||
FuzzFlag,
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ var engineTestCommand = &cli.Command{
|
|||
Flags: slices.Concat([]cli.Flag{
|
||||
DumpFlag,
|
||||
HumanReadableFlag,
|
||||
NDJSONFlag,
|
||||
RunFlag,
|
||||
FuzzFlag,
|
||||
WorkersFlag,
|
||||
|
|
|
|||
|
|
@ -75,6 +75,10 @@ var (
|
|||
Name: "human",
|
||||
Usage: "\"Human-readable\" output",
|
||||
}
|
||||
NDJSONFlag = &cli.BoolFlag{
|
||||
Name: "ndjson",
|
||||
Usage: "Output one JSON result per line as tests complete (streaming)",
|
||||
}
|
||||
StatDumpFlag = &cli.BoolFlag{
|
||||
Name: "statdump",
|
||||
Usage: "displays stack and heap memory information",
|
||||
|
|
|
|||
|
|
@ -85,3 +85,9 @@ func report(ctx *cli.Context, results []testResult) {
|
|||
out, _ := json.MarshalIndent(results, "", " ")
|
||||
fmt.Println(string(out))
|
||||
}
|
||||
|
||||
// reportNDJSON prints one JSON object per result as it completes.
|
||||
func reportNDJSON(r testResult) {
|
||||
out, _ := json.Marshal(r)
|
||||
fmt.Println(string(out))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ var stateTestCommand = &cli.Command{
|
|||
DumpFlag,
|
||||
forkFlag,
|
||||
HumanReadableFlag,
|
||||
NDJSONFlag,
|
||||
idxFlag,
|
||||
RunFlag,
|
||||
WorkersFlag,
|
||||
|
|
@ -76,7 +77,9 @@ func stateTestCmd(ctx *cli.Context) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
report(ctx, results)
|
||||
if !ctx.Bool(NDJSONFlag.Name) {
|
||||
report(ctx, results)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
// Otherwise, read filenames from stdin and execute back-to-back.
|
||||
|
|
@ -211,6 +214,9 @@ func runStateTest(ctx *cli.Context, fname string) ([]testResult, error) {
|
|||
return
|
||||
}
|
||||
})
|
||||
if ctx.Bool(NDJSONFlag.Name) {
|
||||
reportNDJSON(*result)
|
||||
}
|
||||
results = append(results, *result)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue