Read directly from stdin

pull/245/head
obscuren 10 years ago
parent c1908c7d91
commit 982c812e81
  1. 11
      cmd/ethtest/main.go

@ -24,10 +24,10 @@ package main
import ( import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"io"
"io/ioutil" "io/ioutil"
"log" "log"
"os" "os"
"strings"
"github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/ethutil"
@ -65,10 +65,10 @@ type VmTest struct {
Pre map[string]Account Pre map[string]Account
} }
func RunVmTest(js string) (failed int) { func RunVmTest(r io.Reader) (failed int) {
tests := make(map[string]VmTest) tests := make(map[string]VmTest)
data, _ := ioutil.ReadAll(strings.NewReader(js)) data, _ := ioutil.ReadAll(r)
err := json.Unmarshal(data, &tests) err := json.Unmarshal(data, &tests)
if err != nil { if err != nil {
log.Fatalln(err) log.Fatalln(err)
@ -125,9 +125,6 @@ func RunVmTest(js string) (failed int) {
func main() { func main() {
helper.Logger.SetLogLevel(5) helper.Logger.SetLogLevel(5)
if len(os.Args) == 1 {
log.Fatalln("no json supplied")
}
os.Exit(RunVmTest(os.Args[1])) os.Exit(RunVmTest(os.Stdin))
} }

Loading…
Cancel
Save