Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zentaoatf
提交
86658092
Z
zentaoatf
项目概览
易企天创
/
zentaoatf
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
86658092
编写于
7月 16, 2019
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rerun failed cases in test result
上级
1c8e7f55
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
86 addition
and
2 deletion
+86
-2
src/action/rerun.go
src/action/rerun.go
+19
-0
src/atf.go
src/atf.go
+13
-0
src/biz/report.go
src/biz/report.go
+1
-1
src/misc/enum.go
src/misc/enum.go
+1
-1
src/utils/date.go
src/utils/date.go
+21
-0
src/utils/file.go
src/utils/file.go
+31
-0
未找到文件。
src/action/rerun.go
0 → 100644
浏览文件 @
86658092
package
action
import
(
"github.com/easysoft/zentaoatf/src/biz"
"github.com/easysoft/zentaoatf/src/model"
.
"github.com/easysoft/zentaoatf/src/utils"
)
func
Rerun
(
resultFile
string
)
{
files
,
scriptDir
,
langType
,
_
:=
GetFailedFiles
(
resultFile
)
var
report
=
model
.
TestReport
{
Path
:
scriptDir
,
Env
:
GetOs
(),
Pass
:
0
,
Fail
:
0
,
Total
:
0
,
Cases
:
make
([]
model
.
CaseLog
,
0
)}
biz
.
ExeScripts
(
files
,
scriptDir
,
langType
,
&
report
)
biz
.
CheckResults
(
files
,
scriptDir
,
langType
,
&
report
)
biz
.
Print
(
report
,
scriptDir
)
}
src/atf.go
浏览文件 @
86658092
...
...
@@ -14,6 +14,7 @@ func main() {
var
independentExpectFile
bool
var
fromUrl
string
var
path
string
var
files
strSlice
runSet
:=
flag
.
NewFlagSet
(
"atf run:
\n
Run test scripts in specified folder"
,
flag
.
ContinueOnError
)
...
...
@@ -21,6 +22,9 @@ func main() {
runSet
.
StringVar
(
&
langType
,
"l"
,
""
,
"Script Language like python, php etc."
)
runSet
.
Var
(
&
files
,
"f"
,
"Script files to run, no need langType if specified"
)
rerunSet
:=
flag
.
NewFlagSet
(
"atf rerun:
\n
Rerun failed test scripts in specified result"
,
flag
.
ContinueOnError
)
rerunSet
.
StringVar
(
&
path
,
"p"
,
""
,
"Test result file path"
)
genSet
:=
flag
.
NewFlagSet
(
"atf gen:
\n
Generate test scripts from zentao test cases"
,
flag
.
ContinueOnError
)
genSet
.
StringVar
(
&
fromUrl
,
"u"
,
""
,
"Remote interface for test case export"
)
genSet
.
StringVar
(
&
langType
,
"l"
,
""
,
"Script Language like python, php etc."
)
...
...
@@ -64,6 +68,15 @@ func main() {
action
.
Run
(
scriptDir
,
files
,
langType
)
}
}
case
"rerun"
:
if
err
:=
rerunSet
.
Parse
(
os
.
Args
[
2
:
]);
err
==
nil
{
if
path
==
""
{
rerunSet
.
Usage
()
os
.
Exit
(
1
)
}
else
{
action
.
Rerun
(
path
)
}
}
case
"gen"
:
if
err
:=
genSet
.
Parse
(
os
.
Args
[
2
:
]);
err
==
nil
{
if
fromUrl
==
""
||
langType
==
""
{
...
...
src/biz/report.go
浏览文件 @
86658092
...
...
@@ -57,5 +57,5 @@ func Print(report model.TestReport, workDir string) {
}
}
utils
.
WriteFile
(
workDir
+
"/logs/re
port
.txt"
,
strings
.
Join
(
logs
,
"
\n
"
))
utils
.
WriteFile
(
workDir
+
"/logs/re
sult-"
+
utils
.
DateTimeStrLong
(
time
.
Now
())
+
"
.txt"
,
strings
.
Join
(
logs
,
"
\n
"
))
}
src/misc/enum.go
浏览文件 @
86658092
...
...
@@ -33,7 +33,7 @@ func (c ResultStatus) String() string {
case
PASS
:
return
"PASS"
case
FAIL
:
return
"FAIL
L
"
return
"FAIL"
case
SKIP
:
return
"SKIP"
}
...
...
src/utils/date.go
0 → 100644
浏览文件 @
86658092
package
utils
import
(
"time"
)
func
DateStr
(
tm
time
.
Time
)
string
{
return
tm
.
Format
(
"2006-01-02"
)
}
func
TimeStr
(
tm
time
.
Time
)
string
{
return
tm
.
Format
(
"15:04:05"
)
}
func
DateTimeStr
(
tm
time
.
Time
)
string
{
return
tm
.
Format
(
"2006-01-02 15:04:05"
)
}
func
DateTimeStrLong
(
tm
time
.
Time
)
string
{
return
tm
.
Format
(
"20060102150405"
)
}
src/utils/file.go
浏览文件 @
86658092
...
...
@@ -96,6 +96,37 @@ func GetSpecifiedFiles(dirPth string, fileNames []string) (files []string, err e
return
ret
,
nil
}
func
GetFailedFiles
(
resultFile
string
)
([]
string
,
string
,
string
,
error
)
{
ret
:=
make
([]
string
,
0
)
dir
:=
""
extName
:=
""
content
:=
ReadFile
(
resultFile
)
reg
:=
regexp
.
MustCompile
(
`\nFAIL\s([^\n]+)\n`
)
arr
:=
reg
.
FindAllStringSubmatch
(
content
,
-
1
)
if
len
(
arr
)
>
1
{
for
_
,
file
:=
range
arr
{
if
len
(
file
)
==
1
{
continue
}
caseFile
:=
RemoveBlankLine
(
file
[
1
])
ret
=
append
(
ret
,
caseFile
)
if
dir
==
""
{
dir
=
path
.
Dir
(
caseFile
)
}
if
extName
==
""
{
extName
=
strings
.
TrimLeft
(
path
.
Ext
(
caseFile
),
"."
)
}
}
}
return
ret
,
dir
,
extName
,
nil
}
func
MkDir
(
dir
string
)
{
if
!
CheckFileIsExist
(
dir
)
{
os
.
Mkdir
(
dir
,
os
.
ModePerm
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录