Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zentaoatf
提交
7ff9d4c9
Z
zentaoatf
项目概览
易企天创
/
zentaoatf
11 个月 前同步成功
通知
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 搜索 >>
提交
7ff9d4c9
编写于
7月 15, 2019
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
skip a test case when scripts print a line like "SKIP/skip"
上级
2808484a
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
139 addition
and
84 deletion
+139
-84
src/biz/check.go
src/biz/check.go
+30
-73
src/biz/report.go
src/biz/report.go
+61
-0
src/misc/enum.go
src/misc/enum.go
+20
-1
src/model/test-model.go
src/model/test-model.go
+4
-1
src/utils/file-utils.go
src/utils/file-utils.go
+14
-8
src/utils/utils.go
src/utils/utils.go
+9
-0
xdoc/scripts/tc-300.php
xdoc/scripts/tc-300.php
+1
-1
未找到文件。
src/biz/check.go
浏览文件 @
7ff9d4c9
...
...
@@ -2,10 +2,9 @@ package biz
import
(
"fmt"
"github.com/easysoft/zentaoatf/src/misc"
"github.com/easysoft/zentaoatf/src/model"
"github.com/easysoft/zentaoatf/src/utils"
"strings"
"time"
)
func
CheckResults
(
dir
string
,
langType
string
,
report
*
model
.
TestReport
)
{
...
...
@@ -18,42 +17,50 @@ func CheckResults(dir string, langType string, report *model.TestReport) {
stepArr
:=
utils
.
ReadCheckpointSteps
(
scriptFile
)
expectArr
:=
utils
.
ReadExpect
(
scriptFile
)
logArr
:=
utils
.
ReadLog
(
logFile
)
skip
,
logArr
:=
utils
.
ReadLog
(
logFile
)
ValidateTestCase
(
scriptFile
,
langType
,
stepArr
,
expectArr
,
logArr
,
report
)
ValidateTestCase
(
scriptFile
,
langType
,
stepArr
,
expectArr
,
skip
,
logArr
,
report
)
}
}
func
ValidateTestCase
(
scriptFile
string
,
langType
string
,
stepArr
[]
string
,
expectArr
[][]
string
,
actualArr
[][]
string
,
report
*
model
.
TestReport
)
{
stepArr
[]
string
,
expectArr
[][]
string
,
skip
bool
,
actualArr
[][]
string
,
report
*
model
.
TestReport
)
{
stepLogs
:=
make
([]
model
.
StepLog
,
0
)
caseResult
:=
misc
.
PASS
caseResult
:=
true
indx
:=
0
for
_
,
step
:=
range
stepArr
{
var
expectLines
[]
string
if
len
(
expectArr
)
>
indx
{
expectLines
=
expectArr
[
indx
]
}
if
skip
{
caseResult
=
misc
.
SKIP
}
else
{
indx
:=
0
for
_
,
step
:=
range
stepArr
{
var
expectLines
[]
string
if
len
(
expectArr
)
>
indx
{
expectLines
=
expectArr
[
indx
]
}
var
actualLines
[]
string
if
len
(
actualArr
)
>
indx
{
actualLines
=
actualArr
[
indx
]
}
var
actualLines
[]
string
if
len
(
actualArr
)
>
indx
{
actualLines
=
actualArr
[
indx
]
}
stepResult
,
checkpointLogs
:=
ValidateStep
(
langType
,
expectLines
,
actualLines
)
step
:=
model
.
StepLog
{
Numb
:
indx
+
1
,
Name
:
step
,
Status
:
stepResult
,
CheckPoints
:
checkpointLogs
}
stepLogs
=
append
(
stepLogs
,
step
)
stepResult
,
checkpointLogs
:=
ValidateStep
(
langType
,
expectLines
,
actualLines
)
step
:=
model
.
StepLog
{
Numb
:
indx
+
1
,
Name
:
step
,
Status
:
stepResult
,
CheckPoints
:
checkpointLogs
}
stepLogs
=
append
(
stepLogs
,
step
)
if
!
stepResult
{
caseResult
=
misc
.
FAIL
}
indx
++
indx
++
}
}
if
!
caseResult
{
if
caseResult
==
misc
.
FAIL
{
report
.
Fail
=
report
.
Fail
+
1
}
else
{
}
else
if
caseResult
==
misc
.
PASS
{
report
.
Pass
=
report
.
Pass
+
1
}
else
if
caseResult
==
misc
.
SKIP
{
report
.
Skip
=
report
.
Skip
+
1
}
report
.
Total
=
report
.
Total
+
1
...
...
@@ -89,56 +96,6 @@ func ValidateStep(langType string, expectLines []string, actualLines []string) (
}
func
Print
(
report
model
.
TestReport
,
workDir
string
)
{
startSec
:=
time
.
Unix
(
report
.
StartTime
,
0
)
endSec
:=
time
.
Unix
(
report
.
EndTime
,
0
)
logs
:=
make
([]
string
,
0
)
PrintAndLog
(
&
logs
,
fmt
.
Sprintf
(
"Run scripts in folder
\"
%s
\"
on %s OS
\n
"
,
report
.
Path
,
report
.
Env
))
PrintAndLog
(
&
logs
,
fmt
.
Sprintf
(
"From %s to %s, duration %d sec"
,
startSec
.
Format
(
"2006-01-02 15:04:05"
),
endSec
.
Format
(
"2006-01-02 15:04:05"
),
report
.
Duration
))
PrintAndLog
(
&
logs
,
fmt
.
Sprintf
(
"Total: %d, Fail: %d, Pass: %d"
,
report
.
Total
,
report
.
Pass
,
report
.
Fail
))
for
_
,
cs
:=
range
report
.
Cases
{
PrintAndLog
(
&
logs
,
fmt
.
Sprintf
(
"
\n
%s: %t"
,
cs
.
Path
,
cs
.
Status
))
if
len
(
cs
.
Steps
)
>
0
{
count
:=
0
for
_
,
step
:=
range
cs
.
Steps
{
if
count
>
0
{
// 空行
PrintAndLog
(
&
logs
,
""
)
}
PrintAndLog
(
&
logs
,
fmt
.
Sprintf
(
" Step %d %s: %t"
,
step
.
Numb
,
step
.
Name
,
step
.
Status
))
count1
:=
0
for
_
,
cp
:=
range
step
.
CheckPoints
{
if
count1
>
0
{
// 空行
PrintAndLog
(
&
logs
,
""
)
}
PrintAndLog
(
&
logs
,
fmt
.
Sprintf
(
" Checkpoint %d: %t"
,
cp
.
Numb
,
cp
.
Status
))
PrintAndLog
(
&
logs
,
fmt
.
Sprintf
(
" Expect %s"
,
cp
.
Expect
))
PrintAndLog
(
&
logs
,
fmt
.
Sprintf
(
" Actual %s"
,
cp
.
Actual
))
count1
++
}
count
++
}
}
else
{
PrintAndLog
(
&
logs
,
" No check points"
)
}
}
utils
.
WriteFile
(
workDir
+
"/logs/report.txt"
,
strings
.
Join
(
logs
,
"
\n
"
))
}
func
PrintAndLog
(
logs
*
[]
string
,
str
string
)
{
*
logs
=
append
(
*
logs
,
str
)
fmt
.
Println
(
str
)
...
...
src/biz/report.go
0 → 100644
浏览文件 @
7ff9d4c9
package
biz
import
(
"fmt"
"github.com/easysoft/zentaoatf/src/model"
"github.com/easysoft/zentaoatf/src/utils"
"strings"
"time"
)
func
Print
(
report
model
.
TestReport
,
workDir
string
)
{
startSec
:=
time
.
Unix
(
report
.
StartTime
,
0
)
endSec
:=
time
.
Unix
(
report
.
EndTime
,
0
)
logs
:=
make
([]
string
,
0
)
PrintAndLog
(
&
logs
,
fmt
.
Sprintf
(
"Run scripts in folder
\"
%s
\"
on %s OS
\n
"
,
report
.
Path
,
report
.
Env
))
PrintAndLog
(
&
logs
,
fmt
.
Sprintf
(
"From %s to %s, duration %d sec"
,
startSec
.
Format
(
"2006-01-02 15:04:05"
),
endSec
.
Format
(
"2006-01-02 15:04:05"
),
report
.
Duration
))
PrintAndLog
(
&
logs
,
fmt
.
Sprintf
(
"Total: %d, Fail: %d, Pass: %d, Skip: %d"
,
report
.
Total
,
report
.
Pass
,
report
.
Fail
,
report
.
Skip
))
for
_
,
cs
:=
range
report
.
Cases
{
PrintAndLog
(
&
logs
,
fmt
.
Sprintf
(
"
\n
%s %s"
,
cs
.
Status
.
String
(),
cs
.
Path
))
if
len
(
cs
.
Steps
)
>
0
{
count
:=
0
for
_
,
step
:=
range
cs
.
Steps
{
if
count
>
0
{
// 空行
PrintAndLog
(
&
logs
,
""
)
}
PrintAndLog
(
&
logs
,
fmt
.
Sprintf
(
" Step %d %s: %s"
,
step
.
Numb
,
step
.
Name
,
utils
.
BoolToPass
(
step
.
Status
)))
count1
:=
0
for
_
,
cp
:=
range
step
.
CheckPoints
{
if
count1
>
0
{
// 空行
PrintAndLog
(
&
logs
,
""
)
}
PrintAndLog
(
&
logs
,
fmt
.
Sprintf
(
" Checkpoint %d: %s"
,
cp
.
Numb
,
utils
.
BoolToPass
(
cp
.
Status
)))
PrintAndLog
(
&
logs
,
fmt
.
Sprintf
(
" Expect %s"
,
cp
.
Expect
))
PrintAndLog
(
&
logs
,
fmt
.
Sprintf
(
" Actual %s"
,
cp
.
Actual
))
count1
++
}
count
++
}
}
else
{
PrintAndLog
(
&
logs
,
" No check points"
)
}
}
utils
.
WriteFile
(
workDir
+
"/logs/report.txt"
,
strings
.
Join
(
logs
,
"
\n
"
))
}
src/misc/enum.go
浏览文件 @
7ff9d4c9
...
...
@@ -6,7 +6,6 @@ const (
PHP
LangType
=
iota
PYTHON
GO
UNKNOWN
)
func
(
c
LangType
)
String
()
string
{
...
...
@@ -20,3 +19,23 @@ func (c LangType) String() string {
}
return
"unknown"
}
type
ResultStatus
int
const
(
PASS
ResultStatus
=
iota
FAIL
SKIP
)
func
(
c
ResultStatus
)
String
()
string
{
switch
c
{
case
PASS
:
return
"PASS"
case
FAIL
:
return
"FAILL"
case
SKIP
:
return
"SKIP"
}
return
"UNKNOWN"
}
src/model/test-model.go
浏览文件 @
7ff9d4c9
package
model
import
"github.com/easysoft/zentaoatf/src/misc"
type
Response
struct
{
Code
int
Cases
[]
TestCase
...
...
@@ -25,6 +27,7 @@ type TestReport struct {
Pass
int
Fail
int
Skip
int
Total
int
StartTime
int64
EndTime
int64
...
...
@@ -35,7 +38,7 @@ type TestReport struct {
type
CaseLog
struct
{
Numb
int
Path
string
Status
bool
Status
misc
.
ResultStatus
Steps
[]
StepLog
}
...
...
src/utils/file-utils.go
浏览文件 @
7ff9d4c9
...
...
@@ -126,11 +126,11 @@ func ReadExpect(file string) [][]string {
return
ret
}
func
ReadLog
(
logFile
string
)
[][]
string
{
func
ReadLog
(
logFile
string
)
(
bool
,
[][]
string
)
{
str
:=
ReadFile
(
logFile
)
ret
:=
GenLogArr
(
str
)
return
ret
skip
,
ret
:=
GenLogArr
(
str
)
return
skip
,
ret
}
func
GenCheckpointStepArr
(
str
string
)
[]
string
{
...
...
@@ -147,17 +147,23 @@ func GenCheckpointStepArr(str string) []string {
}
func
GenExpectArr
(
str
string
)
[][]
string
{
return
GenArr
(
str
)
_
,
arr
:=
GenArr
(
str
,
false
)
return
arr
}
func
GenLogArr
(
str
string
)
[][]
string
{
return
GenArr
(
str
)
func
GenLogArr
(
str
string
)
(
bool
,
[][]
string
)
{
skip
,
arr
:=
GenArr
(
str
,
true
)
return
skip
,
arr
}
func
GenArr
(
str
string
)
[][]
string
{
func
GenArr
(
str
string
,
checkSkip
bool
)
(
bool
,
[][]
string
)
{
ret
:=
make
([][]
string
,
0
)
indx
:=
-
1
for
_
,
line
:=
range
strings
.
Split
(
str
,
"
\n
"
)
{
line
:=
strings
.
TrimSpace
(
line
)
if
checkSkip
&&
strings
.
ToLower
(
line
)
==
"skip"
{
return
true
,
nil
}
if
line
==
"#"
{
ret
=
append
(
ret
,
make
([]
string
,
0
))
indx
++
...
...
@@ -168,5 +174,5 @@ func GenArr(str string) [][]string {
}
}
return
ret
return
false
,
ret
}
src/utils/utils.go
浏览文件 @
7ff9d4c9
package
utils
import
(
"github.com/easysoft/zentaoatf/src/misc"
"os"
"path"
"regexp"
...
...
@@ -37,6 +38,14 @@ func ScriptToExpectName(file string) string {
return
expectName
}
func
BoolToPass
(
b
bool
)
string
{
if
b
{
return
misc
.
PASS
.
String
()
}
else
{
return
misc
.
FAIL
.
String
()
}
}
func
GetOs
()
string
{
osName
:=
runtime
.
GOOS
...
...
xdoc/scripts/tc-300.php
浏览文件 @
7ff9d4c9
...
...
@@ -14,7 +14,7 @@ readme:
TC;
/* 此处编写操作步骤代码 */
echo
(
"SKIP
\n
"
);
?>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录