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

support run with dir suite task result files

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