Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zentaoatf
提交
0df77d7d
Z
zentaoatf
项目概览
易企天创
/
zentaoatf
9 个月 前同步成功
通知
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,体验更适合开发者的 AI 搜索 >>
提交
0df77d7d
编写于
10月 07, 2019
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add prefix space before case id when printing case result line
上级
d1c934d3
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
42 addition
and
22 deletion
+42
-22
res/res.go
res/res.go
+3
-3
src/action/run.go
src/action/run.go
+9
-1
src/service/testing/check.go
src/service/testing/check.go
+5
-4
src/service/testing/exe.go
src/service/testing/exe.go
+4
-4
src/utils/zentao/zentao.go
src/utils/zentao/zentao.go
+21
-10
未找到文件。
res/res.go
浏览文件 @
0df77d7d
此差异已折叠。
点击以展开。
src/action/run.go
浏览文件 @
0df77d7d
...
...
@@ -13,6 +13,7 @@ import (
logUtils
"github.com/easysoft/zentaoatf/src/utils/log"
stringUtils
"github.com/easysoft/zentaoatf/src/utils/string"
"github.com/easysoft/zentaoatf/src/utils/vari"
zentaoUtils
"github.com/easysoft/zentaoatf/src/utils/zentao"
"github.com/mattn/go-runewidth"
"path"
"strconv"
...
...
@@ -141,14 +142,21 @@ func runCases(files []string) {
Pass
:
0
,
Fail
:
0
,
Total
:
0
,
Cases
:
make
([]
model
.
CaseLog
,
0
)}
pathMaxWidth
:=
0
numbMaxWidth
:=
0
for
_
,
file
:=
range
casesToRun
{
lent
:=
runewidth
.
StringWidth
(
file
)
if
lent
>
pathMaxWidth
{
pathMaxWidth
=
lent
}
content
:=
fileUtils
.
ReadFile
(
file
)
caseId
:=
zentaoUtils
.
ReadCaseId
(
content
)
if
len
(
caseId
)
>
numbMaxWidth
{
numbMaxWidth
=
len
(
caseId
)
}
}
testingService
.
ExeScripts
(
casesToRun
,
&
report
,
pathMaxWidth
)
testingService
.
ExeScripts
(
casesToRun
,
&
report
,
pathMaxWidth
,
numbMaxWidth
)
testingService
.
Report
(
report
,
pathMaxWidth
)
}
...
...
src/service/testing/check.go
浏览文件 @
0df77d7d
...
...
@@ -16,7 +16,7 @@ import (
"strings"
)
func
CheckCaseResult
(
file
string
,
logs
string
,
report
*
model
.
TestReport
,
idx
int
,
total
int
,
secs
string
,
pathMaxWidth
int
)
{
func
CheckCaseResult
(
file
string
,
logs
string
,
report
*
model
.
TestReport
,
idx
int
,
total
int
,
secs
string
,
pathMaxWidth
int
,
numbMaxWidth
int
)
{
_
,
_
,
expectMap
:=
scriptUtils
.
GetStepAndExpectMap
(
file
)
isIndependent
,
expectIndependentContent
:=
zentaoUtils
.
GetDependentExpect
(
file
)
if
isIndependent
{
...
...
@@ -26,12 +26,12 @@ func CheckCaseResult(file string, logs string, report *model.TestReport, idx int
skip
,
actualArr
:=
zentaoUtils
.
ReadLogArr
(
logs
)
language
:=
langUtils
.
GetLangByFile
(
file
)
ValidateCaseResult
(
file
,
language
,
expectMap
,
skip
,
actualArr
,
report
,
idx
,
total
,
secs
,
pathMaxWidth
)
ValidateCaseResult
(
file
,
language
,
expectMap
,
skip
,
actualArr
,
report
,
idx
,
total
,
secs
,
pathMaxWidth
,
numbMaxWidth
)
}
func
ValidateCaseResult
(
scriptFile
string
,
langType
string
,
expectMap
maps
.
Map
,
skip
bool
,
actualArr
[][]
string
,
report
*
model
.
TestReport
,
idx
int
,
total
int
,
secs
string
,
pathMaxWidth
int
)
{
idx
int
,
total
int
,
secs
string
,
pathMaxWidth
int
,
numbMaxWidth
int
)
{
_
,
caseId
,
productId
,
title
:=
zentaoUtils
.
GetCaseInfo
(
scriptFile
)
...
...
@@ -85,6 +85,7 @@ func ValidateCaseResult(scriptFile string, langType string,
// print case result to console
statusColor
:=
logUtils
.
ColoredStatus
(
cs
.
Status
)
width
:=
strconv
.
Itoa
(
len
(
strconv
.
Itoa
(
total
)))
numbWidth
:=
strconv
.
Itoa
(
numbMaxWidth
)
path
:=
cs
.
Path
lent
:=
runewidth
.
StringWidth
(
path
)
...
...
@@ -94,7 +95,7 @@ func ValidateCaseResult(scriptFile string, langType string,
path
+=
postFix
}
format
:=
"(%"
+
width
+
"d/%d) %s [%s]
%d.%s
(%ss)"
format
:=
"(%"
+
width
+
"d/%d) %s [%s]
[%"
+
numbWidth
+
"d. %s]
(%ss)"
logUtils
.
Screen
(
fmt
.
Sprintf
(
format
,
idx
+
1
,
total
,
statusColor
,
path
,
cs
.
Id
,
cs
.
Title
,
secs
))
logUtils
.
Result
(
fmt
.
Sprintf
(
format
,
idx
+
1
,
total
,
i118Utils
.
I118Prt
.
Sprintf
(
cs
.
Status
),
path
,
cs
.
Id
,
cs
.
Title
,
secs
))
}
...
...
src/service/testing/exe.go
浏览文件 @
0df77d7d
...
...
@@ -10,7 +10,7 @@ import (
"time"
)
func
ExeScripts
(
casesToRun
[]
string
,
report
*
model
.
TestReport
,
pathMaxWidth
int
)
{
func
ExeScripts
(
casesToRun
[]
string
,
report
*
model
.
TestReport
,
pathMaxWidth
int
,
numbMaxWidth
int
)
{
now
:=
time
.
Now
()
startTime
:=
now
.
Unix
()
report
.
StartTime
=
startTime
...
...
@@ -19,7 +19,7 @@ func ExeScripts(casesToRun []string, report *model.TestReport, pathMaxWidth int)
i118Utils
.
I118Prt
.
Sprintf
(
"found_scripts"
,
len
(
casesToRun
))
+
"
\n
"
)
for
idx
,
file
:=
range
casesToRun
{
ExeScript
(
file
,
report
,
idx
,
len
(
casesToRun
),
pathMaxWidth
)
ExeScript
(
file
,
report
,
idx
,
len
(
casesToRun
),
pathMaxWidth
,
numbMaxWidth
)
}
endTime
:=
time
.
Now
()
.
Unix
()
...
...
@@ -29,7 +29,7 @@ func ExeScripts(casesToRun []string, report *model.TestReport, pathMaxWidth int)
report
.
Duration
=
secs
}
func
ExeScript
(
file
string
,
report
*
model
.
TestReport
,
idx
int
,
total
int
,
pathMaxWidth
int
)
{
func
ExeScript
(
file
string
,
report
*
model
.
TestReport
,
idx
int
,
total
int
,
pathMaxWidth
int
,
numbMaxWidth
int
)
{
startTime
:=
time
.
Now
()
logUtils
.
Log
(
"===start "
+
file
+
" at "
+
startTime
.
Format
(
"2006-01-02 15:04:05"
))
...
...
@@ -48,7 +48,7 @@ func ExeScript(file string, report *model.TestReport, idx int, total int, pathMa
logUtils
.
Log
(
"===end "
+
file
+
" at "
+
entTime
.
Format
(
"2006-01-02 15:04:05"
))
CheckCaseResult
(
file
,
logs
,
report
,
idx
,
total
,
secs
,
pathMaxWidth
)
CheckCaseResult
(
file
,
logs
,
report
,
idx
,
total
,
secs
,
pathMaxWidth
,
numbMaxWidth
)
if
idx
<
total
-
1
{
logUtils
.
Log
(
""
)
...
...
src/utils/zentao/zentao.go
浏览文件 @
0df77d7d
...
...
@@ -102,16 +102,16 @@ func GetCaseInfo(file string) (bool, int, int, string) {
return
pass
,
caseId
,
productId
,
title
}
func
ReadScriptCheckpoints
(
file
string
)
([]
string
,
[][]
string
)
{
_
,
expectIndependentContent
:=
GetDependentExpect
(
file
)
content
:=
fileUtils
.
ReadFile
(
file
)
_
,
checkpoints
:=
ReadCaseInfo
(
content
)
cpStepArr
,
expectArr
:=
getCheckpointStepArr
(
checkpoints
,
expectIndependentContent
)
return
cpStepArr
,
expectArr
}
//
func ReadScriptCheckpoints(file string) ([]string, [][]string) {
//
_, expectIndependentContent := GetDependentExpect(file)
//
//
content := fileUtils.ReadFile(file)
//
_, checkpoints := ReadCaseInfo(content)
//
//
cpStepArr, expectArr := getCheckpointStepArr(checkpoints, expectIndependentContent)
//
//
return cpStepArr, expectArr
//
}
func
getCheckpointStepArr
(
content
string
,
expectIndependentContent
string
)
([]
string
,
[][]
string
)
{
cpStepArr
:=
make
([]
string
,
0
)
expectArr
:=
make
([][]
string
,
0
)
...
...
@@ -272,6 +272,17 @@ func ReadCaseInfo(content string) (string, string) {
return
""
,
""
}
func
ReadCaseId
(
content
string
)
string
{
myExp
:=
regexp
.
MustCompile
(
`(?s)\[case\].*\ncid=((?U:.*))\n.*\[esac\]`
)
arr
:=
myExp
.
FindStringSubmatch
(
content
)
if
len
(
arr
)
>
1
{
id
:=
strings
.
TrimSpace
(
arr
[
1
])
return
id
}
return
""
}
func
GetDependentExpect
(
file
string
)
(
bool
,
string
)
{
expectIndependentFile
:=
strings
.
Replace
(
file
,
path
.
Ext
(
file
),
".exp"
,
-
1
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录