Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b96330dc
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
b96330dc
编写于
12月 14, 2021
作者:
H
Hui Li
提交者:
GitHub
12月 14, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #9057 from taosdata/test/TD-12057
[TD-12057]Adjust catalog collection logic
上级
a639d0db
de02206b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
52 addition
and
39 deletion
+52
-39
tests/get_catalog.py
tests/get_catalog.py
+52
-39
未找到文件。
tests/get_catalog.py
浏览文件 @
b96330dc
...
...
@@ -17,8 +17,11 @@ import sys
import
getopt
import
os
from
fabric2
import
Connection
sys
.
path
.
append
(
"pytest"
)
import
importlib
import
re
class
CatalogGen
:
def
__init__
(
self
,
CaseDirList
,
CatalogName
,
DirDepth
):
...
...
@@ -31,7 +34,7 @@ class CatalogGen:
for
i
in
self
.
CaseDirList
:
self
.
GetCatalog
(
i
)
self
.
CollectLog
(
i
)
print
(
'Catalog Generation done'
)
print
(
"Catalog Generation done"
)
def
CollectLog
(
self
,
CaseDir
):
DirorFiles
=
os
.
listdir
(
CaseDir
)
...
...
@@ -43,12 +46,14 @@ class CatalogGen:
else
:
if
i
==
self
.
CatalogName
and
fileName
not
in
self
.
blacklist
:
self
.
blacklist
.
append
(
fileName
)
with
open
(
fileName
,
"r"
)
as
f
:
with
open
(
fileName
,
"r"
)
as
f
:
Catalog
=
f
.
read
()
title
=
CaseDir
.
split
(
"/"
)[
-
1
]
TitleLevel
=
CaseDir
.
count
(
"/"
)
with
open
(
os
.
path
.
dirname
(
CaseDir
)
+
'/'
+
self
.
CatalogName
,
"a"
)
as
f
:
f
.
write
(
"#"
*
TitleLevel
+
' %s
\n
'
%
title
)
with
open
(
os
.
path
.
dirname
(
CaseDir
)
+
"/"
+
self
.
CatalogName
,
"a"
)
as
f
:
f
.
write
(
"#"
*
TitleLevel
+
" %s
\n
"
%
title
)
f
.
write
(
Catalog
)
def
GetCatalog
(
self
,
CaseDir
):
...
...
@@ -58,16 +63,20 @@ class CatalogGen:
fileName
=
os
.
path
.
join
(
root
,
file
)
moduleName
=
fileName
.
replace
(
".py"
,
""
).
replace
(
"/"
,
"."
)
uModule
=
importlib
.
import_module
(
moduleName
)
title
=
file
.
split
(
'.'
)[
0
]
TitleLevel
=
root
.
count
(
'/'
)
+
1
title
=
file
.
split
(
"."
)[
0
]
TitleLevel
=
root
.
count
(
"/"
)
+
1
try
:
ucase
=
uModule
.
TDTestCase
()
with
open
(
root
+
'/'
+
self
.
CatalogName
,
'a'
)
as
f
:
f
.
write
(
'#'
*
TitleLevel
+
' %s
\n
'
%
title
)
for
i
in
ucase
.
caseDescription
.
__doc__
.
split
(
'
\n
'
):
if
i
.
lstrip
()
==
''
:
continue
f
.
write
(
'* '
+
i
.
strip
()
+
'
\n
'
)
except
:
with
open
(
root
+
"/"
+
self
.
CatalogName
,
"a"
)
as
f
:
f
.
write
(
"#"
*
TitleLevel
+
" %s
\n
"
%
title
)
for
i
in
ucase
.
caseDescription
.
__doc__
.
split
(
"
\n
"
):
if
i
.
lstrip
()
==
""
:
continue
if
re
.
match
(
"^case.*:"
,
i
.
strip
()):
f
.
write
(
"* "
+
i
.
strip
()
+
"
\n
"
)
else
:
f
.
write
(
i
.
strip
()
+
"
\n
"
)
except
:
print
(
fileName
)
def
CleanCatalog
(
self
):
...
...
@@ -75,57 +84,61 @@ class CatalogGen:
for
root
,
dirs
,
files
in
os
.
walk
(
i
):
for
file
in
files
:
if
file
==
self
.
CatalogName
:
os
.
remove
(
root
+
'/'
+
self
.
CatalogName
)
print
(
'clean is done'
)
os
.
remove
(
root
+
"/"
+
self
.
CatalogName
)
print
(
"clean is done"
)
if
__name__
==
"__main__"
:
CaseDirList
=
[]
CatalogName
=
''
CatalogName
=
""
DirDepth
=
0
generate
=
True
delete
=
True
opts
,
args
=
getopt
.
gnu_getopt
(
sys
.
argv
[
1
:],
'd:c:v:n:th'
)
opts
,
args
=
getopt
.
gnu_getopt
(
sys
.
argv
[
1
:],
"d:c:v:n:th"
)
for
key
,
value
in
opts
:
if
key
in
[
'-h'
,
'--help'
]:
if
key
in
[
"-h"
,
"--help"
]:
print
(
"A collection of test cases catalog written using Python"
)
print
(
'A collection of test cases catalog written using Python'
)
print
(
"-d root dir of test case files written by Python, default: system-test,develop-test"
)
print
(
'-c catalog file name, default: catalog.md'
)
print
(
'-v dir depth of test cases.default: 5'
)
print
(
'-n <True:False> generate'
)
print
(
'-r <True:False> delete'
)
"-d root dir of test case files written by Python, default: system-test,develop-test"
)
print
(
"-c catalog file name, default: catalog.md"
)
print
(
"-v dir depth of test cases.default: 5"
)
print
(
"-n <True:False> generate"
)
print
(
"-r <True:False> delete"
)
sys
.
exit
(
0
)
if
key
in
[
'-d'
]:
CaseDirList
=
value
.
split
(
','
)
if
key
in
[
"-d"
]:
CaseDirList
=
value
.
split
(
","
)
if
key
in
[
'-c'
]:
if
key
in
[
"-c"
]:
CatalogName
=
value
if
key
in
[
'-v'
]:
if
key
in
[
"-v"
]:
DirDepth
=
int
(
value
)
if
key
in
[
'-n'
]:
if
(
value
.
upper
()
==
"TRUE"
)
:
if
key
in
[
"-n"
]:
if
value
.
upper
()
==
"TRUE"
:
generate
=
True
elif
(
value
.
upper
()
==
"FALSE"
)
:
elif
value
.
upper
()
==
"FALSE"
:
generate
=
False
if
key
in
[
'-r'
]:
if
(
value
.
upper
()
==
"TRUE"
)
:
if
key
in
[
"-r"
]:
if
value
.
upper
()
==
"TRUE"
:
delete
=
True
elif
(
value
.
upper
()
==
"FALSE"
)
:
elif
value
.
upper
()
==
"FALSE"
:
delete
=
False
print
(
CaseDirList
,
CatalogName
)
if
CaseDirList
==
[]
:
CaseDirList
=
[
'system-test'
,
'develop-test'
]
if
CatalogName
==
''
:
CatalogName
=
'catalog.md'
if
CaseDirList
==
[]:
CaseDirList
=
[
"system-test"
,
"develop-test"
]
if
CatalogName
==
""
:
CatalogName
=
"catalog.md"
if
DirDepth
==
0
:
DirDepth
=
5
print
(
'opt:
\n\t
catalogname: %s
\n\t
casedirlist: %s
\n\t
depth: %d
\n\t
generate: %s
\n\t
delete: %s'
%
(
CatalogName
,
','
.
join
(
CaseDirList
),
DirDepth
,
generate
,
delete
))
print
(
"opt:
\n\t
catalogname: %s
\n\t
casedirlist: %s
\n\t
depth: %d
\n\t
generate: %s
\n\t
delete: %s"
%
(
CatalogName
,
","
.
join
(
CaseDirList
),
DirDepth
,
generate
,
delete
)
)
f
=
CatalogGen
(
CaseDirList
,
CatalogName
,
DirDepth
)
if
delete
:
f
.
CleanCatalog
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录