未验证 提交 1efefdce 编写于 作者: H Hind3ight 提交者: GitHub

Merge pull request #4 from aaronchen2k/main

from main
......@@ -14,6 +14,7 @@ const (
LogText = "log.txt"
ResultText = "result.txt"
ResultJson = "result.json"
ResultZip = "result.zip"
ExpectResultPass = "pass"
)
......@@ -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)
......
......@@ -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)
......
......@@ -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)
bodyBytes, _ := 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
......
......@@ -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)
......
......@@ -21,9 +21,11 @@ func CommitBug(ztfBug commDomain.ZtfBug, projectPath string) (err error) {
Login(config)
ztfBug.Steps = strings.Replace(ztfBug.Steps, " ", "&nbsp;", -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("ztfBug", "create", params)
//params = ""
url := config.Url + GenApiUri("bug", "create", params)
bug := commDomain.ZentaoBug{}
copier.Copy(&bug, ztfBug)
......
......@@ -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)
......
......@@ -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)
......
......@@ -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",
......
......@@ -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="">&nbsp;</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: '请输入所要执行的命令' },
],
......
......@@ -266,7 +266,7 @@ export default defineComponent({
notification.success({
message: '提交成功',
});
setResultFormVisible(false)
setBugFormVisible(false)
} else {
notification.error({
message: '提交失败',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册