Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zentaoatf
提交
9022e360
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,发现更多精彩内容 >>
提交
9022e360
编写于
2月 24, 2022
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix issue
上级
a52d1848
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
74 addition
and
81 deletion
+74
-81
internal/comm/helper/script/extract.go
internal/comm/helper/script/extract.go
+3
-17
internal/comm/helper/script/generator.go
internal/comm/helper/script/generator.go
+15
-19
internal/comm/helper/script/parser.go
internal/comm/helper/script/parser.go
+37
-9
internal/pkg/consts/consts.go
internal/pkg/consts/consts.go
+0
-24
internal/pkg/lib/lang/consts.go
internal/pkg/lib/lang/consts.go
+8
-8
ui/src/layouts/IndexLayout/components/RightTopProject.vue
ui/src/layouts/IndexLayout/components/RightTopProject.vue
+1
-1
ui/src/locales/en-US.ts
ui/src/locales/en-US.ts
+2
-0
ui/src/locales/zh-CN.ts
ui/src/locales/zh-CN.ts
+2
-0
ui/src/views/script/index/main.vue
ui/src/views/script/index/main.vue
+5
-2
xdoc/notes.txt
xdoc/notes.txt
+1
-1
未找到文件。
internal/comm/helper/script/extract.go
浏览文件 @
9022e360
...
...
@@ -31,7 +31,7 @@ func Extract(scriptPaths []string) error {
steps
:=
prepareSteps
(
stepObjs
)
desc
:=
prepareDesc
(
steps
,
pth
)
r
eplaceCaseDesc
(
desc
,
pth
)
R
eplaceCaseDesc
(
desc
,
pth
)
}
return
nil
...
...
@@ -177,19 +177,6 @@ func prepareDesc(steps []string, file string) (desc string) {
return
}
func
replaceCaseDesc
(
desc
,
file
string
)
{
content
:=
fileUtils
.
ReadFile
(
file
)
lang
:=
langUtils
.
GetLangByFile
(
file
)
regStr
:=
fmt
.
Sprintf
(
`(?smU)%s((?U:.*pid.*))\n(.*)%s`
,
langUtils
.
LangCommentsRegxMap
[
lang
][
0
],
langUtils
.
LangCommentsRegxMap
[
lang
][
1
])
re
,
_
:=
regexp
.
Compile
(
regStr
)
out
:=
re
.
ReplaceAllString
(
content
,
"
\n
/**
\n\n
"
+
desc
+
"
\n\n
*/"
)
fileUtils
.
WriteFile
(
file
,
out
)
}
func
getName
(
line
,
str
,
lang
string
)
(
name
,
expect
string
)
{
lowerLine
:=
strings
.
ToLower
(
line
)
...
...
@@ -204,9 +191,8 @@ func getName(line, str, lang string) (name, expect string) {
}
}
regx
,
_
:=
regexp
.
Compile
(
langUtils
.
LangCommentsTagMap
[
lang
][
1
])
name
=
strings
.
TrimSpace
(
regx
.
ReplaceAllString
(
name
,
""
))
expect
=
strings
.
TrimSpace
(
regx
.
ReplaceAllString
(
expect
,
""
))
name
=
strings
.
TrimSpace
(
strings
.
Replace
(
name
,
langUtils
.
LangCommentsTagMap
[
lang
][
1
],
""
,
-
1
))
expect
=
strings
.
TrimSpace
(
strings
.
Replace
(
expect
,
langUtils
.
LangCommentsTagMap
[
lang
][
1
],
""
,
-
1
))
return
}
...
...
internal/comm/helper/script/generator.go
浏览文件 @
9022e360
...
...
@@ -10,7 +10,6 @@ import (
langUtils
"github.com/aaronchen2k/deeptest/internal/pkg/lib/lang"
resUtils
"github.com/aaronchen2k/deeptest/internal/pkg/lib/res"
"path/filepath"
"regexp"
"strconv"
"strings"
)
...
...
@@ -65,19 +64,8 @@ func GenerateScript(cs commDomain.ZtfCase, langType string, independentFile bool
}
if
fileUtils
.
FileExist
(
scriptFile
)
{
// update title and steps
regStr
:=
fmt
.
Sprintf
(
`(?sm)%s((?U:.*pid.*))\n(.*)%s`
,
langUtils
.
LangCommentsRegxMap
[
langType
][
0
],
langUtils
.
LangCommentsRegxMap
[
langType
][
1
])
// replace info
re
,
_
:=
regexp
.
Compile
(
regStr
)
newContent
:=
fmt
.
Sprintf
(
"
\n
%s
\n\n
%s
\n\n
%s
\n
"
,
langUtils
.
LangCommentsTagMap
[
langType
][
0
],
strings
.
Join
(
info
,
"
\n
"
),
langUtils
.
LangCommentsTagMap
[
langType
][
1
])
out
:=
re
.
ReplaceAllString
(
content
,
newContent
)
fileUtils
.
WriteFile
(
scriptFile
,
out
)
newContent
:=
strings
.
Join
(
info
,
"
\n
"
)
ReplaceCaseDesc
(
newContent
,
scriptFile
)
return
}
...
...
@@ -166,7 +154,7 @@ func generateTestStepAndScriptObsolete(testSteps []commDomain.ZtfStep, steps *[]
GetCaseContent
(
child
,
strconv
.
Itoa
(
stepNumb
),
independentFile
,
group
.
MultiLine
)
...
)
if
independentFile
&&
strings
.
TrimSpace
(
child
.
Expect
)
!=
""
{
*
independentExpects
=
append
(
*
independentExpects
,
getExcepts
(
child
.
Expect
))
*
independentExpects
=
append
(
*
independentExpects
,
getExcepts
(
child
.
Expect
,
false
))
}
stepNumb
++
...
...
@@ -179,7 +167,7 @@ func generateTestStepAndScriptObsolete(testSteps []commDomain.ZtfStep, steps *[]
*
steps
=
append
(
*
steps
,
GetCaseContent
(
child
,
numbStr
,
independentFile
,
group
.
MultiLine
)
...
)
if
independentFile
&&
strings
.
TrimSpace
(
child
.
Expect
)
!=
""
{
*
independentExpects
=
append
(
*
independentExpects
,
getExcepts
(
child
.
Expect
))
*
independentExpects
=
append
(
*
independentExpects
,
getExcepts
(
child
.
Expect
,
false
))
}
}
...
...
@@ -210,14 +198,22 @@ func generateTestStepAndScript(testSteps []commDomain.ZtfStep, steps *[]string,
*
steps
=
append
(
*
steps
,
""
)
for
_
,
item
:=
range
nestedSteps
{
numbStr
:=
fmt
.
Sprintf
(
"%d"
,
stepNumb
)
*
steps
=
append
(
*
steps
,
GetCaseContent
(
item
,
numbStr
,
independentFile
,
false
)
...
)
stepLines1
:=
GetCaseContent
(
item
,
numbStr
,
independentFile
,
false
)
*
steps
=
append
(
*
steps
,
stepLines1
...
)
if
independentFile
&&
strings
.
TrimSpace
(
item
.
Expect
)
!=
""
{
expects1
:=
getExcepts
(
item
.
Expect
,
independentFile
)
*
independentExpects
=
append
(
*
independentExpects
,
expects1
)
}
for
childNo
,
child
:=
range
item
.
Children
{
numbStr
:=
fmt
.
Sprintf
(
"%d.%d"
,
stepNumb
,
childNo
+
1
)
*
steps
=
append
(
*
steps
,
GetCaseContent
(
child
,
numbStr
,
independentFile
,
true
)
...
)
stepLines2
:=
GetCaseContent
(
child
,
numbStr
,
independentFile
,
true
)
*
steps
=
append
(
*
steps
,
stepLines2
...
)
if
independentFile
&&
strings
.
TrimSpace
(
child
.
Expect
)
!=
""
{
*
independentExpects
=
append
(
*
independentExpects
,
getExcepts
(
child
.
Expect
))
expects2
:=
getExcepts
(
child
.
Expect
,
independentFile
)
*
independentExpects
=
append
(
*
independentExpects
,
expects2
)
}
}
...
...
internal/comm/helper/script/parser.go
浏览文件 @
9022e360
...
...
@@ -19,16 +19,38 @@ import (
"strings"
)
func
getExcepts
(
str
string
)
string
{
str
=
stringUtils
.
TrimAll
(
str
)
func
ReplaceCaseDesc
(
desc
,
file
string
)
{
content
:=
fileUtils
.
ReadFile
(
file
)
lang
:=
langUtils
.
GetLangByFile
(
file
)
regStr
:=
fmt
.
Sprintf
(
`(?smU)%s((?U:.*pid.*))\n(.*)%s`
,
langUtils
.
LangCommentsRegxMap
[
lang
][
0
],
langUtils
.
LangCommentsRegxMap
[
lang
][
1
])
re
,
_
:=
regexp
.
Compile
(
regStr
)
newDesc
:=
fmt
.
Sprintf
(
"
\n
%s
\n\n
"
+
desc
+
"
\n\n
%s"
,
langUtils
.
LangCommentsTagMap
[
lang
][
0
],
langUtils
.
LangCommentsTagMap
[
lang
][
1
])
out
:=
re
.
ReplaceAllString
(
content
,
newDesc
)
fileUtils
.
WriteFile
(
file
,
out
)
}
func
getExcepts
(
str
string
,
independentFile
bool
)
(
ret
string
)
{
str
=
stringUtils
.
TrimAll
(
str
)
arr
:=
strings
.
Split
(
str
,
"
\n
"
)
if
len
(
arr
)
==
1
{
return
">> "
+
str
ret
=
str
if
len
(
arr
)
==
1
&&
!
independentFile
{
ret
=
">> "
+
str
}
else
if
len
(
arr
)
==
1
&&
independentFile
{
ret
=
str
}
else
{
ret
urn
">>
\n
"
+
str
ret
=
">>
\n
"
+
str
}
return
}
func
GetStepAndExpectMap
(
file
string
)
(
stepMap
,
stepTypeMap
,
expectMap
maps
.
Map
,
isOldFormat
bool
)
{
...
...
@@ -599,7 +621,13 @@ func GetCaseContent(stepObj commDomain.ZtfStep, seq string, independentFile bool
stepStr
:=
getStepContent
(
step
,
isChild
)
expectStr
:=
getExpectContent
(
expect
,
isChild
,
independentFile
)
lines
=
append
(
lines
,
stepStr
+
expectStr
)
line
:=
""
if
!
independentFile
{
line
=
stepStr
+
expectStr
}
else
{
line
=
stepStr
+
" >>"
}
lines
=
append
(
lines
,
line
)
return
lines
}
...
...
@@ -632,12 +660,12 @@ func getExpectContent(str string, isChild bool, independentFile bool) (ret strin
ret
=
" >> "
+
str
}
}
else
{
rpl
:=
"
\r\n
"
+
" "
rpl
:=
"
\r\n
"
if
independentFile
{
ret
=
">>
\n
"
+
strings
.
ReplaceAll
(
str
,
"
\r\n
"
,
rpl
)
+
"
\n
>>"
ret
=
">>
\n
"
+
strings
.
ReplaceAll
(
str
,
rpl
,
rpl
+
" "
)
+
"
\n
>>"
}
else
{
ret
=
" >> "
+
strings
.
ReplaceAll
(
str
,
"
\r\n
"
,
rpl
)
+
"
\n
>>"
ret
=
" >> "
+
strings
.
ReplaceAll
(
str
,
rpl
,
rpl
+
" "
)
+
"
\n
>>"
}
}
...
...
internal/pkg/consts/consts.go
浏览文件 @
9022e360
...
...
@@ -43,28 +43,4 @@ var (
RunModeCommon
=
"common"
RunModeServer
=
"server"
RunModeRequest
=
"request"
LangCommentsTagMap
=
map
[
string
][]
string
{
"bat"
:
{
"goto start"
,
":start"
},
"javascript"
:
{
"/
\\
*{1,}"
,
"
\\
*{1,}/"
},
"lua"
:
{
"--
\\
[
\\
["
,
"
\\
]
\\
]"
},
"perl"
:
{
"=pod"
,
"=cut"
},
"php"
:
{
"/
\\
*{1,}"
,
"
\\
*{1,}/"
},
"python"
:
{
"'''"
,
"'''"
},
"ruby"
:
{
"=begin"
,
"=end"
},
"shell"
:
{
":<<!"
,
"!"
},
"tcl"
:
{
"set case {"
,
"}"
},
}
LangCommentsRegxMap
=
map
[
string
][]
string
{
"bat"
:
{
"^
\\
s*goto start
\\
s*$"
,
"^
\\
s*:start
\\
s*$"
},
"javascript"
:
{
"^
\\
s*/
\\
*{1,}
\\
s*$"
,
"^
\\
s*
\\
*{1,}/
\\
s*$"
},
"lua"
:
{
"^
\\
s*--
\\
[
\\
[
\\
s*$"
,
"^
\\
s*
\\
]
\\
]
\\
s*$"
},
"perl"
:
{
"^
\\
s*=pod
\\
s*$"
,
"^
\\
s*=cut
\\
s*$"
},
"php"
:
{
"^
\\
s*/
\\
*{1,}
\\
s*$"
,
"^
\\
s*
\\
*{1,}/
\\
s*$"
},
"python"
:
{
"^
\\
s*'''
\\
s*$"
,
"^
\\
s*'''
\\
s*$"
},
"ruby"
:
{
"^
\\
s*=begin
\\
s*$"
,
"^
\\
s*=end
\\
s*$"
},
"shell"
:
{
"^
\\
s*:<<!
\\
s*$"
,
"^
\\
s*!
\\
s*$"
},
"tcl"
:
{
"^
\\
s*set case {"
,
"^
\\
s*}"
},
}
)
internal/pkg/lib/lang/consts.go
浏览文件 @
9022e360
...
...
@@ -2,15 +2,15 @@ package langUtils
var
(
LangCommentsTagMap
=
map
[
string
][]
string
{
"bat"
:
{
"goto start"
,
":start"
},
"javascript"
:
{
"/
\\
*"
,
"
\\
*/"
},
"lua"
:
{
"--
\\
[
\\
["
,
"
\\
]
\\
]"
},
"perl"
:
{
"=pod"
,
"=cut"
},
"php"
:
{
"/
\\
*"
,
"
\\
*/"
},
"bat"
:
{
`goto start`
,
`:start`
},
"javascript"
:
{
`/*`
,
`*/`
},
"lua"
:
{
`--[[`
,
`]]`
},
"perl"
:
{
`=pod`
,
`=cut`
},
"php"
:
{
`/**`
,
`*/`
},
"python"
:
{
"'''"
,
"'''"
},
"ruby"
:
{
"=begin"
,
"=end"
},
"shell"
:
{
":<<!"
,
"!"
},
"tcl"
:
{
"set case {"
,
"}"
},
"ruby"
:
{
`=begin`
,
`=end`
},
"shell"
:
{
`:<<!`
,
`!`
},
"tcl"
:
{
`set case {`
,
`}`
},
}
LangCommentsRegxMap
=
map
[
string
][]
string
{
...
...
ui/src/layouts/IndexLayout/components/RightTopProject.vue
浏览文件 @
9022e360
...
...
@@ -204,7 +204,7 @@ export default defineComponent({
}
.icon2 {
.svg-icon {
vertical-align:
0.15em
!important;
vertical-align:
3px
!important;
}
}
.anticon-down {
...
...
ui/src/locales/en-US.ts
浏览文件 @
9022e360
...
...
@@ -87,6 +87,8 @@ export default {
'
wrong_url
'
:
'
Please input right ZenTao URL.
'
,
'
create_project
'
:
'
Create Project
'
,
'
extract_success
'
:
'
Extract comments to test steps and checkpoints successfully.
'
,
'
extract_fail
'
:
'
Extract comments to test steps and checkpoints failed.
'
,
'
pls_create_project
'
:
'
Please create project to continue.
'
,
'
pls_product
'
:
'
Please select product.
'
,
'
pls_lang
'
:
'
Please select language.
'
,
...
...
ui/src/locales/zh-CN.ts
浏览文件 @
9022e360
...
...
@@ -88,6 +88,8 @@ export default {
'
collapse_all
'
:
'
收缩全部
'
,
'
wrong_url
'
:
'
请输入正确的的URL地址,以http或https开头。
'
,
'
create_project
'
:
'
新建项目
'
,
'
extract_success
'
:
'
提取注释为测试步骤和验证点成功。
'
,
'
extract_fail
'
:
'
提取注释为测试步骤和验证点失败。
'
,
'
pls_create_project
'
:
'
请点击右上角链接新建项目
'
,
'
pls_product
'
:
'
请选择产品
'
,
'
pls_lang
'
:
'
请选择语言
'
,
...
...
ui/src/views/script/index/main.vue
浏览文件 @
9022e360
...
...
@@ -159,13 +159,16 @@ export default defineComponent({
}
const
extract
=
()
=>
{
console
.
log
(
'
extract
'
,
selectedNode
.
props
)
scriptCode
.
value
=
''
storeScript
.
dispatch
(
'
script/extractScript
'
,
selectedNode
.
props
).
then
(()
=>
{
scriptCode
.
value
=
script
.
value
.
code
notification
.
success
({
message
:
`提取注释为测试步骤和验证点成功!`
,
message
:
t
(
'
extract_success
'
)
,
})
}).
catch
(()
=>
{
notification
.
error
({
message
:
`提取注释为测试步骤和验证点失败!`
,
message
:
t
(
'
extract_fail
'
)
,
});
})
}
...
...
xdoc/notes.txt
浏览文件 @
9022e360
...
...
@@ -15,7 +15,7 @@ protoc --go_out=. \
安装打包工具
npm install --save-dev electron-packager
打包
打包
客户端
cd ui && yarn build --dest ../client/ui && cd ..
go-bindata -o=res/res.go -pkg=res res/...
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录