Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zentaoatf
提交
d66e4dad
Z
zentaoatf
项目概览
易企天创
/
zentaoatf
大约 1 年 前同步成功
通知
11
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
3
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
zentaoatf
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
3
Issue
3
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d66e4dad
编写于
8月 29, 2022
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/main'
上级
29896f11
37b3705f
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
74 addition
and
9 deletion
+74
-9
internal/pkg/helper/exec/result.go
internal/pkg/helper/exec/result.go
+15
-0
test/cli_run_test.go
test/cli_run_test.go
+57
-7
test/ui_result_test.go
test/ui_result_test.go
+2
-2
未找到文件。
internal/pkg/helper/exec/result.go
浏览文件 @
d66e4dad
...
@@ -243,6 +243,21 @@ func MatchScene(expect, actual, langType string) (pass bool) {
...
@@ -243,6 +243,21 @@ func MatchScene(expect, actual, langType string) (pass bool) {
case
"!="
:
case
"!="
:
return
actualFloot
!=
expectFloot
return
actualFloot
!=
expectFloot
}
}
}
else
if
strings
.
Contains
(
expect
,
"-"
)
&&
strings
.
Count
(
expect
,
"-"
)
==
1
{
rangeArr
:=
strings
.
Split
(
expect
,
"-"
)
rangeFrom
,
err
:=
strconv
.
ParseFloat
(
strings
.
TrimSpace
(
rangeArr
[
0
]),
64
)
if
err
!=
nil
{
return
false
}
rangeTo
,
err
:=
strconv
.
ParseFloat
(
strings
.
TrimSpace
(
rangeArr
[
1
]),
64
)
if
err
!=
nil
{
return
false
}
actualFloot
,
err
:=
strconv
.
ParseFloat
(
strings
.
TrimSpace
(
actual
),
64
)
if
err
!=
nil
{
return
false
}
return
actualFloot
>=
rangeFrom
&&
actualFloot
<=
rangeTo
}
else
{
}
else
{
character
:=
expect
[
:
1
]
character
:=
expect
[
:
1
]
expectFloot
,
err
:=
strconv
.
ParseFloat
(
strings
.
TrimSpace
(
expect
[
1
:
]),
64
)
expectFloot
,
err
:=
strconv
.
ParseFloat
(
strings
.
TrimSpace
(
expect
[
1
:
]),
64
)
...
...
test/cli_run_test.go
浏览文件 @
d66e4dad
...
@@ -45,11 +45,11 @@ import (
...
@@ -45,11 +45,11 @@ import (
var
(
var
(
scriptResMap
=
map
[
string
]
*
regexp
.
Regexp
{
scriptResMap
=
map
[
string
]
*
regexp
.
Regexp
{
"ztf run demo/1_string_match_pass.php"
:
regexp
.
MustCompile
(
`Run 1 scripts in \d+ sec, 1\(100\.0%\) Pass, 0\(0\.0%\) Fail, 0\(0\.0%\) Skip`
),
"ztf run demo/1_string_match_pass.php"
:
regexp
.
MustCompile
(
`Run 1 scripts in \d+ sec, 1\(100\.0%\) Pass, 0\(0\.0%\) Fail, 0\(0\.0%\) Skip
|执行1个用例,耗时\d+秒。1\(100\.0%\) 通过,0\(0\.0%\) 失败,0\(0\.0%\) 忽略
`
),
"ztf run demo demo/all.cs"
:
regexp
.
MustCompile
(
`Run 2 scripts in \d+ sec, 1\(50\.0%\) Pass, 1\(50\.0%\) Fail, 0\(0\.0%\) Skip`
),
"ztf run demo demo/all.cs"
:
regexp
.
MustCompile
(
`Run 2 scripts in \d+ sec, 1\(50\.0%\) Pass, 1\(50\.0%\) Fail, 0\(0\.0%\) Skip
|执行2个用例,耗时\d+秒。1\(50\.0%\) 通过,1\(50\.0%\) 失败,0\(0\.0%\) 忽略
`
),
// "ztf run demo/001/result.txt": regexp.MustCompile(`Run 1 scripts in \d+ sec, 0\(0\.0%\) Pass, 1\(100\.0%\) Fail, 0\(0\.0%\) Skip`),
// "ztf run demo/001/result.txt": regexp.MustCompile(`Run 1 scripts in \d+ sec, 0\(0\.0%\) Pass, 1\(100\.0%\) Fail, 0\(0\.0%\) Skip`),
"ztf run demo -suite 1"
:
regexp
.
MustCompile
(
`Run 2 scripts in \d+ sec, 1\(50\.0%\) Pass, 1\(50\.0%\) Fail, 0\(0\.0%\) Skip`
),
"ztf run demo -suite 1"
:
regexp
.
MustCompile
(
`Run 2 scripts in \d+ sec, 1\(50\.0%\) Pass, 1\(50\.0%\) Fail, 0\(0\.0%\) Skip
|执行2个用例,耗时\d+秒。1\(50\.0%\) 通过,1\(50\.0%\) 失败,0\(0\.0%\) 忽略
`
),
"ztf run demo -task 1"
:
regexp
.
MustCompile
(
`Run 2 scripts in \d+ sec, 1\(50\.0%\) Pass, 1\(50\.0%\) Fail, 0\(0\.0%\) Skip`
),
"ztf run demo -task 1"
:
regexp
.
MustCompile
(
`Run 2 scripts in \d+ sec, 1\(50\.0%\) Pass, 1\(50\.0%\) Fail, 0\(0\.0%\) Skip
|执行2个用例,耗时\d+秒。1\(50\.0%\) 通过,1\(50\.0%\) 失败,0\(0\.0%\) 忽略
`
),
// "ztf run demo -p 1 -t task1 -cr -cb": regexp.MustCompile(`Submitted test results to ZenTao\.[\s\S]+Success to report bug for case 6`),
// "ztf run demo -p 1 -t task1 -cr -cb": regexp.MustCompile(`Submitted test results to ZenTao\.[\s\S]+Success to report bug for case 6`),
}
}
)
)
...
@@ -59,14 +59,13 @@ type RunSuit struct {
...
@@ -59,14 +59,13 @@ type RunSuit struct {
testCount
uint32
testCount
uint32
}
}
func
(
s
*
RunSuit
)
TestRun
Suite
()
{
func
(
s
*
RunSuit
)
TestRun
Ztf
()
{
for
cmd
,
expectReg
:=
range
scriptResMap
{
for
cmd
,
expectReg
:=
range
scriptResMap
{
if
runtime
.
GOOS
==
"windows"
{
if
runtime
.
GOOS
==
"windows"
{
cmd
=
strings
.
ReplaceAll
(
cmd
,
"/"
,
"
\\
"
)
cmd
=
strings
.
ReplaceAll
(
cmd
,
"/"
,
"
\\
"
)
}
}
assert
.
Equal
(
s
.
Suite
.
T
(),
"Success"
,
testRun
(
cmd
,
expectReg
))
assert
.
Equal
(
s
.
Suite
.
T
(),
"Success"
,
testRun
(
cmd
,
expectReg
))
}
}
}
}
func
(
s
*
RunSuit
)
TestRunUnitTest
()
{
func
(
s
*
RunSuit
)
TestRunUnitTest
()
{
testngDir
:=
"./demo/ci_test_testng"
testngDir
:=
"./demo/ci_test_testng"
...
@@ -92,7 +91,7 @@ func testRun(cmd string, expectReg *regexp.Regexp) string {
...
@@ -92,7 +91,7 @@ func testRun(cmd string, expectReg *regexp.Regexp) string {
defer
child
.
Close
()
defer
child
.
Close
()
if
_
,
err
:=
child
.
Expect
(
expectReg
,
10
*
time
.
Second
);
err
!=
nil
{
if
_
,
err
:=
child
.
Expect
(
expectReg
,
10
*
time
.
Second
);
err
!=
nil
{
return
fmt
.
Sprintf
(
"
expect %s, actual %s"
,
expectReg
,
err
.
Error
())
return
fmt
.
Sprintf
(
"
cmd:%s, expect %s, actual %s"
,
cmd
,
expectReg
,
err
.
Error
())
}
}
return
"Success"
return
"Success"
...
@@ -175,6 +174,57 @@ func testRunUnitTest(cmdStr, workspacePath string, successRe *regexp.Regexp) str
...
@@ -175,6 +174,57 @@ func testRunUnitTest(cmdStr, workspacePath string, successRe *regexp.Regexp) str
return
"Success"
return
"Success"
}
}
func
(
s
*
RunSuit
)
TestRunScenes
()
{
sceneMap
:=
map
[
string
]
string
{
"exactly empty >> ~~"
:
""
,
"exactly start with abc >> ~f:^abc~"
:
"abcdvd"
,
"exactly end with abc >> ~f:abc$~"
:
"dcdabc"
,
"exactly contain abc >> ~f:abc~"
:
"dvabcd"
,
"exactly containX abc*3 >> ~f:abc*3~"
:
"dvabcdabcabcdds"
,
"exactly 2 in (1,2,3) >> ~f:(1,2,3)~"
:
"2"
,
"exactly match %sabc%d >> ~m:%sabc%d~"
:
"dabc1dad"
,
"exactly match .*cid=.* >> ~m:.*cid=.*~"
:
"sdfascid=ljlkjl"
,
"exactly equal 123 >> ~c:=123~"
:
"123"
,
"exactly less than 123 >> ~c:<123~"
:
"1"
,
"exactly less than or equal 123 >> ~c:<=123~"
:
"123"
,
"exactly greater than 123 >> ~c:>123~"
:
"124"
,
"exactly greater than or equal 123 >> ~c:>=123~"
:
"123"
,
"exactly not equal 123 >> ~c:<>123~"
:
"120"
,
"exactly between 12-19 >> ~c:12-19~"
:
"15"
,
}
template
:=
`#!/usr/bin/env php
<?php
/**
title=check string matches pattern
cid=1
pid=1
%s
*/
print("%s\n");`
path
:=
"./demo/test"
if
runtime
.
GOOS
==
"windows"
{
path
=
`.\demo\test_scene.php`
}
cmd
:=
`ztf run `
+
path
for
expectVal
,
actualVal
:=
range
sceneMap
{
file
,
err
:=
os
.
OpenFile
(
path
,
os
.
O_WRONLY
|
os
.
O_TRUNC
|
os
.
O_CREATE
,
0666
)
defer
file
.
Close
()
if
err
!=
nil
{
s
.
Suite
.
T
()
.
Errorf
(
"open file fail, err:%s"
,
err
)
return
}
write
:=
bufio
.
NewWriter
(
file
)
write
.
WriteString
(
fmt
.
Sprintf
(
template
,
expectVal
,
actualVal
))
write
.
Flush
()
assert
.
Equal
(
s
.
Suite
.
T
(),
"Success"
,
testRun
(
cmd
,
regexp
.
MustCompile
(
`Run 1 scripts in \d+ sec, 1\(100\.0%\) Pass, 0\(0\.0%\) Fail, 0\(0\.0%\) Skip|执行1个用例,耗时\d+秒。1\(100\.0%\) 通过,0\(0\.0%\) 失败,0\(0\.0%\) 忽略`
)))
}
}
func
TestRun
(
t
*
testing
.
T
)
{
func
TestRun
(
t
*
testing
.
T
)
{
suite
.
Run
(
t
,
new
(
RunSuit
))
suite
.
Run
(
t
,
new
(
RunSuit
))
}
}
test/ui_result_test.go
浏览文件 @
d66e4dad
...
@@ -312,6 +312,6 @@ func SubmitBug(t *testing.T) {
...
@@ -312,6 +312,6 @@ func SubmitBug(t *testing.T) {
func
TestUiResult
(
t
*
testing
.
T
)
{
func
TestUiResult
(
t
*
testing
.
T
)
{
t
.
Run
(
"Detail"
,
Detail
)
t
.
Run
(
"Detail"
,
Detail
)
//
t.Run("SubmitResult", SubmitResult)
t
.
Run
(
"SubmitResult"
,
SubmitResult
)
//
t.Run("SubmitBug", SubmitBug)
t
.
Run
(
"SubmitBug"
,
SubmitBug
)
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录