Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zentaoatf
提交
a18d1c2a
Z
zentaoatf
项目概览
易企天创
/
zentaoatf
12 个月 前同步成功
通知
11
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
3
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
zentaoatf
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
3
Issue
3
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a18d1c2a
编写于
2月 15, 2022
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/main'
上级
c42903e5
b82cc95a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
216 addition
and
3 deletion
+216
-3
cmd/command/main.go
cmd/command/main.go
+16
-0
internal/command/action/list.go
internal/command/action/list.go
+87
-0
internal/command/action/view.go
internal/command/action/view.go
+110
-0
internal/command/action/ztfTest.go
internal/command/action/ztfTest.go
+3
-3
未找到文件。
cmd/command/main.go
浏览文件 @
a18d1c2a
...
...
@@ -125,6 +125,22 @@ func main() {
action
.
CommitBug
(
files
,
actionModule
)
}
case
"list"
,
"ls"
,
"-l"
:
files
:=
fileUtils
.
GetFilesFromParams
(
os
.
Args
[
2
:
])
if
err
:=
flagSet
.
Parse
(
os
.
Args
[
len
(
files
)
+
2
:
]);
err
==
nil
{
if
len
(
files
)
==
0
{
files
=
append
(
files
,
"."
)
}
action
.
List
(
files
,
keywords
)
}
case
"view"
,
"-v"
:
files
:=
fileUtils
.
GetFilesFromParams
(
os
.
Args
[
2
:
])
if
err
:=
flagSet
.
Parse
(
os
.
Args
[
len
(
files
)
+
2
:
]);
err
==
nil
{
action
.
View
(
files
,
keywords
)
}
case
"help"
,
"-h"
,
"-help"
,
"--help"
:
resUtils
.
PrintUsage
()
...
...
internal/command/action/list.go
0 → 100644
浏览文件 @
a18d1c2a
package
action
import
(
"fmt"
commDomain
"github.com/aaronchen2k/deeptest/internal/comm/domain"
scriptUtils
"github.com/aaronchen2k/deeptest/internal/comm/helper/script"
i118Utils
"github.com/aaronchen2k/deeptest/internal/pkg/lib/i118"
logUtils
"github.com/aaronchen2k/deeptest/internal/pkg/lib/log"
"github.com/fatih/color"
"github.com/mattn/go-runewidth"
"strconv"
"strings"
"time"
)
func
List
(
files
[]
string
,
keywords
string
)
{
var
cases
[]
string
for
_
,
v1
:=
range
files
{
group
:=
scriptUtils
.
LoadScriptByProject
(
v1
)
for
_
,
v2
:=
range
group
{
cases
=
append
(
cases
,
v2
)
}
}
keywords
=
strings
.
TrimSpace
(
keywords
)
scriptArr
:=
make
([]
commDomain
.
FuncResult
,
0
)
pathMaxWidth
:=
0
numbMaxWidth
:=
0
for
_
,
tc
:=
range
cases
{
pass
,
cs
:=
SummaryObj
(
tc
,
keywords
)
if
pass
{
scriptArr
=
append
(
scriptArr
,
cs
)
}
if
len
(
cs
.
Path
)
>
pathMaxWidth
{
pathMaxWidth
=
len
(
cs
.
Path
)
}
if
len
(
tc
)
>
numbMaxWidth
{
numbMaxWidth
=
len
(
strconv
.
Itoa
(
cs
.
Id
))
}
}
numbWidth
:=
strconv
.
Itoa
(
numbMaxWidth
)
total
:=
len
(
scriptArr
)
width
:=
strconv
.
Itoa
(
len
(
strconv
.
Itoa
(
total
)))
logUtils
.
Info
(
time
.
Now
()
.
Format
(
"2006-01-02 15:04:05"
)
+
" "
+
i118Utils
.
Sprintf
(
"found_scripts"
,
color
.
CyanString
(
strconv
.
Itoa
(
total
)))
+
"
\n
"
)
for
idx
,
cs
:=
range
scriptArr
{
//format := "(%" + width + "d/%d) [%s] %d.%s"
//logUtils.Screen(fmt.Sprintf(format, idx+1, total, cs.Path, cs.Id, cs.Title))
path
:=
cs
.
Path
lent
:=
runewidth
.
StringWidth
(
path
)
if
pathMaxWidth
>
lent
{
postFix
:=
strings
.
Repeat
(
" "
,
pathMaxWidth
-
lent
)
path
+=
postFix
}
format
:=
"(%"
+
width
+
"d/%d) [%s] [%"
+
numbWidth
+
"d. %s]"
logUtils
.
Info
(
fmt
.
Sprintf
(
format
,
idx
+
1
,
total
,
path
,
cs
.
Id
,
cs
.
Title
))
}
}
func
SummaryObj
(
file
string
,
keywords
string
)
(
bool
,
commDomain
.
FuncResult
)
{
pass
,
caseId
,
_
,
title
:=
scriptUtils
.
GetCaseInfo
(
file
)
if
pass
{
_
,
err
:=
strconv
.
Atoi
(
keywords
)
var
pass
bool
if
err
==
nil
&&
keywords
==
strconv
.
Itoa
(
caseId
)
{
// int
pass
=
true
}
else
if
strings
.
Index
(
title
,
keywords
)
>
-
1
{
pass
=
true
}
if
pass
{
return
true
,
commDomain
.
FuncResult
{
Id
:
caseId
,
Title
:
title
,
Path
:
file
}
}
else
{
return
false
,
commDomain
.
FuncResult
{}
}
}
return
false
,
commDomain
.
FuncResult
{}
}
internal/command/action/view.go
0 → 100644
浏览文件 @
a18d1c2a
package
action
import
(
"fmt"
scriptUtils
"github.com/aaronchen2k/deeptest/internal/comm/helper/script"
commonUtils
"github.com/aaronchen2k/deeptest/internal/pkg/lib/common"
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"
"github.com/fatih/color"
"regexp"
"strconv"
"strings"
"time"
)
func
View
(
files
[]
string
,
keywords
string
)
{
var
cases
[]
string
for
_
,
v1
:=
range
files
{
group
:=
scriptUtils
.
LoadScriptByProject
(
v1
)
for
_
,
v2
:=
range
group
{
cases
=
append
(
cases
,
v2
)
}
}
view
(
cases
,
keywords
)
}
func
view
(
cases
[]
string
,
keywords
string
)
{
keywords
=
strings
.
TrimSpace
(
keywords
)
count
:=
0
arrs
:=
make
([][]
string
,
0
)
for
_
,
file
:=
range
cases
{
pass
,
arr
:=
brief
(
file
,
keywords
)
if
pass
{
arrs
=
append
(
arrs
,
arr
)
count
++
}
}
total
:=
len
(
arrs
)
logUtils
.
Info
(
time
.
Now
()
.
Format
(
"2006-01-02 15:04:05"
)
+
" "
+
i118Utils
.
Sprintf
(
"found_scripts"
,
color
.
CyanString
(
strconv
.
Itoa
(
total
))))
width
:=
len
(
strconv
.
Itoa
(
len
(
arrs
)))
for
idx
,
arr
:=
range
arrs
{
numb
:=
fmt
.
Sprintf
(
"#%0"
+
strconv
.
Itoa
(
width
)
+
"d"
,
idx
+
1
)
logUtils
.
Infof
(
logUtils
.
GetWholeLine
(
numb
+
" "
+
arr
[
3
],
"="
))
logUtils
.
ExecConsole
(
color
.
FgCyan
,
fmt
.
Sprintf
(
"%s. %s"
,
arr
[
0
],
arr
[
1
]))
fmt
.
Printf
(
"Steps:
\n
%s
\n
"
,
arr
[
2
])
logUtils
.
Info
(
""
)
}
}
func
brief
(
file
string
,
keywords
string
)
(
bool
,
[]
string
)
{
content
:=
fileUtils
.
ReadFile
(
file
)
lang
:=
langUtils
.
GetLangByFile
(
file
)
isOldFormat
:=
strings
.
Index
(
content
,
"[esac]"
)
>
-
1
regStr
:=
""
if
isOldFormat
{
regStr
=
`\[case\][\S\s]*`
+
`title=([^\n]*)\n+`
+
`cid=([^\n]*)\n+`
+
`pid=([^\n]*)\n+`
+
`([\S\s]*)\n*`
+
`\[esac\]`
}
else
{
regStr
=
fmt
.
Sprintf
(
`(?sm)%s[\S\s]*`
+
`title=([^\n]*)\n+`
+
`cid=([^\n]*)\n+`
+
`pid=([^\n]*)\n+`
+
`([\S\s]*)\n*%s`
,
langUtils
.
LangCommentsRegxMap
[
lang
][
0
],
langUtils
.
LangCommentsRegxMap
[
lang
][
1
])
}
myExp
:=
regexp
.
MustCompile
(
regStr
)
arr
:=
myExp
.
FindStringSubmatch
(
content
)
if
len
(
arr
)
>
2
{
title
:=
commonUtils
.
RemoveBlankLine
(
arr
[
1
])
caseId
:=
commonUtils
.
RemoveBlankLine
(
arr
[
2
])
//productId := commonUtils.RemoveBlankLine(arr[3])
steps
:=
commonUtils
.
RemoveBlankLine
(
arr
[
4
])
_
,
err
:=
strconv
.
Atoi
(
keywords
)
var
pass
bool
if
err
==
nil
&&
keywords
==
caseId
{
// int
pass
=
true
}
else
if
strings
.
Index
(
title
,
keywords
)
>
-
1
{
pass
=
true
}
if
pass
{
return
true
,
[]
string
{
caseId
,
title
,
steps
,
file
}
}
else
{
return
false
,
nil
}
}
return
false
,
nil
}
internal/command/action/ztfTest.go
浏览文件 @
a18d1c2a
...
...
@@ -31,7 +31,7 @@ func RunZTFTest(file []string, suiteIdStr, taskIdStr string, actionModule *comma
cases
=
append
(
cases
,
file
[
0
])
}
else
{
_
,
_
,
_
,
scriptTree
,
_
:=
actionModule
.
ProjectService
.
GetByUser
(
commConsts
.
WorkDir
)
cases
=
G
etCasesFromChildren
(
scriptTree
.
Children
)
cases
=
g
etCasesFromChildren
(
scriptTree
.
Children
)
}
req
.
Cases
=
cases
...
...
@@ -42,13 +42,13 @@ func RunZTFTest(file []string, suiteIdStr, taskIdStr string, actionModule *comma
}
// 扁平化
func
G
etCasesFromChildren
(
scripts
[]
*
serverDomain
.
TestAsset
)
(
cases
[]
string
)
{
func
g
etCasesFromChildren
(
scripts
[]
*
serverDomain
.
TestAsset
)
(
cases
[]
string
)
{
for
_
,
v
:=
range
scripts
{
if
v
.
Path
!=
""
{
cases
=
append
(
cases
,
v
.
Path
)
}
if
v
.
Children
!=
nil
{
G
etCasesFromChildren
(
v
.
Children
)
g
etCasesFromChildren
(
v
.
Children
)
}
}
return
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录