Skip to content

Commit

Permalink
fix a issue about more than one comments block in script
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronchen2k committed Jun 9, 2021
1 parent 55fd685 commit a6efd84
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 14 deletions.
2 changes: 1 addition & 1 deletion demo/sample/1_simple.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/

checkStep1() || print("expect 0\n");
checkStep1() || print("expect 1\n");
checkStep3() || print("expect 3\n");

function checkStep1(){}
Expand Down
38 changes: 26 additions & 12 deletions demo/sample/8_extract_desc.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env php
<?php

/**
Expand Down Expand Up @@ -28,24 +29,37 @@


/* group: group1 */
run() && out() && expect(); // Step: 1.1 >> expect 1.1
run() && out() && expect(); // Step: 1.2 >> expect 1.2
run() && out() && expect(); // Step: 1.3 >> expect 1.3 ]]
// Step: 1.1 >> expect 1.1
// Step: 1.2 >> expect 1.2
// Step: 1.3 >> expect 1.3 ]]

/* group: group2 */
run() && out() && expect(); // Step: 2.1 >> expect 2.1
run() && out() && expect(); // Step: 2.2 >> expect 2.2
run() && out() && expect(); // Step: 2.3 >> expect 2.3 ]]
// Step: 2.1 >> expect 2.1
// Step: 2.2 >> expect 2.2
// Step: 2.3 >> expect 2.3 ]]

/**
step: multi line expect >>
expect 3.1
expect 3.2
>>
*
*
*/
run() && out() && expect();
run() && out() && expect(); // step: 4 >> expect 4
run() && out() && expect(); // step: 5 >> expect 5

// step: 4 >> expect 4
// step: 5 >> expect 5

print("expect 1.1\n");
print("expect 1.2\n");
print("expect 1.3\n");

print("expect 2.1\n");
print("expect 2.2\n");
print("expect 2.3\n");

print(">>\n");
print("expect 3.1\n");
print("expect 3.2\n");
print("<<\n");

print("expect 4\n");
print("expect 5\n");
3 changes: 3 additions & 0 deletions src/utils/script/script.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,9 @@ func getSortedTextFromNestedSteps(groups []model.TestStep) (ret string, stepMap,
stepMap.Put(numbStr, stepTxt)

expectTxt := strings.TrimSpace(group.Expect)
expectTxt = strings.TrimRight(expectTxt, "]]")
expectTxt = strings.TrimSpace(expectTxt)

expectMap.Put(numbStr, expectTxt)

if expectTxt != "" {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/zentao/zentao.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ func ReadCaseInfo(content, lang string, isOldFormat bool) (info, checkpoints str
if isOldFormat {
regStr = `(?s)\[case\]((?U:.*pid.*))\n(.*)\[esac\]`
} else {
regStr = fmt.Sprintf(`(?sm)%s((?U:.*pid.*))\n(.*)%s`,
regStr = fmt.Sprintf(`(?smU)%s((?U:.*pid.*))\n(.*)%s`,
constant.LangCommentsRegxMap[lang][0], constant.LangCommentsRegxMap[lang][1])
}
myExp := regexp.MustCompile(regStr)
Expand Down

0 comments on commit a6efd84

Please sign in to comment.