From ab2b6542be878c59919cd595e0b3131b587870e2 Mon Sep 17 00:00:00 2001 From: Aaron Chen <462826@qq.com> Date: Thu, 8 Aug 2019 18:00:14 +0800 Subject: [PATCH] fix regx issue in windows --- res/res.go | 2 +- src/action/run.go | 8 ++++---- src/biz/report.go | 3 +-- src/test.go | 5 ++--- src/utils/file.go | 2 -- src/utils/utils.go | 12 ++++++------ 6 files changed, 14 insertions(+), 18 deletions(-) diff --git a/res/res.go b/res/res.go index 6f5e5be5..09a0bbd1 100644 --- a/res/res.go +++ b/res/res.go @@ -138,7 +138,7 @@ func resResGo() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "res/res.go", size: 12288, mode: os.FileMode(420), modTime: time.Unix(1565242287, 0)} + info := bindataFileInfo{name: "res/res.go", size: 12288, mode: os.FileMode(420), modTime: time.Unix(1565256982, 0)} a := &asset{bytes: bytes, info: info} return a, nil } diff --git a/src/action/run.go b/src/action/run.go index 2808af9a..5018f256 100644 --- a/src/action/run.go +++ b/src/action/run.go @@ -33,11 +33,11 @@ func Run(scriptDir string, fileNames []string, langType string) { utils.RunDir = utils.PathToRunName(scriptDir) } - var report = model.TestReport{Path: scriptDir, Env: utils.GetOs(), + var report = model.TestReport{Path: utils.Prefer.WorkDir, Env: utils.GetOs(), Pass: 0, Fail: 0, Total: 0, Cases: make([]model.CaseLog, 0)} - biz.ExeScripts(files, scriptDir, langType, &report) + biz.ExeScripts(files, utils.Prefer.WorkDir, langType, &report) - biz.CheckResults(files, scriptDir, langType, &report) - biz.Print(report, scriptDir) + biz.CheckResults(files, utils.Prefer.WorkDir, langType, &report) + biz.Print(report, utils.Prefer.WorkDir) } diff --git a/src/biz/report.go b/src/biz/report.go index 44681a28..939a8fec 100644 --- a/src/biz/report.go +++ b/src/biz/report.go @@ -5,7 +5,6 @@ import ( "github.com/easysoft/zentaoatf/src/model" "github.com/easysoft/zentaoatf/src/utils" "github.com/fatih/color" - "os" "strings" "time" ) @@ -73,5 +72,5 @@ func Print(report model.TestReport, workDir string) { } } - utils.WriteFile(workDir+string(os.PathSeparator)+utils.LogDir+utils.RunDir+"result.txt", strings.Join(logs, "\n")) + utils.WriteFile(workDir+utils.LogDir+utils.RunDir+"result.txt", strings.Join(logs, "\n")) } diff --git a/src/test.go b/src/test.go index d6972213..d3df8355 100644 --- a/src/test.go +++ b/src/test.go @@ -2,7 +2,6 @@ package main import ( "fmt" - "github.com/easysoft/zentaoatf/src/utils" ) func main() { @@ -16,6 +15,6 @@ func main() { // //fmt.Println(arr[1]) - a := utils.ConvertWorkDir("/sdf") - fmt.Println(a) + a := "." + fmt.Println(a == ".") } diff --git a/src/utils/file.go b/src/utils/file.go index 72a446ae..c85511df 100644 --- a/src/utils/file.go +++ b/src/utils/file.go @@ -50,7 +50,6 @@ func FileExist(path string) bool { func GetAllFiles(dirPth string, ext string, files *[]string) error { sep := string(os.PathSeparator) - var dirs []string dir, err := ioutil.ReadDir(dirPth) if err != nil { return err @@ -63,7 +62,6 @@ func GetAllFiles(dirPth string, ext string, files *[]string) error { continue } - dirs = append(dirs, dirPth+fi.Name()) GetAllFiles(dirPth+name+sep, ext, files) } else { // 过滤指定格式 diff --git a/src/utils/utils.go b/src/utils/utils.go index 52bf1ab7..e4bcff7d 100644 --- a/src/utils/utils.go +++ b/src/utils/utils.go @@ -124,19 +124,19 @@ func ConvertWorkDir(p string) string { // base on workdir func ConvertRunDir(p string) string { sepa := string(os.PathSeparator) - var temp string + if p == "." { return Prefer.WorkDir } - if IsRelativePath(p) { - temp = Prefer.WorkDir + p - } + //if IsRelativePath(p) { + // temp = Prefer.WorkDir + p + //} if !PathEndWithSeparator(p) { - temp = p + sepa + p = p + sepa } - return temp + return p } func IsRelativePath(path string) bool { -- GitLab