diff --git a/src/action/run.go b/src/action/run.go index daec70fd337b1ab3ee3d9d291542b979321bc888..311d3abb934960b6e7c274d6112ab616b2a41ec1 100644 --- a/src/action/run.go +++ b/src/action/run.go @@ -23,13 +23,13 @@ func Run(files []string, suiteIdStr string, taskIdStr string) error { cases := make([]string, 0) - if suiteIdStr != "" { - if len(files) == 0 { // run with suite/task id, but no dir + if suiteIdStr != "" { // run with suite id, + if len(files) == 0 { // no dir files[0] = fileUtils.AbosutePath(".") } cases = getCaseBySuiteId(suiteIdStr, files[0]) - } else if taskIdStr != "" { - if len(files) == 0 { // run with suite/task id, but no dir + } else if taskIdStr != "" { // run with task id, + if len(files) == 0 { // no dir files[0] = fileUtils.AbosutePath(".") } cases = getCaseByTaskId(taskIdStr, files[0]) diff --git a/src/atf.go b/src/atf.go index 72ce3775d0d0c4dab9f9c2452814c6623f4e3528..eeaa9cff0dee63de99ff9a2a9d0225847bfbf14c 100644 --- a/src/atf.go +++ b/src/atf.go @@ -118,9 +118,8 @@ func main() { args = append(args, "run") args = append(args, os.Args[1:]...) - os.Args = args - files := fileUtils.GetFilesFromParams(os.Args[2:]) - if err := flagSet.Parse(os.Args[len(files)+2:]); err == nil { + files := fileUtils.GetFilesFromParams(args[2:]) + if err := flagSet.Parse(args[len(files)+2:]); err == nil { action.Run(files, suiteId, taskId) } } else { diff --git a/src/utils/file/file.go b/src/utils/file/file.go index 325bee328bcf6c7eba94d434490c72ac0b9ac643..c7448fa517a1cae60b006e48455ee6e68335b1f4 100644 --- a/src/utils/file/file.go +++ b/src/utils/file/file.go @@ -68,18 +68,20 @@ func AbosutePath(pth string) string { pth, _ = filepath.Abs(pth) } - pth = UpdateDir(pth) + if IsDir(pth) { + pth = UpdateDir(pth) + } return pth } -func UpdateDir(path string) string { +func UpdateDir(pth string) string { sepa := string(os.PathSeparator) - if strings.LastIndex(path, sepa) < len(path)-1 { - path += sepa + if strings.LastIndex(pth, sepa) < len(pth)-1 { + pth += sepa } - return path + return pth } func GetFilesFromParams(arguments []string) []string {