diff --git a/src/biz/check.go b/src/biz/check.go index 71c71f7cf95553b8dbb328f44565df1b3b562d1e..0f3f2e0c66aba3b211d2292e3b4a469de75376db 100644 --- a/src/biz/check.go +++ b/src/biz/check.go @@ -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) { diff --git a/src/biz/run.go b/src/biz/run.go index 063c2aaf9f0decfc98c5331bf1e942d30b4f4d08..5ab04f5584e428349766ca1e69ff12af300f3ea9 100644 --- a/src/biz/run.go +++ b/src/biz/run.go @@ -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 diff --git a/src/model/test-model.go b/src/model/test-model.go index 9a631b6bb4fdb8985f87667f1ff1db2d97482ac2..d18b63fbf3826cd0c432e040b913b263471b621d 100644 --- a/src/model/test-model.go +++ b/src/model/test-model.go @@ -20,6 +20,9 @@ type TestStep struct { } type TestReport struct { + Path string + Env string + Pass int Fail int Total int diff --git a/src/run.go b/src/run.go index 6ac709cc75d716a03ddbd5a2243f2035fe9cd615..a13204fea39c2c6bdf3a1a65a6602f3648fe36f1 100644 --- a/src/run.go +++ b/src/run.go @@ -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) diff --git a/src/utils/utils.go b/src/utils/utils.go index 0870bf508cd69c8f31c82a087b51a99a4c339905..fc77391c49a1de8926abbf2c33d6797d49f7416e 100644 --- a/src/utils/utils.go +++ b/src/utils/utils.go @@ -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" +}