diff --git a/.gitignore b/.gitignore index 3e4d453adda5130113d6c9aeab661200e7e78295..578e12ead63c918138754341eeff27c760da53f9 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,4 @@ logs/ #vim .vim/ .*.swp +/.scannerwork/ diff --git a/cmd/command/main.go b/cmd/command/main.go index fbb665f36a0cc240673305baabe7386b7bd05a5e..ad0a913935a83ebfb776bbd3596c9f68f89e7157 100644 --- a/cmd/command/main.go +++ b/cmd/command/main.go @@ -67,6 +67,8 @@ func main() { flagSet.StringVar(&keywords, "k", "", "") flagSet.StringVar(&keywords, "keywords", "", "") + flagSet.BoolVar(&commConsts.AutoCommitResult, "cr", false, "") + flagSet.BoolVar(&commConsts.AutoCommitBug, "cb", false, "") flagSet.BoolVar(&noNeedConfirm, "y", false, "") flagSet.BoolVar(&commConsts.Verbose, "verbose", false, "") @@ -113,7 +115,7 @@ func main() { case "cb": files := fileUtils.GetFilesFromParams(os.Args[2:]) if err := flagSet.Parse(os.Args[len(files)+2:]); err == nil { - action.CommitBug(files, stringUtils.ParseInt(productId)) + action.CommitBug(files, stringUtils.ParseInt(productId), noNeedConfirm) } case "list", "ls", "-l": @@ -161,6 +163,15 @@ func run(args []string) { runUnitTest(args) } else { // ztf test runFuncTest(args) + + if commConsts.AutoCommitResult && productId != "" { + action.CommitZTFTestResult([]string{commConsts.ExecLogDir}, + stringUtils.ParseInt(productId), stringUtils.ParseInt(productId), true) + } + + if commConsts.AutoCommitBug && productId != "" { + action.CommitBug([]string{commConsts.ExecLogDir}, stringUtils.ParseInt(productId), true) + } } } diff --git a/demo/sample/2_with_group.php b/demo/sample/2_with_group.php index 2d8954c45278576a2ca0658acf3662e8581ccafe..bdcb51b86b9bbf7fb528707da956f2a74c8a5619 100755 --- a/demo/sample/2_with_group.php +++ b/demo/sample/2_with_group.php @@ -3,10 +3,10 @@ /** title=with multi groups -cid=0 +cid=2 pid=0 -step 1 >> expect 1 +step 1 >> expect 11 step 2 >> expect 2 step 3 >> diff --git a/internal/command/action/bug.go b/internal/command/action/bug.go index f9f889813d1f3c67e463b65a7dfd4a09aea31a95..9940fde534d7a3a616d8a3d5b50dcdb170028925 100644 --- a/internal/command/action/bug.go +++ b/internal/command/action/bug.go @@ -22,7 +22,7 @@ var ( bugFields commDomain.ZentaoBugFields ) -func CommitBug(files []string, productId int) { +func CommitBug(files []string, productId int, noNeedConfirm bool) { var resultDir string if len(files) > 0 { resultDir = files[0] @@ -56,9 +56,18 @@ func CommitBug(files []string, productId int) { return } + if noNeedConfirm { + for _, caseId := range ids { + reportBug(resultDir, caseId, productId) + } + + return + } + + // wait to input for { logUtils.ExecConsole(color.FgCyan, "\n"+i118Utils.Sprintf("enter_case_id_for_report_bug")) - logUtils.ExecConsole(color.FgCyan, strings.Join(lines, "\n")) + logUtils.ExecConsole(-1, strings.Join(lines, "\n")) var caseId string fmt.Scanln(&caseId) if caseId == "exit" { diff --git a/internal/command/config/config.go b/internal/command/config/config.go index 9d248d873c0deb60ea54817d6ad0c663de8336e8..95655f8211ee09b0bf4fe505ec63484ac08bb623 100644 --- a/internal/command/config/config.go +++ b/internal/command/config/config.go @@ -16,7 +16,6 @@ import ( resUtils "github.com/easysoft/zentaoatf/pkg/lib/res" "github.com/fatih/color" "github.com/spf13/viper" - "log" "os" "path/filepath" "reflect" @@ -26,10 +25,7 @@ func InitConfig() { commConsts.IsRelease = commonUtils.IsRelease() commConsts.WorkDir = fileUtils.GetWorkDir() - log.Println("===" + commConsts.WorkDir) commConsts.ZtfDir = fileUtils.GetZTFDir() - log.Println("===" + commConsts.ZtfDir) - log.Println(commonUtils.IsRelease()) commConsts.ConfigPath = filepath.Join(commConsts.WorkDir, commConsts.ConfigDir, commConsts.ConfigFile) if commConsts.IsRelease { diff --git a/internal/pkg/consts/var.go b/internal/pkg/consts/var.go index d30be28f8fb94749a535a2492c66eaad75c26ca2..dfad27d701c1bd7682c94bb899ceb86c11e0dafb 100644 --- a/internal/pkg/consts/var.go +++ b/internal/pkg/consts/var.go @@ -9,12 +9,14 @@ var ( LanguageEn = "en" Language = LanguageZh - Verbose = false - IsRelease bool - ZtfDir string - WorkDir string - ExecLogDir string - LogDir string + AutoCommitResult bool + AutoCommitBug bool + Verbose = false + IsRelease bool + ZtfDir string + WorkDir string + ExecLogDir string + LogDir string RequestType string ExecFrom ExecFromDef diff --git a/res/doc/sample.txt b/res/doc/sample.txt index 109010191382985138ec4423396b260094b44581..d76d373cc89b80822d71a5350950698ac54cdc01 100644 --- a/res/doc/sample.txt +++ b/res/doc/sample.txt @@ -11,6 +11,8 @@ $>ztf.exe run product01 product01\all.cs 执行all.cs测试套件的 $>ztf.exe run log\001\result.txt 执行result.txt结果文件中的失败用例。 $>ztf.exe run product01 -suite 1 执行禅道系统中编号为1的套件,脚本在product01目录,缩写-s。 $>ztf.exe run -task 1 执行禅道系统中编号为1的任务,脚本在当期目录, 缩写-t。 +$>ztf.exe run demo\demo -p 1 -cr -cb 执行目录demo下的脚本,完成后提交结果到禅道,并将失败结果提交成用例。 + cr提交结果,-cb提交缺陷,-p必填参数指定产品ID $>ztf.exe run demo\autoit 执行ZTF自带AutoIT脚本。 $>ztf.exe run demo\selenium\chrome.php --interp runtime\php\php7\php.exe diff --git a/xdoc/test1.py b/xdoc/test1.py new file mode 100755 index 0000000000000000000000000000000000000000..29e7d1814ef93db6ae4d7790839db78dddb0b074 --- /dev/null +++ b/xdoc/test1.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +''' + +title=check string matches pattern +cid=1 +pid=1 + +1 登录RDsim +2 点击建模按钮 >> 设置 + +''' + +from test2 import start_app +c = start_app() + +print(c) diff --git a/xdoc/test2.py b/xdoc/test2.py new file mode 100755 index 0000000000000000000000000000000000000000..21d7c0a002eacd6e6f71458c2e50a6b5e87235cc --- /dev/null +++ b/xdoc/test2.py @@ -0,0 +1,6 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import os +def start_app(): + return "设置" diff --git a/xdoc/test3.py b/xdoc/test3.py index abdd508cba9513a0d95e43a5d58a2349097410bb..dd8629547667986b1201e53fe6f022ea676ca978 100755 --- a/xdoc/test3.py +++ b/xdoc/test3.py @@ -1,7 +1,5 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# @Author: Beibei -# @Time: 2022/6/23 17:14 ''' title=建模按钮功能 @@ -13,4 +11,9 @@ pid=1 ''' +import sys,io,platform +if(platform.system()=='Windows'): + import sys,io + sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf8') + print("设置") \ No newline at end of file