diff_unittest.py 687 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#!/usr/bin/env python
import difflib
import sys

with open(sys.argv[1], 'r') as f:
    origin = f.read()
    origin = origin.splitlines()

with open(sys.argv[2], 'r') as f:
    new = f.read()
    new = new.splitlines()

differ = difflib.Differ()
result = differ.compare(origin, new)

error = False
diffs = []
for each_diff in result:
    if each_diff[0] == '-':  # delete unit test is not allowed
        error = True
21
        diffs.append(each_diff)
22 23 24 25
'''
If you delete the unit test, such as commenting it out, 
please ask for approval of one RD below for passing CI:

26
    - kolinwei(recommended) or zhouwei25 or luotao1
27 28 29 30
'''
if error:
    for each_diff in diffs:
        print(each_diff)