Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zentaoatf
提交
1efefdce
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,发现更多精彩内容 >>
未验证
提交
1efefdce
编写于
2月 08, 2022
作者:
H
Hind3ight
提交者:
GitHub
2月 08, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request
#4
from aaronchen2k/main
from main
上级
d2e6c095
a9c61f99
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
71 addition
and
30 deletion
+71
-30
internal/comm/consts/consts.go
internal/comm/consts/consts.go
+1
-0
internal/pkg/lib/file/file.go
internal/pkg/lib/file/file.go
+8
-0
internal/pkg/lib/file/zip.go
internal/pkg/lib/file/zip.go
+12
-0
internal/pkg/lib/http/http.go
internal/pkg/lib/http/http.go
+13
-7
internal/server/modules/v1/utils/exec/report-unit.go
internal/server/modules/v1/utils/exec/report-unit.go
+12
-4
internal/server/modules/v1/utils/zentao/bug.go
internal/server/modules/v1/utils/zentao/bug.go
+6
-4
internal/server/modules/v1/utils/zentao/result.go
internal/server/modules/v1/utils/zentao/result.go
+2
-2
internal/server/modules/v1/utils/zentao/zentao.go
internal/server/modules/v1/utils/zentao/zentao.go
+6
-6
res/server/zh/messages.json
res/server/zh/messages.json
+4
-4
ui/src/views/exec/exec/unit.vue
ui/src/views/exec/exec/unit.vue
+6
-2
ui/src/views/exec/history/result-func.vue
ui/src/views/exec/history/result-func.vue
+1
-1
未找到文件。
internal/comm/consts/consts.go
浏览文件 @
1efefdce
...
...
@@ -14,6 +14,7 @@ const (
LogText
=
"log.txt"
ResultText
=
"result.txt"
ResultJson
=
"result.json"
ResultZip
=
"result.zip"
ExpectResultPass
=
"pass"
)
internal/pkg/lib/file/file.go
浏览文件 @
1efefdce
...
...
@@ -104,6 +104,14 @@ func AddPathSepIfNeeded(pth string) string {
}
return
pth
}
func
RemovePathSepIfNeeded
(
pth
string
)
string
{
sep
:=
consts
.
PthSep
if
strings
.
LastIndex
(
pth
,
sep
)
==
len
(
pth
)
-
1
{
pth
=
pth
[
:
len
(
pth
)
-
1
]
}
return
pth
}
func
GetFilesFromParams
(
arguments
[]
string
)
[]
string
{
ret
:=
make
([]
string
,
0
)
...
...
internal/pkg/lib/file/zip.go
浏览文件 @
1efefdce
...
...
@@ -8,6 +8,18 @@ import (
"strings"
)
func
ZipDir
(
dist
string
,
dir
string
)
error
{
dir
=
RemovePathSepIfNeeded
(
dir
)
paths
:=
make
([]
string
,
0
)
paths
=
append
(
paths
,
dir
)
zip
:=
archiver
.
NewZip
()
err
:=
zip
.
Archive
(
paths
,
dist
)
return
err
}
func
ZipFiles
(
dist
string
,
dir
string
,
files
[]
string
)
error
{
dir
=
AddPathSepIfNeeded
(
dir
)
...
...
internal/pkg/lib/http/http.go
浏览文件 @
1efefdce
...
...
@@ -41,7 +41,8 @@ func Get(url string) (ret []byte, ok bool) {
bodyBytes
,
_
:=
ioutil
.
ReadAll
(
resp
.
Body
)
if
commConsts
.
Verbose
{
logUtils
.
PrintUnicode
(
bodyBytes
)
logUtils
.
Infof
(
i118Utils
.
Sprintf
(
"request_response"
))
logUtils
.
Infof
(
logUtils
.
ConvertUnicode
(
bodyBytes
))
}
defer
resp
.
Body
.
Close
()
...
...
@@ -50,7 +51,7 @@ func Get(url string) (ret []byte, ok bool) {
if
jsonErr
!=
nil
{
if
strings
.
Index
(
string
(
bodyBytes
),
"<html>"
)
>
-
1
{
if
commConsts
.
Verbose
{
logUtils
.
Errorf
(
i118Utils
.
Sprintf
(
"
server_return
"
)
+
" HTML - "
+
gohtml
.
FormatWithLineNo
(
string
(
bodyBytes
)))
logUtils
.
Errorf
(
i118Utils
.
Sprintf
(
"
request_response
"
)
+
" HTML - "
+
gohtml
.
FormatWithLineNo
(
string
(
bodyBytes
)))
}
return
}
else
{
...
...
@@ -98,7 +99,8 @@ func Post(url string, data interface{}, useFormFormat bool) (ret []byte, ok bool
}
if
commConsts
.
Verbose
{
logUtils
.
PrintUnicode
([]
byte
(
dataStr
))
logUtils
.
Infof
(
i118Utils
.
Sprintf
(
"request_content"
))
logUtils
.
Infof
(
dataStr
)
}
req
,
reqErr
:=
http
.
NewRequest
(
"POST"
,
url
,
strings
.
NewReader
(
dataStr
))
...
...
@@ -123,8 +125,10 @@ func Post(url string, data interface{}, useFormFormat bool) (ret []byte, ok bool
}
if
commConsts
.
Verbose
{
logUtils
.
PrintUnicode
(
bodyBytes
)
logUtils
.
Infof
(
i118Utils
.
Sprintf
(
"request_response"
))
logUtils
.
Infof
(
logUtils
.
ConvertUnicode
(
bodyBytes
))
}
defer
resp
.
Body
.
Close
()
ret
,
ok
=
GetRespErr
(
bodyBytes
,
url
)
...
...
@@ -151,7 +155,8 @@ func PostStr(url string, params map[string]string) (ret []byte, ok bool) {
}
if
commConsts
.
Verbose
{
logUtils
.
Infof
(
i118Utils
.
Sprintf
(
"server_params"
)
+
paramStr
)
logUtils
.
Infof
(
i118Utils
.
Sprintf
(
"request_content"
))
logUtils
.
Infof
(
paramStr
)
}
req
,
reqErr
:=
http
.
NewRequest
(
"POST"
,
url
,
strings
.
NewReader
(
paramStr
))
...
...
@@ -175,9 +180,10 @@ func PostStr(url string, params map[string]string) (ret []byte, ok bool) {
return
}
bytes
,
_
:=
ioutil
.
ReadAll
(
resp
.
Body
)
b
odyB
ytes
,
_
:=
ioutil
.
ReadAll
(
resp
.
Body
)
if
commConsts
.
Verbose
{
logUtils
.
Infof
(
i118Utils
.
Sprintf
(
"server_return"
)
+
logUtils
.
ConvertUnicode
(
bytes
))
logUtils
.
Infof
(
i118Utils
.
Sprintf
(
"request_response"
))
logUtils
.
Infof
(
logUtils
.
ConvertUnicode
(
bodyBytes
))
}
return
...
...
internal/server/modules/v1/utils/exec/report-unit.go
浏览文件 @
1efefdce
...
...
@@ -28,7 +28,10 @@ func GenUnitTestReport(req serverDomain.WsReq, startTime, endTime int64,
ch
chan
int
,
sendOutputMsg
,
sendExecMsg
func
(
info
,
isRunning
string
,
wsMsg
websocket
.
Message
),
wsMsg
websocket
.
Message
)
(
report
commDomain
.
ZtfReport
)
{
testSuites
:=
RetrieveUnitResult
(
req
.
ProjectPath
,
startTime
,
req
.
Framework
,
req
.
Tool
)
testSuites
,
zipDir
:=
RetrieveUnitResult
(
req
.
ProjectPath
,
startTime
,
req
.
Framework
,
req
.
Tool
)
unitResultPath
:=
filepath
.
Join
(
commConsts
.
ExecLogDir
,
commConsts
.
ResultZip
)
fileUtils
.
ZipDir
(
unitResultPath
,
zipDir
)
cases
,
classNameMaxWidth
,
duration
:=
ParserUnitTestResult
(
testSuites
)
if
duration
==
0
{
...
...
@@ -158,22 +161,27 @@ func GenUnitTestReport(req serverDomain.WsReq, startTime, endTime int64,
return
}
func
RetrieveUnitResult
(
projectPath
string
,
startTime
int64
,
testFramework
commConsts
.
UnitTestFramework
,
testTool
commConsts
.
UnitTestTool
)
(
suites
[]
commDomain
.
UnitTestSuite
)
{
resultFiles
:=
make
([]
string
,
0
)
func
RetrieveUnitResult
(
projectPath
string
,
startTime
int64
,
testFramework
commConsts
.
UnitTestFramework
,
testTool
commConsts
.
UnitTestTool
)
(
suites
[]
commDomain
.
UnitTestSuite
,
zipDir
string
)
{
resultDir
:=
""
resultFiles
:=
make
([]
string
,
0
)
if
testFramework
==
commConsts
.
JUnit
&&
testTool
==
commConsts
.
Maven
{
resultDir
=
filepath
.
Join
(
"target"
,
"surefire-reports"
)
zipDir
=
resultDir
}
else
if
testFramework
==
commConsts
.
TestNG
&&
testTool
==
commConsts
.
Maven
{
resultDir
=
filepath
.
Join
(
"target"
,
"surefire-reports"
,
"junitreports"
)
zipDir
=
filepath
.
Dir
(
resultDir
)
}
else
if
testFramework
==
commConsts
.
RobotFramework
||
testFramework
==
commConsts
.
Cypress
{
resultDir
=
"results"
zipDir
=
resultDir
}
else
{
resultDir
=
"results"
zipDir
=
resultDir
}
zipDir
=
filepath
.
Join
(
projectPath
,
zipDir
)
resultDir
=
filepath
.
Join
(
projectPath
,
resultDir
)
resultFiles
,
_
=
GetSuiteFiles
(
resultDir
,
startTime
)
...
...
internal/server/modules/v1/utils/zentao/bug.go
浏览文件 @
1efefdce
...
...
@@ -21,9 +21,11 @@ func CommitBug(ztfBug commDomain.ZtfBug, projectPath string) (err error) {
Login
(
config
)
ztfBug
.
Steps
=
strings
.
Replace
(
ztfBug
.
Steps
,
" "
,
" "
,
-
1
)
ztfBug
.
Steps
=
strings
.
Replace
(
ztfBug
.
Steps
,
"
\n
"
,
"<br />"
,
-
1
)
// ztfBug-create-1-0-caseID=1,version=3,resultID=93,runID=0,stepIdList=9_12_
// ztfBug-create-1-0-caseID=1,version=3,resultID=84,runID=6,stepIdList=9_12_,testtask=2,projectID=1,buildID=1
// bug-create-1-0-caseID=1,version=3,resultID=93,runID=0,stepIdList=9_12_
// bug-create-1-0-caseID=1,version=3,resultID=84,runID=6,stepIdList=9_12_,testtask=2,projectID=1,buildID=1
// http://zentaopms.deeptest.com/bug-create-1-0-moduleID=0.html
extras
:=
fmt
.
Sprintf
(
"caseID=%s,version=%s,resultID=0,runID=0,stepIdList=%s"
,
ztfBug
.
Case
,
ztfBug
.
Version
,
ztfBug
.
StepIds
)
...
...
@@ -34,8 +36,8 @@ func CommitBug(ztfBug commDomain.ZtfBug, projectPath string) (err error) {
}
else
{
params
=
fmt
.
Sprintf
(
"productID=%s&branch=0&$extras=%s"
,
ztfBug
.
Product
,
extras
)
}
params
=
""
url
:=
config
.
Url
+
GenApiUri
(
"
ztfB
ug"
,
"create"
,
params
)
//
params = ""
url
:=
config
.
Url
+
GenApiUri
(
"
b
ug"
,
"create"
,
params
)
bug
:=
commDomain
.
ZentaoBug
{}
copier
.
Copy
(
&
bug
,
ztfBug
)
...
...
internal/server/modules/v1/utils/zentao/result.go
浏览文件 @
1efefdce
...
...
@@ -24,13 +24,13 @@ func CommitResult(report commDomain.ZtfReport, result serverDomain.ZentaoResultS
Login
(
config
)
url
:=
config
.
Url
+
GenApiUri
(
"ci"
,
"commitResult"
,
""
)
_
,
ok
:=
httpUtils
.
Post
(
url
,
report
,
false
)
ret
,
ok
:=
httpUtils
.
Post
(
url
,
report
,
false
)
msg
:=
""
if
ok
{
msg
=
color
.
GreenString
(
i118Utils
.
Sprintf
(
"success_to_submit_test_result"
))
}
else
{
msg
=
color
.
RedString
(
err
.
Error
(
))
msg
=
color
.
RedString
(
string
(
ret
))
}
logUtils
.
Info
(
msg
)
...
...
internal/server/modules/v1/utils/zentao/zentao.go
浏览文件 @
1efefdce
...
...
@@ -264,15 +264,15 @@ func GetBugFiledOptions(req commDomain.FuncResult, projectPath string) (
func
GetStepText
(
step
commDomain
.
StepLog
)
string
{
stepResults
:=
make
([]
string
,
0
)
stepTxt
:=
fmt
.
Sprintf
(
"
%s %s
\n
"
,
step
.
Id
,
step
.
Status
)
stepTxt
:=
fmt
.
Sprintf
(
"
步骤%s: %s %s
\n
"
,
step
.
Id
,
step
.
Name
,
step
.
Status
)
for
_
,
checkpoint
:=
range
step
.
CheckPoints
{
text
:=
fmt
.
Sprintf
(
"
Checkpoint:
%s
\n
"
+
"
Expect
\n
"
+
" %s
\n
"
+
"
Actual
\n
"
+
" %s"
,
"
检查点:
%s
\n
"
+
"
期待结果:
\n
"
+
"
%s
\n
"
+
"
实际结果:
\n
"
+
"
%s"
,
checkpoint
.
Status
,
checkpoint
.
Expect
,
checkpoint
.
Actual
)
stepResults
=
append
(
stepResults
,
text
)
...
...
res/server/zh/messages.json
浏览文件 @
1efefdce
...
...
@@ -452,12 +452,12 @@
"translation"
:
"
\n
请求地址:
\n
"
},
{
"id"
:
"
server_params
"
,
"translation"
:
"
请求参数
:
\n
"
"id"
:
"
request_content
"
,
"translation"
:
"
\n
请求内容
:
\n
"
},
{
"id"
:
"
server_return
"
,
"translation"
:
"服务返回:
\n
"
"id"
:
"
request_response
"
,
"translation"
:
"
\n
服务返回:
\n
"
},
{
"id"
:
"task_id_empty_to_create"
,
...
...
ui/src/views/exec/exec/unit.vue
浏览文件 @
1efefdce
...
...
@@ -33,7 +33,8 @@
</a-select>
</a-form-item>
<a-form-item
label=
"测试工具"
v-bind=
"validateInfos.tool"
>
<a-form-item
label=
"测试工具"
v-if=
"model.framework=='junit' || model.framework=='testng'"
v-bind=
"validateInfos.tool"
>
<a-select
v-model:value=
"model.tool"
>
<a-select-option
key=
""
value=
""
>
</a-select-option>
<a-select-option
v-for=
"item in unitTestTools.data[model.framework]"
:key=
"item"
:value=
"item"
>
...
...
@@ -162,7 +163,7 @@ export default defineComponent({
initWsConn
()
})
const
model
=
reactive
<
any
>
({
productId
:
''
,
framework
:
''
,
cmd
:
''
});
const
model
=
reactive
<
any
>
({
productId
:
''
,
tool
:
''
,
framework
:
''
,
cmd
:
''
});
const
rules
=
reactive
({
productId
:
[
...
...
@@ -171,6 +172,9 @@ export default defineComponent({
framework
:
[
{
required
:
true
,
message
:
'
请选择单元测试框架
'
},
],
tool
:
[
{
required
:
true
,
message
:
'
请选择构建工具
'
},
],
cmd
:
[
{
required
:
true
,
message
:
'
请输入所要执行的命令
'
},
],
...
...
ui/src/views/exec/history/result-func.vue
浏览文件 @
1efefdce
...
...
@@ -266,7 +266,7 @@ export default defineComponent({
notification
.
success
({
message
:
'
提交成功
'
,
});
set
Result
FormVisible
(
false
)
set
Bug
FormVisible
(
false
)
}
else
{
notification
.
error
({
message
:
'
提交失败
'
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录