test/verify/itc.py: minor tweaks
This commit is contained in:
parent
eb551728a5
commit
e16395e1e4
|
@ -9,14 +9,19 @@ import re
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
ITC_PATH = os.path.expanduser('~/testing')
|
|
||||||
ZERO_DIVISION = '000/199/329/zero_division.c'
|
|
||||||
|
|
||||||
if sys.argv[0] in ('test/verify/itc.py', './test/verify/itc.py'):
|
if sys.argv[0] in ('test/verify/itc.py', './test/verify/itc.py'):
|
||||||
CPPCHECK_PATH = './cppcheck'
|
CPPCHECK_PATH = './cppcheck'
|
||||||
else:
|
else:
|
||||||
CPPCHECK_PATH = '../../cppcheck'
|
CPPCHECK_PATH = '../../cppcheck'
|
||||||
|
|
||||||
|
if len(sys.argv) == 2:
|
||||||
|
TESTFILE = sys.argv[1]
|
||||||
|
if not os.path.isfile(TESTFILE):
|
||||||
|
print(f'ERROR: {TESTFILE} is not a file')
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
TESTFILE = os.path.expanduser('~/itc/01.w_Defects/zero_division.c')
|
||||||
|
|
||||||
def get_error_lines(filename):
|
def get_error_lines(filename):
|
||||||
ret = []
|
ret = []
|
||||||
f = open(filename, 'rt')
|
f = open(filename, 'rt')
|
||||||
|
@ -46,9 +51,8 @@ def check(filename):
|
||||||
ret.append(int(res.group(1)))
|
ret.append(int(res.group(1)))
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
filename = os.path.join(ITC_PATH, ZERO_DIVISION)
|
wanted = get_error_lines(TESTFILE)
|
||||||
wanted = get_error_lines(filename)
|
actual = check(TESTFILE)
|
||||||
actual = check(filename)
|
|
||||||
print('wanted:' + str(wanted))
|
print('wanted:' + str(wanted))
|
||||||
print('actual:' + str(actual))
|
print('actual:' + str(actual))
|
||||||
missing = []
|
missing = []
|
||||||
|
|
Loading…
Reference in New Issue