forked from ievans/tpypp
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.py
More file actions
executable file
·33 lines (26 loc) · 1014 Bytes
/
test.py
File metadata and controls
executable file
·33 lines (26 loc) · 1014 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/python
import sys
import os
import filecmp
import preprocessor
def checkFile(A, B):
return filecmp.cmp(A, B)
subdirectory = './tests/'
outputSuffix = '.p'
expectedSuffix = '.expect'
for p in [x for x in os.listdir(subdirectory) if x.endswith('.p')]:
os.remove(subdirectory + p)
files = [x for x in os.listdir(subdirectory) if not x.endswith(expectedSuffix)]
if len(files) == 0:
print('no tests found')
for i, filename in enumerate(files):
pair = (subdirectory + filename, subdirectory + filename + outputSuffix)
preprocessor.preprocessFile(*pair)
checkPair = (subdirectory + filename + outputSuffix, subdirectory + filename + expectedSuffix)
if checkFile(*checkPair) != True:
print(('check failed for ' + str(checkPair)))
sys.exit(-1)
print(('checked ' + str(i + 1) + ' of ' + str(len(files)) + ': ' + str(pair[0])))
print('all checks ok')
for p in [x for x in os.listdir(subdirectory) if x.endswith('.p')]:
os.remove(subdirectory + p)