提交 4d4be853 编写于 作者: m0_58228130's avatar m0_58228130

expect and fix issues

上级 41b8681c
......@@ -5,6 +5,7 @@ import (
"github.com/aaronchen2k/deeptest/internal/comm/consts"
"github.com/aaronchen2k/deeptest/internal/command"
"github.com/aaronchen2k/deeptest/internal/command/action"
commandConfig "github.com/aaronchen2k/deeptest/internal/command/config"
_consts "github.com/aaronchen2k/deeptest/internal/pkg/consts"
commonUtils "github.com/aaronchen2k/deeptest/internal/pkg/lib/common"
fileUtils "github.com/aaronchen2k/deeptest/internal/pkg/lib/file"
......@@ -102,6 +103,10 @@ func main() {
files := fileUtils.GetFilesFromParams(os.Args[2:])
action.Extract(files)
case "expect":
files := fileUtils.GetFilesFromParams(os.Args[2:])
action.GenExpectFiles(files)
case "checkout", "co":
if err := flagSet.Parse(os.Args[2:]); err == nil {
action.Generate(productId, moduleId, suiteId, taskId, independentFile, language, actionModule)
......@@ -223,7 +228,7 @@ func run(args []string, actionModule *command.IndexModule) {
func init() {
cleanup()
command.InitConfig()
commandConfig.Init()
}
func cleanup() {
......
......@@ -9,9 +9,9 @@ var (
LanguageEn = "en"
Language = LanguageZh
Verbose = true
IsRelease bool
//ExeDir string
Verbose = true
IsRelease bool
ExeDir string
WorkDir string
ExecLogDir string
LogDir string
......
......@@ -77,7 +77,7 @@ func RunZtf(ch chan int, sendOutputMsg, sendExecMsg func(info, isRunning string,
conf := configUtils.LoadByProjectPath(projectPath)
casesToRun, casesToIgnore := filterCases(cases, conf)
casesToRun, casesToIgnore := FilterCases(cases, conf)
numbMaxWidth := 0
numbMaxWidth, pathMaxWidth = getNumbMaxWidth(casesToRun)
......@@ -318,7 +318,7 @@ ExitCurrCase:
return
}
func filterCases(cases []string, conf commDomain.ProjectConf) (casesToRun, casesToIgnore []string) {
func FilterCases(cases []string, conf commDomain.ProjectConf) (casesToRun, casesToIgnore []string) {
for _, cs := range cases {
if commonUtils.IsWin() {
if path.Ext(cs) == ".sh" { // filter by os
......
package action
import (
commConsts "github.com/aaronchen2k/deeptest/internal/comm/consts"
configUtils "github.com/aaronchen2k/deeptest/internal/comm/helper/config"
_scriptUtils "github.com/aaronchen2k/deeptest/internal/comm/helper/exec"
scriptUtils "github.com/aaronchen2k/deeptest/internal/comm/helper/script"
fileUtils "github.com/aaronchen2k/deeptest/internal/pkg/lib/file"
i118Utils "github.com/aaronchen2k/deeptest/internal/pkg/lib/i118"
logUtils "github.com/aaronchen2k/deeptest/internal/pkg/lib/log"
"github.com/kataras/iris/v12/websocket"
"path/filepath"
)
func GenExpectFiles(files []string) error {
var cases []string
for _, v1 := range files {
group := scriptUtils.LoadScriptByProject(v1)
for _, v2 := range group {
cases = append(cases, v2)
}
}
if len(cases) < 1 {
logUtils.Info("\n" + i118Utils.Sprintf("no_cases"))
return nil
}
conf := configUtils.LoadByProjectPath(commConsts.WorkDir)
casesToRun, _ := _scriptUtils.FilterCases(cases, conf)
dryRunScripts(casesToRun)
return nil
}
func dryRunScripts(casesToRun []string) {
for _, file := range casesToRun {
dryRunScript(file)
}
}
func dryRunScript(file string) {
conf := configUtils.LoadByProjectPath(commConsts.WorkDir)
wsMsg := websocket.Message{}
out, _ := _scriptUtils.RunScript(file, commConsts.WorkDir, conf, nil, nil, nil, wsMsg)
expFile := filepath.Join(filepath.Dir(file), fileUtils.GetFileNameWithoutExt(file)+".exp")
fileUtils.WriteFile(expFile, out)
}
package commandConfig
import (
"bytes"
"fmt"
commConsts "github.com/aaronchen2k/deeptest/internal/comm/consts"
configUtils "github.com/aaronchen2k/deeptest/internal/comm/helper/config"
"github.com/aaronchen2k/deeptest/internal/pkg/consts"
commonUtils "github.com/aaronchen2k/deeptest/internal/pkg/lib/common"
"github.com/aaronchen2k/deeptest/internal/pkg/lib/display"
fileUtils "github.com/aaronchen2k/deeptest/internal/pkg/lib/file"
i118Utils "github.com/aaronchen2k/deeptest/internal/pkg/lib/i118"
langUtils "github.com/aaronchen2k/deeptest/internal/pkg/lib/lang"
logUtils "github.com/aaronchen2k/deeptest/internal/pkg/lib/log"
resUtils "github.com/aaronchen2k/deeptest/internal/pkg/lib/res"
stdinUtils "github.com/aaronchen2k/deeptest/internal/pkg/lib/stdin"
"github.com/aaronchen2k/deeptest/internal/server/modules/v1/repo"
serverConfig "github.com/aaronchen2k/deeptest/internal/server/config"
"github.com/fatih/color"
"github.com/spf13/viper"
"os"
"path/filepath"
"reflect"
)
type ConfigCtrl struct {
ProjectRepo *repo.ProjectRepo `inject:""`
func CheckConfigPermission() {
err := fileUtils.MkDirIfNeeded(commConsts.ExeDir + "conf")
if err != nil {
msg := i118Utils.Sprintf("perm_deny", commConsts.ExeDir)
logUtils.ExecConsolef(color.FgRed, msg)
os.Exit(0)
}
}
//func CheckConfigPermission() {
// //err := syscall.Access(vari.ExeDir, syscall.O_RDWR)
//
// err := fileUtils.MkDirIfNeeded(commConsts.ExeDir + "conf")
// if err != nil {
// msg := i118Utils.Sprintf("perm_deny", commConsts.ExeDir)
// logUtils.ExecConsolef(color.FgRed, msg)
// os.Exit(0)
// }
//}
func InitConfig() {
commConsts.IsRelease = commonUtils.IsRelease()
commConsts.WorkDir = fileUtils.GetWorkDir()
commConsts.ConfigPath = commConsts.WorkDir + commConsts.ConfigFile
serverConfig.InitExecLog(commConsts.WorkDir)
if commConsts.Verbose {
fmt.Printf("\nlaunch %s%s in %s\n", "", commConsts.App, commConsts.WorkDir)
}
v := viper.New()
serverConfig.VIPER = v
serverConfig.VIPER.SetConfigType("yaml")
configRes := filepath.Join("res", commConsts.AppServer+".yaml")
yamlDefault, _ := resUtils.ReadRes(configRes)
if err := serverConfig.VIPER.ReadConfig(bytes.NewBuffer(yamlDefault)); err != nil {
panic(fmt.Errorf("读取默认配置文件错误: %w ", err))
}
if err := serverConfig.VIPER.Unmarshal(&serverConfig.CONFIG); err != nil {
panic(fmt.Errorf("同步配置文件错误: %w ", err))
}
return
}
func Init() {
InitConfig()
serverConfig.InitLog()
//commandConfig.CheckConfigPermission()
// screen size
InitScreenSize()
// internationalization
i118Utils.Init(commConsts.Language, commConsts.AppServer)
langUtils.GetExtToNameMap()
commConsts.ComeFrom = "cmd"
return
}
func InitScreenSize() {
w, h := display.GetScreenSize()
consts.ScreenWidth = w
......
package command
import (
commConsts "github.com/aaronchen2k/deeptest/internal/comm/consts"
commandConfig "github.com/aaronchen2k/deeptest/internal/command/config"
i118Utils "github.com/aaronchen2k/deeptest/internal/pkg/lib/i118"
langUtils "github.com/aaronchen2k/deeptest/internal/pkg/lib/lang"
serverConfig "github.com/aaronchen2k/deeptest/internal/server/config"
"github.com/aaronchen2k/deeptest/internal/server/modules/v1/service"
)
func InitConfig() {
serverConfig.Init()
serverConfig.InitLog()
//commandConfig.CheckConfigPermission()
// screen size
commandConfig.InitScreenSize()
// internationalization
i118Utils.Init(commConsts.Language, commConsts.AppServer)
langUtils.GetExtToNameMap()
commConsts.ComeFrom = "cmd"
return
}
type IndexModule struct {
ProjectService *service.ProjectService `inject:""`
SyncService *service.SyncService `inject:""`
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册