提交 c2306618 编写于 作者: aaronchen2k2k's avatar aaronchen2k2k

use struct to save the logs

上级 0c8ba34f
......@@ -74,6 +74,9 @@ func Print(report model.TestReport, workDir string) {
logs := make([]string, 0)
PrintAndLog(&logs, fmt.Sprintf("Run scripts in folder \"%s\" on %s OS\n",
report.Path, report.Env))
PrintAndLog(&logs, fmt.Sprintf("From %s to %s, duration %d sec",
startSec.Format("2006-01-02 15:04:05"), endSec.Format("2006-01-02 15:04:05"), report.Duration))
......@@ -101,7 +104,7 @@ func Print(report model.TestReport, workDir string) {
}
}
utils.WriteFile(workDir+"/logs/report.log", strings.Join(logs, "\n"))
utils.WriteFile(workDir+"/logs/report.txt", strings.Join(logs, "\n"))
}
func PrintAndLog(logs *[]string, str string) {
......
......@@ -3,7 +3,6 @@ package biz
import (
"fmt"
"model"
"runtime"
"strings"
"time"
"utils"
......@@ -27,11 +26,10 @@ func RunScripts(files []string, dir string, langType string, report *model.TestR
}
func RunScript(file string, langType string, dir string) {
osName := runtime.GOOS
var command string
var logFile string
if osName == "darwin" {
if utils.IsMac() {
logFile = utils.ScriptToLogName(dir, file)
command = file // + " > " + logFile
......
......@@ -20,6 +20,9 @@ type TestStep struct {
}
type TestReport struct {
Path string
Env string
Pass int
Fail int
Total int
......
......@@ -21,11 +21,8 @@ func main() {
files, _ := utils.GetAllFiles(*workDir, *langType)
var report model.TestReport
report.Pass = 0
report.Fail = 0
report.Total = 0
report.Cases = make([]model.CaseLog, 0)
var report = model.TestReport{Path: *workDir, Env: utils.GetOs(),
Pass: 0, Fail: 0, Total: 0, Cases: make([]model.CaseLog, 0)}
biz.RunScripts(files, *workDir, *langType, &report)
......
......@@ -4,6 +4,7 @@ import (
"os"
"path"
"regexp"
"runtime"
"strings"
)
......@@ -36,3 +37,16 @@ func ScriptToExpectName(file string) string {
return expectName
}
func GetOs() string {
osName := runtime.GOOS
if osName == "darwin" {
return "mac"
} else {
return osName
}
}
func IsMac() bool {
return GetOs() == "mac"
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册