-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
73 lines (58 loc) · 1.38 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/**
* Copyright 2015-2016, Wothing Co., Ltd.
* All rights reserved.
*
* Created by elvizlai on 2016/10/12 16:23.
*/
package main
import (
"flag"
"os"
"runtime"
"strings"
"time"
"github.com/wothing/wotest/file"
"github.com/wothing/wotest/log"
)
const wtSuffix = ".wt"
var passCount = 0
var failCount = 0
var files = "."
var debugMode = false
var forceMode = false
var ver = "1.0"
func init() {
var version = false
flag.BoolVar(&debugMode, "d", debugMode, "debug mode, echo enable")
flag.BoolVar(&forceMode, "f", forceMode, "force mode, stop test if err")
flag.StringVar(&files, "file", files, "wotest file or dir, if multiple, using ';' to separate")
flag.BoolVar(&version, "version", version, "show version info")
flag.Parse()
if version {
log.Infof("ver%s, using %s", ver, runtime.Version())
os.Exit(0)
}
if debugMode {
log.EnableDebugMode()
}
if forceMode {
log.EnableForceMode()
}
}
func main() {
var start = time.Now()
if args := flag.Args(); len(args) != 0 {
files = strings.Join(args, ";")
}
// read then run code
for _, v := range strings.Split(files, ";") {
for _, v := range file.List(v, wtSuffix) {
fileHandler(v)
}
}
if failCount == 0 {
log.Infof("\nall %d assert passed, using: %s", passCount, time.Now().Sub(start))
} else {
log.Fatalf("\n%d assert passed, %d assert failed, using: %s", passCount, failCount, time.Now().Sub(start))
}
}