diff options
author | Taylor Gerring <taylor.gerring@gmail.com> | 2015-06-15 05:55:03 +0800 |
---|---|---|
committer | Taylor Gerring <taylor.gerring@gmail.com> | 2015-06-19 04:24:07 +0800 |
commit | 01ec4dbb1251751b8bbf62ddb3b3a02dc50d29fc (patch) | |
tree | a07bed9da1fecc99f483b725f60283b01e8da845 /tests/init.go | |
parent | a86452d22c2206fd05cfa72b547e7014a0859c7c (diff) | |
download | dexon-01ec4dbb1251751b8bbf62ddb3b3a02dc50d29fc.tar.gz dexon-01ec4dbb1251751b8bbf62ddb3b3a02dc50d29fc.tar.zst dexon-01ec4dbb1251751b8bbf62ddb3b3a02dc50d29fc.zip |
Add stdin option
Diffstat (limited to 'tests/init.go')
-rw-r--r-- | tests/init.go | 75 |
1 files changed, 52 insertions, 23 deletions
diff --git a/tests/init.go b/tests/init.go index 164924ab8..326387341 100644 --- a/tests/init.go +++ b/tests/init.go @@ -8,6 +8,8 @@ import ( "net/http" "os" "path/filepath" + + // "github.com/ethereum/go-ethereum/logger/glog" ) var ( @@ -17,13 +19,40 @@ var ( transactionTestDir = filepath.Join(baseDir, "TransactionTests") vmTestDir = filepath.Join(baseDir, "VMTests") - blockSkipTests = []string{"SimpleTx3"} - transSkipTests = []string{"TransactionWithHihghNonce256"} - stateSkipTests = []string{"mload32bitBound_return", "mload32bitBound_return2"} - vmSkipTests = []string{} + BlockSkipTests = []string{"SimpleTx3"} + TransSkipTests = []string{"TransactionWithHihghNonce256"} + StateSkipTests = []string{"mload32bitBound_return", "mload32bitBound_return2"} + VmSkipTests = []string{} ) -func readJSON(reader io.Reader, value interface{}) error { +// type TestRunner interface { +// // LoadTest() +// RunTest() error +// } + +// func RunTests(bt map[string]TestRunner, skipTests []string) error { +// // map skipped tests to boolean set +// skipTest := make(map[string]bool, len(skipTests)) +// for _, name := range skipTests { +// skipTest[name] = true +// } + +// for name, test := range bt { +// // if the test should be skipped, return +// if skipTest[name] { +// glog.Infoln("Skipping block test", name) +// return nil +// } +// // test the block +// if err := test.RunTest(); err != nil { +// return err +// } +// glog.Infoln("Block test passed: ", name) +// } +// return nil +// } + +func readJson(reader io.Reader, value interface{}) error { data, err := ioutil.ReadAll(reader) if err != nil { return fmt.Errorf("Error reading JSON file", err.Error()) @@ -39,44 +68,44 @@ func readJSON(reader io.Reader, value interface{}) error { return nil } -// findLine returns the line number for the given offset into data. -func findLine(data []byte, offset int64) (line int) { - line = 1 - for i, r := range string(data) { - if int64(i) >= offset { - return - } - if r == '\n' { - line++ - } - } - return -} - -func readHttpFile(uri string, value interface{}) error { +func readJsonHttp(uri string, value interface{}) error { resp, err := http.Get(uri) if err != nil { return err } defer resp.Body.Close() - err = readJSON(resp.Body, value) + err = readJson(resp.Body, value) if err != nil { return err } return nil } -func readTestFile(fn string, value interface{}) error { +func readJsonFile(fn string, value interface{}) error { file, err := os.Open(fn) if err != nil { return err } defer file.Close() - err = readJSON(file, value) + err = readJson(file, value) if err != nil { return fmt.Errorf("%s in file %s", err.Error(), fn) } return nil } + +// findLine returns the line number for the given offset into data. +func findLine(data []byte, offset int64) (line int) { + line = 1 + for i, r := range string(data) { + if int64(i) >= offset { + return + } + if r == '\n' { + line++ + } + } + return +} |