diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-02-22 22:58:00 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2017-02-23 18:16:46 +0800 |
commit | 23a5d64fd059bb8bdf02781608a15b8b1bdbdfd2 (patch) | |
tree | 143cd04a9fe002b25c146e7c0b5aacfbe62092eb /cmd/ethtest/main.go | |
parent | 61e6bb12478740d614c8effd330f881f962b7b84 (diff) | |
download | go-tangerine-23a5d64fd059bb8bdf02781608a15b8b1bdbdfd2.tar go-tangerine-23a5d64fd059bb8bdf02781608a15b8b1bdbdfd2.tar.gz go-tangerine-23a5d64fd059bb8bdf02781608a15b8b1bdbdfd2.tar.bz2 go-tangerine-23a5d64fd059bb8bdf02781608a15b8b1bdbdfd2.tar.lz go-tangerine-23a5d64fd059bb8bdf02781608a15b8b1bdbdfd2.tar.xz go-tangerine-23a5d64fd059bb8bdf02781608a15b8b1bdbdfd2.tar.zst go-tangerine-23a5d64fd059bb8bdf02781608a15b8b1bdbdfd2.zip |
accounts, cmd: port packages over to the new logging system
Diffstat (limited to 'cmd/ethtest/main.go')
-rw-r--r-- | cmd/ethtest/main.go | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/cmd/ethtest/main.go b/cmd/ethtest/main.go index a107c701f..fcae668c6 100644 --- a/cmd/ethtest/main.go +++ b/cmd/ethtest/main.go @@ -70,7 +70,8 @@ var ( ) func runTestWithReader(test string, r io.Reader) error { - log.Info(fmt.Sprint("runTest", test)) + log.Info("Running test", "test", test) + var err error switch strings.ToLower(test) { case "bk", "block", "blocktest", "blockchaintest", "blocktests", "blockchaintests": @@ -92,7 +93,8 @@ func runTestWithReader(test string, r io.Reader) error { } func getFiles(path string) ([]string, error) { - log.Info(fmt.Sprint("getFiles", path)) + log.Info("Listing files", "path", path) + var files []string f, err := os.Open(path) if err != nil { @@ -113,7 +115,7 @@ func getFiles(path string) ([]string, error) { // only go 1 depth and leave directory entires blank if !v.IsDir() && v.Name()[len(v.Name())-len(testExtension):len(v.Name())] == testExtension { files[i] = filepath.Join(path, v.Name()) - log.Info(fmt.Sprint("Found file", files[i])) + log.Info("Found test file", "file", files[i]) } } case mode.IsRegular(): @@ -134,7 +136,9 @@ func runSuite(test, file string) { } for _, curTest := range tests { - log.Info(fmt.Sprint("runSuite", curTest, file)) + suiteLogger := log.New("suite", file, "test", curTest) + suiteLogger.Info("Running test suite") + var err error var files []string if test == defaultTest { @@ -149,30 +153,31 @@ func runSuite(test, file string) { files, err = getFiles(file) } if err != nil { - log.Crit(fmt.Sprint(err)) + suiteLogger.Crit("Failed to gather files", "error", err) } if len(files) == 0 { - log.Warn("No files matched path") + suiteLogger.Warn("No files matched path") } for _, curFile := range files { // Skip blank entries if len(curFile) == 0 { continue } + testLogger := suiteLogger.New("file", curFile) r, err := os.Open(curFile) if err != nil { - log.Crit(fmt.Sprint(err)) + testLogger.Crit("Failed to open file") } defer r.Close() err = runTestWithReader(curTest, r) if err != nil { if continueOnError { - log.Error(fmt.Sprint(err)) + testLogger.Error("Test failed, continuing", "error", err) } else { - log.Crit(fmt.Sprint(err)) + testLogger.Crit("Test failed, aborting", "error", err) } } } @@ -189,9 +194,7 @@ func setupApp(c *cli.Context) error { if !useStdIn { runSuite(flagTest, flagFile) } else { - if err := runTestWithReader(flagTest, os.Stdin); err != nil { - log.Crit(fmt.Sprint(err)) - } + return runTestWithReader(flagTest, os.Stdin) } return nil } @@ -216,7 +219,6 @@ func main() { } if err := app.Run(os.Args); err != nil { - log.Crit(fmt.Sprint(err)) + log.Crit("Failed to run the tester", "error", err) } - } |