提交 01e42c3d 编写于 作者: Z zhaoke

Merge branch 'main' of git.zcorp.cc:pangu/zentaoatf

PROJECT=ztf
VERSION=`head -n 1 VERSION`
VERSION:=$(shell head -n 1 VERSION)
ifeq ($(OS),Windows_NT)
PLATFORM="Windows"
......
......@@ -2,6 +2,7 @@ package action
import (
"fmt"
"github.com/easysoft/zentaoatf/pkg/consts"
"strconv"
"strings"
"time"
......@@ -45,7 +46,7 @@ func List(files []string, keywords string) {
total := len(scriptArr)
width := strconv.Itoa(len(strconv.Itoa(total)))
logUtils.Info("\n" + time.Now().Format("2006-01-02 15:04:05") + " " +
logUtils.Info("\n" + time.Now().Format(consts.DateTimeFormat) + " " +
i118Utils.Sprintf("found_scripts_no_ztf_dir", total, commConsts.WorkDir))
for idx, cs := range scriptArr {
......
......@@ -5,6 +5,7 @@ import (
commConsts "github.com/easysoft/zentaoatf/internal/pkg/consts"
langHelper "github.com/easysoft/zentaoatf/internal/pkg/helper/lang"
scriptHelper "github.com/easysoft/zentaoatf/internal/pkg/helper/script"
"github.com/easysoft/zentaoatf/pkg/consts"
commonUtils "github.com/easysoft/zentaoatf/pkg/lib/common"
fileUtils "github.com/easysoft/zentaoatf/pkg/lib/file"
i118Utils "github.com/easysoft/zentaoatf/pkg/lib/i118"
......@@ -44,7 +45,7 @@ func view(cases []string, keywords string) {
total := len(arrs)
logUtils.Info("\n" + time.Now().Format("2006-01-02 15:04:05") + " " +
logUtils.Info("\n" + time.Now().Format(consts.DateTimeFormat) + " " +
i118Utils.Sprintf("found_scripts_no_ztf_dir", total, commConsts.WorkDir))
width := len(strconv.Itoa(len(arrs)))
......
......@@ -29,9 +29,9 @@ var (
ErrDirNotEmpty = ResponseCode{1100, "Dir Not Empty Error"}
ErrZentaoConfig = ResponseCode{2000, "Zentao Config Error"}
ErrZentaoRequest = ResponseCode{3000, "zentao request Error"}
ErrRecordWithSameNameExist = ResponseCode{3010, "Record Exist"}
ErrRecordWithSamePathExist = ResponseCode{3011, "Record Exist"}
ErrRecordWithSameInterpreterExist = ResponseCode{2000, "Record Exist"}
ErrRecordWithSameNameExist = ResponseCode{3010, "Record With Same Name Exist"}
ErrRecordWithSamePathExist = ResponseCode{3011, "Record With Same Path Exist"}
ErrRecordWithSameInterpreterExist = ResponseCode{2000, "Record With Same Interpreter Exist"}
ErrRecordNotExist = ResponseCode{4000, "Record Not Found"}
ErrRecordNotAllowDelete = ResponseCode{2000, "Record Can Not Delete"}
ErrPostParam = ResponseCode{2000, "Parameter Error"}
......
......@@ -431,14 +431,8 @@ func ParserUnitTestResult(testSuites []commDomain.UnitTestSuite) (
idx := 1
for _, suite := range testSuites {
//if suite.Time != 0 && suite.Time { // for junit, there is a time on suite level
// dur += suite.Time
//}
for _, cs := range suite.Cases {
if cs.Id <= 0 {
cs.Id = idx
}
getCaseIdFromName(&cs, idx)
if cs.Failure != nil {
cs.Status = "fail"
......@@ -913,3 +907,24 @@ func getZapReport() (ret string) {
return
}
func getCaseIdFromName(cs *commDomain.UnitResult, defaultVal int) {
if cs.Cid > 0 {
return
}
cs.Title = strings.TrimSpace(cs.Title)
regx := regexp.MustCompile(`^(\d+)\. (.+)`)
arr := regx.FindAllStringSubmatch(cs.Title, -1)
if len(arr) > 0 {
cs.Cid = stringUtils.ParseInt(arr[0][1])
cs.Title = arr[0][2]
}
if cs.Cid <= 0 {
cs.Cid = defaultVal
}
return
}
......@@ -29,6 +29,7 @@ func GenZTFTestReport(report commDomain.ZtfReport, pathMaxWidth int,
}
default:
}
// print failed case
failedCount := 0
failedCaseLinesWithCheckpoint := make([]string, 0)
......
......@@ -433,7 +433,7 @@ func GetCaseInfo(file string) (pass bool, caseId, productId int, title string, t
return
}
// TODO: deal with old format, will removed
// deal with old format, will be removed
isOldFormat := strings.Index(content, "[esac]") > -1
pass = CheckFileContentIsScript(content)
if !pass {
......
......@@ -4,6 +4,7 @@ import (
"errors"
"fmt"
configHelper "github.com/easysoft/zentaoatf/internal/pkg/helper/config"
"github.com/easysoft/zentaoatf/pkg/consts"
i118Utils "github.com/easysoft/zentaoatf/pkg/lib/i118"
"path/filepath"
"strconv"
......@@ -203,8 +204,8 @@ func (s *JobService) SubmitJobStatus(job model.Job) (err error) {
status := serverDomain.ZentaoJobSubmitReq{
Task: job.Task,
Status: job.Status,
StartTime: (*job.StartDate).Format("2006-01-02 15:04:05"),
EndTime: (*job.EndDate).Format("2006-01-02 15:04:05"),
StartTime: (*job.StartDate).Format(consts.DateTimeFormat),
EndTime: (*job.EndDate).Format(consts.DateTimeFormat),
RetryTime: job.Retry,
Error: "",
Data: "",
......@@ -246,8 +247,8 @@ func (s *JobService) SubmitExecResult(job model.Job, execErr error) (err error)
ret := serverDomain.ZentaoJobSubmitReq{
Task: job.Task,
Status: job.Status,
StartTime: (*job.StartDate).Format("2006-01-02 15:04:05"),
EndTime: (*job.EndDate).Format("2006-01-02 15:04:05"),
StartTime: (*job.StartDate).Format(consts.DateTimeFormat),
EndTime: (*job.EndDate).Format(consts.DateTimeFormat),
RetryTime: job.Retry,
Error: fmt.Sprintf("%v", execErr),
Data: report,
......
......@@ -34,4 +34,6 @@ var (
Authorization = "Authorization"
Bearer = "Bearer"
DateTimeFormat = "2006-01-02 15:04:05"
)
package dateUtils
import (
"github.com/easysoft/zentaoatf/pkg/consts"
"time"
)
const (
dateTimeFormat = "2006-01-02 15:04:05"
)
func DateStr(tm time.Time) string {
return tm.Format("2006-01-02")
}
......@@ -24,7 +21,7 @@ func DateTimeStrFmt(tm time.Time, fm string) string {
}
func DateTimeStr(tm time.Time) string {
return tm.Format("2006-01-02 15:04:05")
return tm.Format(consts.DateTimeFormat)
}
func DateTimeStrLong(tm time.Time) string {
......@@ -48,9 +45,9 @@ func DateStrToTimestamp(str string) (int64, error) {
}
func UnitToDate(unit int64) (date time.Time, err error) {
timeStr := time.Unix(unit, 0).Format(dateTimeFormat)
timeStr := time.Unix(unit, 0).Format(consts.DateTimeFormat)
date, _ = time.ParseInLocation(dateTimeFormat, timeStr, time.Local)
date, _ = time.ParseInLocation(consts.DateTimeFormat, timeStr, time.Local)
return
}
......@@ -85,6 +85,8 @@ func HashPassword(pwd string) string {
}
func ParseInt(str string) (ret int) {
str = strings.TrimSpace(str)
ret, _ = strconv.Atoi(str)
return
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册