-
Notifications
You must be signed in to change notification settings - Fork 0
/
grading.py
executable file
·36 lines (32 loc) · 983 Bytes
/
grading.py
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
34
35
36
#!/usr/bin/env python
import os, time, sys
from os.path import isfile, join
import shutil
os.system('./build')
test_output = 'test_output'
tests = 'tests'
if len(sys.argv) == 2:
tests = sys.argv[1]
try:
shutil.rmtree(test_output)
except:
pass
os.mkdir(test_output)
for f in os.listdir(tests):
abs_f = join(tests, f)
if isfile(abs_f):
if f[len(f) - len('.input'):] == '.input':
fn = f[:len(f) - len('.input')]
print fn,
os.system('./master.py < ' + abs_f + \
' 2> ' + join(test_output, fn+'.err') + \
' > ' + join(test_output, fn+'.output'))
with open(join(test_output, fn+'.output')) as fi:
out = fi.read()
with open(join(tests, fn+'.output')) as fi:
std = fi.read()
if out.strip() == std.strip():
print 'correct'
else:
print 'wrong'
time.sleep(2)