diff --git a/demo/sample/7_misc.php b/demo/sample/7_misc.php index d1d1bffc05cc36ad7a98bdd111e270884b4e02b6..62148868e209b25adf9a2bdb822d04c96cafa744 100755 --- a/demo/sample/7_misc.php +++ b/demo/sample/7_misc.php @@ -12,18 +12,17 @@ pid=0 3. steps step 3.1.1 step 3.1.2 - [3.1. expects] + 3.1. expects - [3.2. steps] + 3.2. steps step 3.2.1 step 3.2.2 - [3.2. expects] + 3.2. expects expect 3.2.1 expect 3.2.2 -[group] - 4. step 4 - 5. step 5 >> expect 5 +4. step 4 +5. step 5 >> expect 5 */ diff --git a/src/service/script/viewer.go b/src/service/script/viewer.go index 1b0bf39fc8dd9d0e61369be96da256476362a196..bf996da480b60a227d42a7435a177c1946cee171 100644 --- a/src/service/script/viewer.go +++ b/src/service/script/viewer.go @@ -4,8 +4,10 @@ import ( "fmt" "github.com/easysoft/zentaoatf/src/model" "github.com/easysoft/zentaoatf/src/utils/common" + constant "github.com/easysoft/zentaoatf/src/utils/const" "github.com/easysoft/zentaoatf/src/utils/file" i118Utils "github.com/easysoft/zentaoatf/src/utils/i118" + langUtils "github.com/easysoft/zentaoatf/src/utils/lang" logUtils "github.com/easysoft/zentaoatf/src/utils/log" zentaoUtils "github.com/easysoft/zentaoatf/src/utils/zentao" "github.com/fatih/color" @@ -120,14 +122,26 @@ func View(cases []string, keywords string) { func Brief(file string, keywords string) (bool, []string) { content := fileUtils.ReadFile(file) + lang := langUtils.GetLangByFile(file) + isOldFormat := strings.Index(content, "[esac]") > -1 - myExp := regexp.MustCompile( - `\[case\][\S\s]*` + + regStr := "" + if isOldFormat { + regStr = `\[case\][\S\s]*` + `title=([^\n]*)\n+` + `cid=([^\n]*)\n+` + `pid=([^\n]*)\n+` + `([\S\s]*)\n*` + - `\[esac\]`) + `\[esac\]` + } else { + regStr = fmt.Sprintf(`(?sm)%s[\S\s]*`+ + `title=([^\n]*)\n+`+ + `cid=([^\n]*)\n+`+ + `pid=([^\n]*)\n+`+ + `([\S\s]*)\n*%s`, + constant.LangCommentsMap[lang][0], constant.LangCommentsMap[lang][1]) + } + myExp := regexp.MustCompile(regStr) arr := myExp.FindStringSubmatch(content) if len(arr) > 2 { diff --git a/src/utils/zentao/zentao.go b/src/utils/zentao/zentao.go index 8e01106449daac05f6f771bcf4d338dd4554b9b4..683469cc98e3c3625e0b25e6b37ae5bf9b9e6589 100644 --- a/src/utils/zentao/zentao.go +++ b/src/utils/zentao/zentao.go @@ -83,7 +83,7 @@ func GetCaseInfo(file string) (bool, int, int, string) { if isOldFormat { regStr = `(?s)\[case\](.*)\[esac\]` } else { - regStr = fmt.Sprintf(`(?Us)%s(.*)%s`, + regStr = fmt.Sprintf(`(?sm)%s((?U:.*pid.*))\n(.*)%s`, constant.LangCommentsMap[lang][0], constant.LangCommentsMap[lang][1]) } myExp := regexp.MustCompile(regStr) diff --git a/src/ztf.go b/src/ztf.go index c5357a01128d545644d2baa7c61eb0ef7b72a8ec..3f3f791c2de54f17650d369ff54ddedfed5f53c0 100644 --- a/src/ztf.go +++ b/src/ztf.go @@ -140,11 +140,11 @@ func main() { case "set", "-set": action.Set() - case "sort", "-sort": - files := fileUtils.GetFilesFromParams(os.Args[2:]) - if err := flagSet.Parse(os.Args[len(files)+2:]); err == nil { - action.Sort(files) - } + //case "sort", "-sort": + // files := fileUtils.GetFilesFromParams(os.Args[2:]) + // if err := flagSet.Parse(os.Args[len(files)+2:]); err == nil { + // action.Sort(files) + // } case "clean", "-clean", "-c": action.Clean()