Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zentaoatf
提交
d09ca681
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 搜索 >>
提交
d09ca681
编写于
4月 07, 2020
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/master'
上级
9c78eec1
8f71c5fb
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
149 addition
and
24 deletion
+149
-24
demo/selenium/chrome.php
demo/selenium/chrome.php
+2
-1
src/action/ztfResult.go
src/action/ztfResult.go
+0
-1
src/model/testing.go
src/model/testing.go
+46
-0
src/service/client/http.go
src/service/client/http.go
+6
-6
src/service/testing/unitTestReport.go
src/service/testing/unitTestReport.go
+2
-2
src/service/testing/unitTestResult.go
src/service/testing/unitTestResult.go
+63
-0
src/service/testing/ztfExec.go
src/service/testing/ztfExec.go
+2
-2
src/service/zentao/testResult.go
src/service/zentao/testResult.go
+5
-7
src/utils/vari/vari.go
src/utils/vari/vari.go
+1
-0
src/ztf.go
src/ztf.go
+22
-5
未找到文件。
demo/selenium/chrome.php
浏览文件 @
d09ca681
...
...
@@ -52,6 +52,7 @@ print(">> $title\n");
$driver
->
close
();
exec
(
'taskkill /F /im chrome80.exe'
);
function
isWindows
()
{
function
isWindows
()
{
return
strtoupper
(
substr
(
PHP_OS
,
0
,
3
))
===
'WIN'
;
}
\ No newline at end of file
src/action/ztfResult.go
浏览文件 @
d09ca681
...
...
@@ -16,5 +16,4 @@ func CommitZTFTestResult(files []string, noNeedConfirm bool) {
resultDir
=
fileUtils
.
UpdateDir
(
resultDir
)
zentaoService
.
CommitZTFTestResult
(
resultDir
,
noNeedConfirm
)
}
src/model/testing.go
浏览文件 @
d09ca681
...
...
@@ -265,3 +265,49 @@ type GTestSuites struct {
Duration
int
}
// cppunit xml
type
CppUnitSuites
struct
{
XMLName
xml
.
Name
`xml:"TestRun"`
SuccessfulTests
struct
{
TestCases
[]
CppUnitTest
`json:"test" xml:"Test"`
}
`json:"successfulTests" xml:"SuccessfulTests"`
FailedTests
struct
{
TestCases
[]
CppUnitTest
`json:"test" xml:"FailedTest"`
}
`json:"failedTests" xml:"FailedTests"`
Duration
int
}
type
CppUnitTest
struct
{
Id
int
`json:"id" xml:"Id,attr"`
Title
string
`json:"name" xml:"Name"`
FailureType
string
`json:"failureType" xml:"FailureType"`
Message
string
`json:"message" xml:"Message"`
Location
[]
struct
{
File
string
`json:"file" xml:"File"`
Line
string
`json:"line" xml:"Line"`
}
`json:"location" xml:"Location"`
Duration
int
}
// qtest xml
type
QTestSuites
struct
{
XMLName
xml
.
Name
`xml:"testsuite"`
Name
string
`json:"name" xml:"name,attr"`
TestCases
[]
struct
{
Title
string
`json:"name" xml:"name,attr"`
Result
string
`json:"result" xml:"result,attr"`
Failure
*
struct
{
Type
string
`json:"type" xml:"tag,attr"`
Desc
string
`json:"desc" xml:"message,attr"`
}
`json:"failure" xml:"failure"`
}
`json:"testCases" xml:"testcase"`
Properties
Properties
`json:"properties" xml:"properties"`
Duration
int
}
src/service/client/http.go
浏览文件 @
d09ca681
...
...
@@ -2,8 +2,6 @@ package client
import
(
"encoding/json"
"fmt"
"github.com/ajg/form"
"github.com/easysoft/zentaoatf/src/model"
constant
"github.com/easysoft/zentaoatf/src/utils/const"
"github.com/easysoft/zentaoatf/src/utils/log"
...
...
@@ -93,19 +91,20 @@ func PostObject(url string, params interface{}) (string, bool) {
}
else
{
url
=
url
+
"&"
+
vari
.
SessionVar
+
"="
+
vari
.
SessionId
}
url
=
url
+
"&XDEBUG_SESSION_START=PHPSTORM"
val
,
_
:=
json
.
Marshal
(
params
)
if
vari
.
Verbose
{
logUtils
.
PrintToCmd
(
url
,
-
1
)
logUtils
.
PrintToCmd
(
fmt
.
Sprintf
(
"%+v"
,
params
),
-
1
)
logUtils
.
PrintToCmd
(
string
(
val
),
-
1
)
}
client
:=
&
http
.
Client
{}
val
,
_
:=
form
.
EncodeToString
(
params
)
// convert data to post fomat
re3
,
_
:=
regexp
.
Compile
(
`([^&]*?)=`
)
data
:=
re3
.
ReplaceAllStringFunc
(
val
,
replacePostData
)
data
:=
re3
.
ReplaceAllStringFunc
(
string
(
val
)
,
replacePostData
)
req
,
reqErr
:=
http
.
NewRequest
(
"POST"
,
url
,
strings
.
NewReader
(
data
))
if
reqErr
!=
nil
{
...
...
@@ -116,6 +115,7 @@ func PostObject(url string, params interface{}) (string, bool) {
}
req
.
Header
.
Set
(
"Content-Type"
,
"application/x-www-form-urlencoded"
)
//req.Header.Set("cookie", vari.SessionVar+"="+vari.SessionId)
resp
,
respErr
:=
client
.
Do
(
req
)
...
...
src/service/testing/unitTestReport.go
浏览文件 @
d09ca681
...
...
@@ -57,8 +57,8 @@ func GenUnitTestReport(cases []model.UnitResult, classNameMaxWidth int,
postFix
=
"."
}
logUtils
.
ScreenAndResult
(
time
.
Now
()
.
Format
(
"2006-01-02 15:04:05"
)
+
" "
+
i118Utils
.
I118Prt
.
Sprintf
(
"found_scripts"
,
color
.
CyanString
(
strconv
.
Itoa
(
len
(
cases
))))
+
postFix
)
logUtils
.
ScreenAndResult
(
"
\n
"
+
logUtils
.
GetWholeLine
(
time
.
Now
()
.
Format
(
"2006-01-02 15:04:05"
)
+
" "
+
i118Utils
.
I118Prt
.
Sprintf
(
"found_scripts"
,
color
.
CyanString
(
strconv
.
Itoa
(
len
(
cases
))))
+
postFix
,
"="
)
)
if
report
.
Total
==
0
{
return
report
...
...
src/service/testing/unitTestResult.go
浏览文件 @
d09ca681
...
...
@@ -78,6 +78,20 @@ func RetrieveUnitResult() []model.UnitTestSuite {
if
err
==
nil
{
testSuite
=
ConvertGTestResult
(
gTestSuite
)
}
}
else
if
vari
.
UnitTestType
==
"cppunit"
{
content
=
strings
.
Replace
(
content
,
"ISO-8859-1"
,
"UTF-8"
,
-
1
)
cppUnitSuites
:=
model
.
CppUnitSuites
{}
err
=
xml
.
Unmarshal
([]
byte
(
content
),
&
cppUnitSuites
)
if
err
==
nil
{
testSuite
=
ConvertCppUnitResult
(
cppUnitSuites
)
}
}
else
if
vari
.
UnitTestType
==
"qtest"
{
qTestSuite
:=
model
.
QTestSuites
{}
err
=
xml
.
Unmarshal
([]
byte
(
content
),
&
qTestSuite
)
if
err
==
nil
{
testSuite
=
ConvertQTestResult
(
qTestSuite
)
}
}
else
{
testSuite
=
model
.
UnitTestSuite
{}
err
=
xml
.
Unmarshal
([]
byte
(
content
),
&
testSuite
)
...
...
@@ -230,3 +244,52 @@ func ConvertGTestResult(gTestSuite model.GTestSuites) model.UnitTestSuite {
return
testSuite
}
func
ConvertCppUnitResult
(
cppunitSuite
model
.
CppUnitSuites
)
model
.
UnitTestSuite
{
testSuite
:=
model
.
UnitTestSuite
{}
for
_
,
cs
:=
range
cppunitSuite
.
FailedTests
.
TestCases
{
caseResult
:=
model
.
UnitResult
{}
caseResult
.
Id
=
cs
.
Id
caseResult
.
Title
=
cs
.
Title
fail
:=
model
.
Failure
{}
fail
.
Type
=
cs
.
FailureType
fail
.
Desc
=
cs
.
Message
caseResult
.
Failure
=
&
fail
testSuite
.
TestCases
=
append
(
testSuite
.
TestCases
,
caseResult
)
}
for
_
,
cs
:=
range
cppunitSuite
.
SuccessfulTests
.
TestCases
{
caseResult
:=
model
.
UnitResult
{}
caseResult
.
Id
=
cs
.
Id
caseResult
.
Title
=
cs
.
Title
testSuite
.
TestCases
=
append
(
testSuite
.
TestCases
,
caseResult
)
}
return
testSuite
}
func
ConvertQTestResult
(
qTestSuite
model
.
QTestSuites
)
model
.
UnitTestSuite
{
testSuite
:=
model
.
UnitTestSuite
{}
for
_
,
cs
:=
range
qTestSuite
.
TestCases
{
caseResult
:=
model
.
UnitResult
{}
caseResult
.
TestSuite
=
qTestSuite
.
Name
caseResult
.
Title
=
cs
.
Title
caseResult
.
Status
=
cs
.
Result
if
cs
.
Failure
!=
nil
{
fail
:=
model
.
Failure
{}
fail
.
Type
=
cs
.
Failure
.
Type
fail
.
Desc
=
cs
.
Failure
.
Desc
caseResult
.
Failure
=
&
fail
}
testSuite
.
TestCases
=
append
(
testSuite
.
TestCases
,
caseResult
)
}
return
testSuite
}
src/service/testing/ztfExec.go
浏览文件 @
d09ca681
...
...
@@ -22,8 +22,8 @@ func ExeScripts(casesToRun []string, casesToIgnore []string, report *model.TestR
postFix
=
"."
}
logUtils
.
ScreenAndResult
(
now
.
Format
(
"2006-01-02 15:04:05"
)
+
" "
+
i118Utils
.
I118Prt
.
Sprintf
(
"found_scripts"
,
color
.
CyanString
(
strconv
.
Itoa
(
len
(
casesToRun
))))
+
postFix
)
logUtils
.
ScreenAndResult
(
"
\n
"
+
logUtils
.
GetWholeLine
(
now
.
Format
(
"2006-01-02 15:04:05"
)
+
" "
+
i118Utils
.
I118Prt
.
Sprintf
(
"found_scripts"
,
color
.
CyanString
(
strconv
.
Itoa
(
len
(
casesToRun
))))
+
postFix
,
"="
)
)
if
len
(
casesToIgnore
)
>
0
{
logUtils
.
ScreenAndResult
(
" "
+
...
...
src/service/zentao/testResult.go
浏览文件 @
d09ca681
package
zentaoService
import
(
"encoding/json"
"github.com/bitly/go-simplejson"
"github.com/easysoft/zentaoatf/src/model"
"github.com/easysoft/zentaoatf/src/service/client"
configUtils
"github.com/easysoft/zentaoatf/src/utils/config"
i118Utils
"github.com/easysoft/zentaoatf/src/utils/i118"
logUtils
"github.com/easysoft/zentaoatf/src/utils/log"
"github.com/easysoft/zentaoatf/src/utils/vari"
"github.com/easysoft/zentaoatf/src/utils/zentao"
"github.com/fatih/color"
"os"
"strconv"
)
func
CommitTestResult
(
report
model
.
TestReport
,
testTaskId
int
)
{
...
...
@@ -19,18 +20,14 @@ func CommitTestResult(report model.TestReport, testTaskId int) {
report
.
ZentaoData
=
os
.
Getenv
(
"ZENTAO_DATA"
)
report
.
BuildUrl
=
os
.
Getenv
(
"BUILD_URL"
)
report
.
ProductId
,
_
=
strconv
.
Atoi
(
vari
.
ProductId
)
report
.
TaskId
=
testTaskId
if
len
(
report
.
ZTFResults
)
>
0
{
report
.
ProductId
=
report
.
ZTFResults
[
0
]
.
ProductId
}
url
:=
conf
.
Url
+
zentaoUtils
.
GenApiUri
(
"unittest"
,
"commitResult"
,
""
)
logUtils
.
Screen
(
url
)
reportJson
,
_
:=
json
.
Marshal
(
report
)
logUtils
.
Screen
(
string
(
reportJson
))
url
:=
conf
.
Url
+
zentaoUtils
.
GenApiUri
(
"ci"
,
"commitResult"
,
""
)
resp
,
ok
:=
client
.
PostObject
(
url
,
report
)
if
ok
{
...
...
@@ -55,6 +52,7 @@ func CommitTestResult(report model.TestReport, testTaskId int) {
}
logUtils
.
Screen
(
msg
)
logUtils
.
Screen
(
logUtils
.
GetWholeLine
(
"="
,
"="
)
+
"
\n
"
)
if
report
.
Fail
>
0
||
!
ok
{
os
.
Exit
(
1
)
...
...
src/utils/vari/vari.go
浏览文件 @
d09ca681
...
...
@@ -18,6 +18,7 @@ var (
UnitTestType
string
UnitTestTool
string
UnitTestResult
string
ProductId
string
SessionVar
string
SessionId
string
...
...
src/ztf.go
浏览文件 @
d09ca681
...
...
@@ -158,18 +158,33 @@ func main() {
func
run
(
args
[]
string
)
{
if
len
(
args
)
>=
3
&&
stringUtils
.
FindInArr
(
args
[
2
],
constant
.
UnitTestType
)
{
// unit test
// junit -p 1 mvn clean package test
vari
.
UnitTestType
=
args
[
2
]
if
args
[
3
]
==
"mvn"
{
vari
.
UnitTestTool
=
"mvn"
}
else
{
flagSet
.
Parse
(
args
[
3
:
])
end
:=
8
if
end
>
len
(
args
)
-
1
{
end
=
len
(
args
)
-
1
}
flagSet
.
Parse
(
args
[
3
:
end
])
start
:=
3
if
vari
.
UnitTestResult
!=
""
{
start
=
start
+
2
}
else
{
vari
.
UnitTestResult
=
"./"
}
if
productId
!=
""
{
start
=
start
+
2
vari
.
ProductId
=
productId
}
if
vari
.
Verbose
{
start
=
start
+
1
}
if
args
[
start
]
==
"mvn"
{
vari
.
UnitTestTool
=
"mvn"
}
cmd
:=
strings
.
Join
(
args
[
start
:
],
" "
)
action
.
RunUnitTest
(
cmd
)
}
else
{
// func test
...
...
@@ -177,6 +192,8 @@ func run(args []string) {
err
:=
flagSet
.
Parse
(
args
[
len
(
files
)
+
2
:
])
if
err
==
nil
{
vari
.
ProductId
=
productId
if
len
(
files
)
==
0
{
files
=
append
(
files
,
"."
)
}
...
...
@@ -200,4 +217,4 @@ func init() {
func
cleanup
()
{
color
.
Unset
()
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录