From 78ee032fe02d6d04023514106ebc6dbafc50a401 Mon Sep 17 00:00:00 2001 From: aaron <462826@qq.com> Date: Wed, 31 Aug 2022 13:30:29 +0800 Subject: [PATCH] go test and allure support --- internal/pkg/helper/exec/report-unit.go | 10 +++++++--- internal/pkg/helper/exec/unit.go | 4 +++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/internal/pkg/helper/exec/report-unit.go b/internal/pkg/helper/exec/report-unit.go index 88cec653..f5afd8ca 100644 --- a/internal/pkg/helper/exec/report-unit.go +++ b/internal/pkg/helper/exec/report-unit.go @@ -198,7 +198,7 @@ func RetrieveUnitResult(workspacePath string, startTime int64, testTool commCons testTool == commConsts.Playwright || testTool == commConsts.Puppeteer { resultDir = "results" zipDir = resultDir - } else if testTool == commConsts.Allure || testTool == commConsts.GoTest { + } else if isAllureReport(testTool) { resultDir = commConsts.AllureReportDir zipDir = resultDir } else { @@ -212,7 +212,7 @@ func RetrieveUnitResult(workspacePath string, startTime int64, testTool commCons resultFiles, _ = GetSuiteFiles(resultDir, startTime, testTool) } - if testTool == commConsts.Allure { + if isAllureReport(testTool) { if resultDir != "" { suites = GetAllureSuites(resultDir, startTime) } else { @@ -274,7 +274,7 @@ func GetSuiteFiles(resultDir string, startTime int64, testTool commConsts.TestTo continue } - if (testTool == commConsts.Allure && ext == ".json") || ext == ".xml" { + if (isAllureReport(testTool) && ext == ".json") || ext == ".xml" { pth := filepath.Join(resultDir, name) resultFiles = append(resultFiles, pth) } @@ -780,3 +780,7 @@ func ConvertCyResult(result commDomain.CypressTestsuites) commDomain.UnitTestSui return testSuite } + +func isAllureReport(testTool commConsts.TestTool) (ret bool) { + return testTool == commConsts.Allure || testTool == commConsts.GoTest +} diff --git a/internal/pkg/helper/exec/unit.go b/internal/pkg/helper/exec/unit.go index 525e7f0e..a185c075 100644 --- a/internal/pkg/helper/exec/unit.go +++ b/internal/pkg/helper/exec/unit.go @@ -6,6 +6,7 @@ import ( fileUtils "github.com/easysoft/zentaoatf/pkg/lib/file" "io" "os/exec" + "path/filepath" "strings" "time" @@ -43,7 +44,8 @@ func ExecUnit(ch chan int, arr := strings.Split(req.Cmd, " ") if len(arr) > 1 && strings.TrimSpace(arr[0]) == "-allureReportDir" { commConsts.AllureReportDir = arr[1] - fileUtils.RmDir(commConsts.AllureReportDir) + pth := filepath.Join(req.WorkspacePath, commConsts.AllureReportDir) + fileUtils.RmDir(pth) req.Cmd = strings.Join(arr[2:], " ") } -- GitLab