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

support run with dir suite task result files

上级 04452418
...@@ -10,7 +10,6 @@ import ( ...@@ -10,7 +10,6 @@ import (
logUtils "github.com/easysoft/zentaoatf/src/utils/log" logUtils "github.com/easysoft/zentaoatf/src/utils/log"
"github.com/easysoft/zentaoatf/src/utils/vari" "github.com/easysoft/zentaoatf/src/utils/vari"
"github.com/fatih/color" "github.com/fatih/color"
"path"
"path/filepath" "path/filepath"
"strconv" "strconv"
) )
...@@ -43,10 +42,6 @@ func Run(files []string, suite string, task string, result string) { ...@@ -43,10 +42,6 @@ func Run(files []string, suite string, task string, result string) {
fileUtils.GetScriptByIdsInDir(files[0], caseIdMap, &cases) fileUtils.GetScriptByIdsInDir(files[0], caseIdMap, &cases)
} else { // find cases in current dir } else { // find cases in current dir
for _, file := range files { for _, file := range files {
if !path.IsAbs(file) {
file, _ = filepath.Abs(file)
}
fileUtils.GetAllScriptsInDir(file, &cases) fileUtils.GetAllScriptsInDir(file, &cases)
} }
} }
......
...@@ -8,6 +8,7 @@ import ( ...@@ -8,6 +8,7 @@ import (
"io/ioutil" "io/ioutil"
"os" "os"
"path" "path"
"path/filepath"
"regexp" "regexp"
"strconv" "strconv"
"strings" "strings"
...@@ -53,6 +54,11 @@ func FileExist(path string) bool { ...@@ -53,6 +54,11 @@ func FileExist(path string) bool {
} }
func GetAllScriptsInDir(dirPth string, files *[]string) error { func GetAllScriptsInDir(dirPth string, files *[]string) error {
dirPth = commonUtils.UpdateDir(dirPth)
if !path.IsAbs(dirPth) {
dirPth, _ = filepath.Abs(dirPth)
}
sep := string(os.PathSeparator) sep := string(os.PathSeparator)
dir, err := ioutil.ReadDir(dirPth) dir, err := ioutil.ReadDir(dirPth)
...@@ -75,10 +81,15 @@ func GetAllScriptsInDir(dirPth string, files *[]string) error { ...@@ -75,10 +81,15 @@ func GetAllScriptsInDir(dirPth string, files *[]string) error {
return nil return nil
} }
func GetScriptByIdsInDir(dir string, idMap map[int]string, files *[]string) error { func GetScriptByIdsInDir(dirPth string, idMap map[int]string, files *[]string) error {
dirPth = commonUtils.UpdateDir(dirPth)
if !path.IsAbs(dirPth) {
dirPth, _ = filepath.Abs(dirPth)
}
sep := string(os.PathSeparator) sep := string(os.PathSeparator)
dir, err := ioutil.ReadDir(dir) dir, err := ioutil.ReadDir(dirPth)
if err != nil { if err != nil {
return err return err
} }
...@@ -86,9 +97,9 @@ func GetScriptByIdsInDir(dir string, idMap map[int]string, files *[]string) erro ...@@ -86,9 +97,9 @@ func GetScriptByIdsInDir(dir string, idMap map[int]string, files *[]string) erro
for _, fi := range dir { for _, fi := range dir {
name := fi.Name() name := fi.Name()
if fi.IsDir() { // 目录, 递归遍历 if fi.IsDir() { // 目录, 递归遍历
GetAllScriptsInDir(dir+name+sep, files) GetAllScriptsInDir(dirPth+name+sep, files)
} else { } else {
path := dir + name path := dirPth + name
if CheckFileIsScript(path) { if CheckFileIsScript(path) {
*files = append(*files, path) *files = append(*files, path)
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册