Skip to content

Commit a86452d

Browse files
committed
Minor cleanup
1 parent 4933667 commit a86452d

1 file changed

Lines changed: 23 additions & 17 deletions

File tree

‎cmd/ethtest/main.go‎

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
/**
1818
* @authors:
1919
* Jeffrey Wilcke <i@jev.io>
20+
* Taylor Gerring <taylor.gerring@gmail.com>
2021
*/
2122

2223
package main
@@ -52,7 +53,7 @@ var (
5253
}
5354
ContinueOnErrorFlag = cli.BoolFlag{
5455
Name: "continue",
55-
Usage: "Continue running tests on error (true) or exit immediately (false)",
56+
Usage: "Continue running tests on error (true) or [default] exit immediately (false)",
5657
}
5758
)
5859

@@ -75,7 +76,7 @@ func runTest(test, file string) error {
7576
}
7677

7778
func getFiles(path string) ([]string, error) {
78-
// glog.Infoln("getFiles ", path)
79+
// glog.Infoln("getFiles", path)
7980
var files []string
8081
f, err := os.Open(path)
8182
if err != nil {
@@ -96,7 +97,7 @@ func getFiles(path string) ([]string, error) {
9697
// only go 1 depth and leave directory entires blank
9798
if !v.IsDir() && v.Name()[len(v.Name())-len(testExtension):len(v.Name())] == testExtension {
9899
files[i] = filepath.Join(path, v.Name())
99-
// glog.Infoln(files[i])
100+
// glog.Infoln("Found file", files[i])
100101
}
101102
}
102103
case mode.IsRegular():
@@ -107,28 +108,24 @@ func getFiles(path string) ([]string, error) {
107108
return files, nil
108109
}
109110

110-
func runSuite(c *cli.Context) {
111-
flagTest := c.GlobalString(TestFlag.Name)
112-
flagFile := c.GlobalString(FileFlag.Name)
113-
continueOnError = c.GlobalBool(ContinueOnErrorFlag.Name)
114-
111+
func runSuite(test, file string) {
115112
var tests []string
116113

117-
if flagTest == defaultTest {
114+
if test == defaultTest {
118115
tests = allTests
119116
} else {
120-
tests = []string{flagTest}
117+
tests = []string{test}
121118
}
122119

123120
for _, curTest := range tests {
124-
// glog.Infoln("runSuite", curTest, flagFile)
121+
// glog.Infoln("runSuite", curTest, file)
125122
var err error
126123
var files []string
127-
if flagTest == defaultTest {
128-
files, err = getFiles(filepath.Join(flagFile, curTest))
124+
if test == defaultTest {
125+
files, err = getFiles(filepath.Join(file, curTest))
129126

130127
} else {
131-
files, err = getFiles(flagFile)
128+
files, err = getFiles(file)
132129
}
133130
if err != nil {
134131
glog.Fatalln(err)
@@ -159,15 +156,24 @@ func runSuite(c *cli.Context) {
159156
}
160157
}
161158

159+
func setupApp(c *cli.Context) {
160+
flagTest := c.GlobalString(TestFlag.Name)
161+
flagFile := c.GlobalString(FileFlag.Name)
162+
continueOnError = c.GlobalBool(ContinueOnErrorFlag.Name)
163+
164+
runSuite(flagTest, flagFile)
165+
}
166+
162167
func main() {
163168
glog.SetToStderr(true)
164169

165-
// vm.Debug = true
166-
167170
app := cli.NewApp()
168171
app.Name = "ethtest"
169172
app.Usage = "go-ethereum test interface"
170-
app.Action = runSuite
173+
app.Action = setupApp
174+
app.Version = "0.2.0"
175+
app.Author = "go-ethereum team"
176+
171177
app.Flags = []cli.Flag{
172178
TestFlag,
173179
FileFlag,

0 commit comments

Comments
 (0)