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

test on win7

上级 dbed31bf
......@@ -145,11 +145,17 @@
"message": "only en(%s) and zh(%s) language is acceptable",
"translation": "only en(%s) and zh(%s) language is acceptable"
},
{
"id": "run_sets_with_no_dir",
"message": "",
"translation": "To run suite or task, the first param should be a dir that contains scripts"
},
{
"id": "no_cases",
"message": "No test cases found",
"translation": "No test cases found"
},
{
"id": "no_scripts",
"message": "No test scripts found",
......
......@@ -133,6 +133,11 @@
"message": "只支持语言en(%s)和zh(%s)",
"translation": "只支持语言en(%s)和zh(%s)"
},
{
"id": "run_sets_with_no_dir",
"message": "",
"translation": "执行套件或任务时,第一个参数必须为包含脚本的目录"
},
{
"id": "no_cases",
"message": "No test cases found",
......
此差异已折叠。
goto start
<<<TC
caseId: 1
caseId: -1
productId: 0
title: Test network connection
steps: steps that begin with @ are checkpoints
......
......@@ -2,7 +2,7 @@
:<<!
<<<TC
caseId: 1
caseId: -1
productId: 0
title: Test network connection
steps: steps that begin with @ are checkpoints
......
......@@ -24,6 +24,19 @@ func Run(files []string, suiteIdStr string, taskIdStr string) {
vari.WorkDir = fileUtils.AbosutePath(".")
vari.RunDir = zentaoUtils.RunDateFolder()
if (suiteIdStr != "" || taskIdStr != "") && len(files) == 0 { // run with suite/task id, but no dir, get scripts from .
files = append(files, fileUtils.AbosutePath("."))
} else if (len(files) > 0 && path.Ext(files[0]) == "."+constant.ExtNameSuite) ||
(len(files) > 0 && path.Ext(files[0]) == "."+constant.ExtNameResult) { // only suite/result file provided
temp := make([]string, 0)
temp = append(temp, fileUtils.AbosutePath(path.Dir(files[0])))
temp = append(temp, files[0])
files = temp
}
if suiteIdStr != "" {
suiteId, err := strconv.Atoi(suiteIdStr)
if err == nil && suiteId > 0 {
......
......@@ -62,8 +62,8 @@ func main() {
switch os.Args[1] {
case "run", "-r":
files, idx := fileUtils.GetFilesFromParams(os.Args[2:])
if err := flagSet.Parse(os.Args[idx+1:]); err == nil {
files := fileUtils.GetFilesFromParams(os.Args[2:])
if err := flagSet.Parse(os.Args[len(files)+2:]); err == nil {
action.Run(files, suiteId, taskId)
}
......@@ -78,32 +78,32 @@ func main() {
}
case "ci":
files, idx := fileUtils.GetFilesFromParams(os.Args[2:])
if err := flagSet.Parse(os.Args[idx+1:]); err == nil {
files := fileUtils.GetFilesFromParams(os.Args[2:])
if err := flagSet.Parse(os.Args[len(files)+2:]); err == nil {
action.CommitCases(files)
}
case "cr":
files, idx := fileUtils.GetFilesFromParams(os.Args[2:])
if err := flagSet.Parse(os.Args[idx+1:]); err == nil {
files := fileUtils.GetFilesFromParams(os.Args[2:])
if err := flagSet.Parse(os.Args[len(files)+2:]); err == nil {
action.CommitResult(files)
}
case "cb":
files, idx := fileUtils.GetFilesFromParams(os.Args[2:])
if err := flagSet.Parse(os.Args[idx+1:]); err == nil {
files := fileUtils.GetFilesFromParams(os.Args[2:])
if err := flagSet.Parse(os.Args[len(files)+2:]); err == nil {
action.CommitBug(files)
}
case "list", "ls", "-l":
files, idx := fileUtils.GetFilesFromParams(os.Args[2:])
if err := flagSet.Parse(os.Args[idx+1:]); err == nil {
files := fileUtils.GetFilesFromParams(os.Args[2:])
if err := flagSet.Parse(os.Args[len(files)+2:]); err == nil {
action.List(files, keywords)
}
case "view", "-v":
files, idx := fileUtils.GetFilesFromParams(os.Args[2:])
if err := flagSet.Parse(os.Args[idx+1:]); err == nil {
files := fileUtils.GetFilesFromParams(os.Args[2:])
if err := flagSet.Parse(os.Args[len(files)+2:]); err == nil {
action.View(files, keywords)
}
......
......@@ -7,6 +7,7 @@ import (
commonUtils "github.com/easysoft/zentaoatf/src/utils/common"
constant "github.com/easysoft/zentaoatf/src/utils/const"
"github.com/easysoft/zentaoatf/src/utils/file"
langUtils "github.com/easysoft/zentaoatf/src/utils/lang"
zentaoUtils "github.com/easysoft/zentaoatf/src/utils/zentao"
"io/ioutil"
"os"
......@@ -118,6 +119,11 @@ func GetScriptByIdsInDir(dirPth string, idMap map[int]string, files *[]string) e
sep := string(os.PathSeparator)
name := path.Base(dirPth)
if strings.Index(name, ".") == 0 || name == "bin" || name == "release" || name == "logs" || name == "xdoc" {
return nil
}
dir, err := ioutil.ReadDir(dirPth)
if err != nil {
return err
......@@ -128,6 +134,13 @@ func GetScriptByIdsInDir(dirPth string, idMap map[int]string, files *[]string) e
if fi.IsDir() { // 目录, 递归遍历
GetScriptByIdsInDir(dirPth+name+sep, idMap, files)
} else {
regx := langUtils.GetSupportLangageRegx()
pass, _ := regexp.MatchString("^*.\\."+regx+"$", name)
if !pass {
continue
}
path := dirPth + name
if CheckFileIsScript(path) {
id, _, _ := zentaoUtils.GetCaseInfo(path)
......
......@@ -81,11 +81,10 @@ func UpdateDir(path string) string {
return path
}
func GetFilesFromParams(arguments []string) ([]string, int) {
func GetFilesFromParams(arguments []string) []string {
ret := make([]string, 0)
index := -1
for idx, arg := range arguments {
for _, arg := range arguments {
if strings.Index(arg, "-") != 0 {
if arg == "." {
arg = AbosutePath(".")
......@@ -96,9 +95,10 @@ func GetFilesFromParams(arguments []string) ([]string, int) {
}
ret = append(ret, arg)
index = idx
} else {
break
}
}
return ret, index
return ret
}
......@@ -88,6 +88,12 @@ func CheckSupportLangages(scriptLang string) bool {
return true
}
func GetSupportLangageRegx() string {
regx := "(" + strings.Join(GetSupportLangageArr(), "|") + ")"
return regx
}
func init() {
GetSupportedScriptLang()
}
......@@ -102,7 +102,7 @@ func InputForCheckout(productId *string, moduleId *string, suiteId *string, task
*independentFile = false
}
regx := "(" + strings.Join(langUtils.GetSupportLangageArr(), "|") + ")"
regx := langUtils.GetSupportLangageRegx()
fmtParam := strings.Join(langUtils.GetSupportLangageArr(), " / ")
*scriptLang = getInput(regx, "enter_co_language", fmtParam)
......
goto start
<<<TC
caseId: 1
caseId: -1
caseIdInTask: 0
taskId: 0
title: 测试服务器响应时间
......
......@@ -2,7 +2,7 @@
:<<!
<<<TC
caseId: 1
caseId: -1
caseIdInTask: 0
taskId: 0
title: 测试服务器响应时间
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册