Skip to content

Commit

Permalink
* [fix] refactor parser methods and improve code clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
ysicing committed Aug 26, 2024
1 parent 04ba06e commit 7f28b44
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
17 changes: 0 additions & 17 deletions demo/sample/1_simple.sh

This file was deleted.

9 changes: 7 additions & 2 deletions internal/pkg/helper/script/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func ReadTitleAndStepsInNewFormat(content, lang string) (caseId int, title strin
}

func getSingleExpect(descAndExpect string) (desc, expect string) {
arr := strings.Split(descAndExpect, "@")
arr := strings.SplitN(descAndExpect, "@", 2)

desc = strings.TrimSpace(arr[0])
if len(arr) > 1 {
Expand All @@ -114,7 +114,6 @@ func getSingleExpect(descAndExpect string) (desc, expect string) {
expect = "pass"
}
}

return
}

Expand Down Expand Up @@ -150,6 +149,12 @@ func getMultiExpect(lines []string, index *int) (ret string) {
return
}

// isStepLine
/*
- 步骤1 # true 步骤1 false
- 子步骤1.1 # true 子步骤1.1 true
- 步骤2 # true 步骤2 false
*/
func isStepLine(line string) (is bool, ret string, isChild bool) {
reg := `^(\s*)-\s*(.+)$`
arr := regexp.MustCompile(reg).FindStringSubmatch(line)
Expand Down

0 comments on commit 7f28b44

Please sign in to comment.