提交 019e2019 编写于 作者: Z zhouwei25 提交者: Tao Luo

fix diff_unittest.py of ci rule to avoid Misjudgment (#22113)

上级 e587bc62
...@@ -2,23 +2,30 @@ ...@@ -2,23 +2,30 @@
import difflib import difflib
import sys import sys
with open(sys.argv[1], 'r') as f: try:
origin = f.read() f1 = open(sys.argv[1], 'r')
origin = f1.read()
origin = origin.splitlines() origin = origin.splitlines()
except:
sys.exit(0)
else:
f1.close()
with open(sys.argv[2], 'r') as f: try:
new = f.read() f2 = open(sys.argv[2], 'r')
new = f2.read()
new = new.splitlines() new = new.splitlines()
except:
differ = difflib.Differ() sys.exit(0)
result = differ.compare(origin, new) else:
f2.close()
error = False error = False
diffs = [] diffs = []
for each_diff in result: for i in origin:
if each_diff[0] == '-': # delete unit test is not allowed if i not in new:
error = True error = True
diffs.append(each_diff) diffs.append(i)
''' '''
If you delete the unit test, such as commenting it out, If you delete the unit test, such as commenting it out,
please ask for approval of one RD below for passing CI: please ask for approval of one RD below for passing CI:
...@@ -27,4 +34,4 @@ please ask for approval of one RD below for passing CI: ...@@ -27,4 +34,4 @@ please ask for approval of one RD below for passing CI:
''' '''
if error: if error:
for each_diff in diffs: for each_diff in diffs:
print(each_diff) print("- %s" % each_diff)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册