提交 78ee032f 编写于 作者: aaronchen2k2k's avatar aaronchen2k2k

go test and allure support

上级 01321c3c
...@@ -198,7 +198,7 @@ func RetrieveUnitResult(workspacePath string, startTime int64, testTool commCons ...@@ -198,7 +198,7 @@ func RetrieveUnitResult(workspacePath string, startTime int64, testTool commCons
testTool == commConsts.Playwright || testTool == commConsts.Puppeteer { testTool == commConsts.Playwright || testTool == commConsts.Puppeteer {
resultDir = "results" resultDir = "results"
zipDir = resultDir zipDir = resultDir
} else if testTool == commConsts.Allure || testTool == commConsts.GoTest { } else if isAllureReport(testTool) {
resultDir = commConsts.AllureReportDir resultDir = commConsts.AllureReportDir
zipDir = resultDir zipDir = resultDir
} else { } else {
...@@ -212,7 +212,7 @@ func RetrieveUnitResult(workspacePath string, startTime int64, testTool commCons ...@@ -212,7 +212,7 @@ func RetrieveUnitResult(workspacePath string, startTime int64, testTool commCons
resultFiles, _ = GetSuiteFiles(resultDir, startTime, testTool) resultFiles, _ = GetSuiteFiles(resultDir, startTime, testTool)
} }
if testTool == commConsts.Allure { if isAllureReport(testTool) {
if resultDir != "" { if resultDir != "" {
suites = GetAllureSuites(resultDir, startTime) suites = GetAllureSuites(resultDir, startTime)
} else { } else {
...@@ -274,7 +274,7 @@ func GetSuiteFiles(resultDir string, startTime int64, testTool commConsts.TestTo ...@@ -274,7 +274,7 @@ func GetSuiteFiles(resultDir string, startTime int64, testTool commConsts.TestTo
continue continue
} }
if (testTool == commConsts.Allure && ext == ".json") || ext == ".xml" { if (isAllureReport(testTool) && ext == ".json") || ext == ".xml" {
pth := filepath.Join(resultDir, name) pth := filepath.Join(resultDir, name)
resultFiles = append(resultFiles, pth) resultFiles = append(resultFiles, pth)
} }
...@@ -780,3 +780,7 @@ func ConvertCyResult(result commDomain.CypressTestsuites) commDomain.UnitTestSui ...@@ -780,3 +780,7 @@ func ConvertCyResult(result commDomain.CypressTestsuites) commDomain.UnitTestSui
return testSuite return testSuite
} }
func isAllureReport(testTool commConsts.TestTool) (ret bool) {
return testTool == commConsts.Allure || testTool == commConsts.GoTest
}
...@@ -6,6 +6,7 @@ import ( ...@@ -6,6 +6,7 @@ import (
fileUtils "github.com/easysoft/zentaoatf/pkg/lib/file" fileUtils "github.com/easysoft/zentaoatf/pkg/lib/file"
"io" "io"
"os/exec" "os/exec"
"path/filepath"
"strings" "strings"
"time" "time"
...@@ -43,7 +44,8 @@ func ExecUnit(ch chan int, ...@@ -43,7 +44,8 @@ func ExecUnit(ch chan int,
arr := strings.Split(req.Cmd, " ") arr := strings.Split(req.Cmd, " ")
if len(arr) > 1 && strings.TrimSpace(arr[0]) == "-allureReportDir" { if len(arr) > 1 && strings.TrimSpace(arr[0]) == "-allureReportDir" {
commConsts.AllureReportDir = arr[1] commConsts.AllureReportDir = arr[1]
fileUtils.RmDir(commConsts.AllureReportDir) pth := filepath.Join(req.WorkspacePath, commConsts.AllureReportDir)
fileUtils.RmDir(pth)
req.Cmd = strings.Join(arr[2:], " ") req.Cmd = strings.Join(arr[2:], " ")
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册