Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zentaoatf
提交
2859799d
Z
zentaoatf
项目概览
易企天创
/
zentaoatf
9 个月 前同步成功
通知
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,体验更适合开发者的 AI 搜索 >>
提交
2859799d
编写于
9月 04, 2019
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
sort scripts languages options
上级
e23428c0
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
26 addition
and
29 deletion
+26
-29
src/action/gen.go
src/action/gen.go
+1
-1
src/service/script/assert.go
src/service/script/assert.go
+3
-3
src/service/script/generator.go
src/service/script/generator.go
+3
-4
src/utils/lang/lang.go
src/utils/lang/lang.go
+17
-20
src/utils/stdin/stdin.go
src/utils/stdin/stdin.go
+2
-1
未找到文件。
src/action/gen.go
浏览文件 @
2859799d
...
...
@@ -23,7 +23,7 @@ func Generate(productId string, moduleId string, suiteId string, taskId string,
&
independentFile
,
&
scriptLang
)
}
ok
:=
langUtils
.
CheckSupportLangages
(
scriptLang
)
ok
:=
langUtils
.
CheckSupportLang
u
ages
(
scriptLang
)
if
!
ok
{
return
}
...
...
src/service/script/assert.go
浏览文件 @
2859799d
...
...
@@ -21,7 +21,7 @@ func GetAllScriptsInDir(filePthParam string, files *[]string) error {
sep
:=
string
(
os
.
PathSeparator
)
if
!
fileUtils
.
IsDir
(
filePthParam
)
{
// first call, param is file
regx
:=
langUtils
.
GetSupportLang
age
Regx
()
regx
:=
langUtils
.
GetSupportLang
uageExt
Regx
()
pass
,
_
:=
regexp
.
MatchString
(
"^*.
\\
."
+
regx
+
"$"
,
filePthParam
)
...
...
@@ -50,7 +50,7 @@ func GetAllScriptsInDir(filePthParam string, files *[]string) error {
GetAllScriptsInDir
(
filePthParam
+
name
+
sep
,
files
)
}
else
{
path
:=
filePthParam
+
name
regx
:=
langUtils
.
GetSupportLang
age
Regx
()
regx
:=
langUtils
.
GetSupportLang
uageExt
Regx
()
pass
,
_
:=
regexp
.
MatchString
(
"^*.
\\
."
+
regx
+
"$"
,
path
)
if
pass
{
...
...
@@ -84,7 +84,7 @@ func GetScriptByIdsInDir(dirPth string, idMap map[int]string, files *[]string) e
if
fi
.
IsDir
()
{
// 目录, 递归遍历
GetScriptByIdsInDir
(
dirPth
+
name
+
sep
,
idMap
,
files
)
}
else
{
regx
:=
langUtils
.
GetSupportLang
age
Regx
()
regx
:=
langUtils
.
GetSupportLang
uageExt
Regx
()
pass
,
_
:=
regexp
.
MatchString
(
"^*.
\\
."
+
regx
+
"$"
,
name
)
if
!
pass
{
...
...
src/service/script/generator.go
浏览文件 @
2859799d
...
...
@@ -99,7 +99,6 @@ func GenerateTestCaseScript(cs model.TestCase, langType string, independentFile
func
GenerateTestStepScript
(
ts
model
.
TestStep
,
langType
string
,
stepWidth
int
,
steps
*
[]
string
,
expects
*
[]
string
,
srcCode
*
[]
string
)
{
LangMap
:=
langUtils
.
GetSupportedScriptLang
()
isGroup
:=
ts
.
Type
==
"group"
isCheckPoint
:=
ts
.
Expect
!=
""
...
...
@@ -147,11 +146,11 @@ func GenerateTestStepScript(ts model.TestStep, langType string, stepWidth int,
// 处理srcCode
if
isCheckPoint
{
codeLine
:=
LangMap
[
langType
][
"printGrammar"
]
codeLine
:=
langUtils
.
LangMap
[
langType
][
"printGrammar"
]
codeLine
+=
fmt
.
Sprintf
(
" %s %s: %s
\n
"
,
LangMap
[
langType
][
"commentsTag"
],
stepIdent
,
stepExpect
)
codeLine
+=
fmt
.
Sprintf
(
" %s %s: %s
\n
"
,
langUtils
.
LangMap
[
langType
][
"commentsTag"
],
stepIdent
,
stepExpect
)
codeLine
+=
LangMap
[
langType
][
"commentsTag"
]
+
"CODE: "
+
i118Utils
.
I118Prt
.
Sprintf
(
"actual_result_here"
)
codeLine
+=
langUtils
.
LangMap
[
langType
][
"commentsTag"
]
+
"CODE: "
+
i118Utils
.
I118Prt
.
Sprintf
(
"actual_result_here"
)
*
srcCode
=
append
(
*
srcCode
,
codeLine
)
}
...
...
src/utils/lang/lang.go
浏览文件 @
2859799d
...
...
@@ -5,6 +5,7 @@ import (
logUtils
"github.com/easysoft/zentaoatf/src/utils/log"
stringUtils
"github.com/easysoft/zentaoatf/src/utils/string"
"github.com/fatih/color"
"sort"
"strconv"
"strings"
"sync"
...
...
@@ -12,7 +13,7 @@ import (
var
LangMap
map
[
string
]
map
[
string
]
string
func
Ge
tSupportedScriptLang
()
map
[
string
]
map
[
string
]
string
{
func
ini
tSupportedScriptLang
()
map
[
string
]
map
[
string
]
string
{
var
once
sync
.
Once
once
.
Do
(
func
()
{
LangMap
=
map
[
string
]
map
[
string
]
string
{
...
...
@@ -68,7 +69,7 @@ func GetSupportedScriptLang() map[string]map[string]string {
}
func
GetSupportLanguageOptions
()
([]
string
,
[]
string
,
[]
string
)
{
arr0
:=
GetSupportLang
ageArr
()
arr0
:=
GetSupportLang
uageArrSort
()
numbs
:=
make
([]
string
,
0
)
names
:=
make
([]
string
,
0
)
...
...
@@ -90,46 +91,42 @@ func GetSupportLanguageOptions() ([]string, []string, []string) {
return
numbs
,
names
,
labels
}
func
GetSupportLangageArr
()
[]
string
{
langMap
:=
GetSupportedScriptLang
()
func
GetSupportLanguageArrSort
()
[]
string
{
arr
:=
make
([]
string
,
0
)
for
lang
,
_
:=
range
l
angMap
{
for
lang
,
_
:=
range
L
angMap
{
arr
=
append
(
arr
,
lang
)
}
sort
.
Strings
(
arr
)
return
arr
}
func
GetSupportLangageExtArr
()
[]
string
{
langMap
:=
GetSupportedScriptLang
()
func
GetSupportLanguageExtArr
()
[]
string
{
arr
:=
make
([]
string
,
0
)
for
_
,
val
:=
range
langMap
{
arr
=
append
(
arr
,
val
[
"extName"
])
for
_
,
key
:=
range
GetSupportLanguageArrSort
()
{
arr
=
append
(
arr
,
LangMap
[
key
]
[
"extName"
])
}
return
arr
}
func
CheckSupportLangages
(
scriptLang
string
)
bool
{
langMap
:=
GetSupportedScriptLang
()
if
langMap
[
scriptLang
]
==
nil
{
langs
:=
strings
.
Join
(
GetSupportLangageArr
(),
", "
)
logUtils
.
PrintToCmd
(
i118Utils
.
I118Prt
.
Sprintf
(
"only_support_script_language"
,
langs
)
+
"
\n
"
,
color
.
FgRed
)
func
CheckSupportLanguages
(
scriptLang
string
)
bool
{
if
LangMap
[
scriptLang
]
==
nil
{
langStr
:=
strings
.
Join
(
GetSupportLanguageArrSort
(),
", "
)
logUtils
.
PrintToCmd
(
i118Utils
.
I118Prt
.
Sprintf
(
"only_support_script_language"
,
langStr
)
+
"
\n
"
,
color
.
FgRed
)
return
false
}
return
true
}
func
GetSupportLang
age
Regx
()
string
{
regx
:=
"("
+
strings
.
Join
(
GetSupportLangageExtArr
(),
"|"
)
+
")"
func
GetSupportLang
uageExt
Regx
()
string
{
regx
:=
"("
+
strings
.
Join
(
GetSupportLang
u
ageExtArr
(),
"|"
)
+
")"
return
regx
}
func
init
()
{
Ge
tSupportedScriptLang
()
ini
tSupportedScriptLang
()
}
src/utils/stdin/stdin.go
浏览文件 @
2859799d
...
...
@@ -63,7 +63,8 @@ func InputForCheckout(productId *string, moduleId *string, suiteId *string, task
numbs
,
names
,
labels
:=
langUtils
.
GetSupportLanguageOptions
()
fmtParam
:=
strings
.
Join
(
labels
,
"
\n
"
)
langStr
:=
GetInput
(
"("
+
strings
.
Join
(
numbs
,
"|"
)
+
")"
,
"enter_co_language"
,
fmtParam
)
langStr
:=
GetInput
(
"("
+
strings
.
Join
(
numbs
,
"|"
)
+
")"
,
""
,
"enter_co_language"
,
fmtParam
)
langNumb
,
_
:=
strconv
.
Atoi
(
langStr
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录