fix: resolve conflicts

This commit is contained in:
徐聪
2024-07-19 15:11:16 +08:00
36 changed files with 2018 additions and 337 deletions
+26
View File
@@ -10,6 +10,7 @@ import (
"fmt"
"math"
"math/rand"
"net"
"os"
"path/filepath"
"reflect"
@@ -483,3 +484,28 @@ func ConvertToStringSlice(val interface{}) ([]string, error) {
}
return nil, fmt.Errorf("invalid type for conversion to []string")
}
func GetFreePort() (int, error) {
addr, err := net.ResolveTCPAddr("tcp", "localhost:0")
if err != nil {
return 0, errors.Wrap(err, "resolve tcp addr failed")
}
l, err := net.ListenTCP("tcp", addr)
if err != nil {
return 0, errors.Wrap(err, "listen tcp addr failed")
}
defer func() {
if err = l.Close(); err != nil {
log.Error().Err(err).Msg(fmt.Sprintf("close addr %s error", l.Addr().String()))
}
}()
return l.Addr().(*net.TCPAddr).Port, nil
}
func GetCurrentDay() string {
now := time.Now()
// 格式化日期为 yyyyMMdd
formattedDate := now.Format("20060102")
return formattedDate
}
+11 -6
View File
@@ -22,15 +22,18 @@ var (
const (
ResultsDirName = "results"
ScreenshotsDirName = "screenshots"
ActionLogDireName = "action_log"
)
var (
RootDir string
ResultsDir string
ResultsPath string
ScreenShotsPath string
StartTime = time.Now()
StartTimeStr = StartTime.Format("20060102150405")
RootDir string
ResultsDir string
ResultsPath string
ScreenShotsPath string
StartTime = time.Now()
StartTimeStr = StartTime.Format("20060102150405")
ActionLogFilePath string
DeviceActionLogFilePath string
)
func init() {
@@ -43,4 +46,6 @@ func init() {
ResultsDir = filepath.Join(ResultsDirName, StartTimeStr)
ResultsPath = filepath.Join(RootDir, ResultsDir)
ScreenShotsPath = filepath.Join(ResultsPath, ScreenshotsDirName)
ActionLogFilePath = filepath.Join(ResultsDir, ActionLogDireName)
DeviceActionLogFilePath = "/sdcard/Android/data/io.appium.uiautomator2.server/files/hodor"
}