Initial commit

This commit is contained in:
2018-01-29 16:14:37 -05:00
commit c9be15672c
72 changed files with 723 additions and 0 deletions

31
icpc_test.py Normal file
View File

@@ -0,0 +1,31 @@
import glob, sys, subprocess
_, src, test, t = sys.argv
ig = glob.glob(f'test/{test}/*.in')
og = glob.glob(f'test/{test}/*.ans')
print(test, len(ig), 'tests')
for ifn, ofn in zip(ig, og):
with open(ifn) as fi, open(ofn) as fx:
try:
o = subprocess.check_output(['python', src],
stdin=fi, stderr=subprocess.STDOUT,
timeout=float(t))
except subprocess.CalledProcessError as e:
o = e.output
except subprocess.TimeoutExpired:
o = b'TIMED OUT'
o = o.decode('utf-8').strip().replace('\r\n', '\n')
x = fx.read().strip().replace('\r\n', '\n')
if o != x:
print(ifn, 'expected:', x, 'got:', o, '=' * 50, sep='\n')
# run this with arguments:
# <script>.py <testdir> <timelimit>
# <testdir> should be populated with <name>.in <name>.out
# file pairs, as can be downloaded from kattis
# <testdir> should be in the test/ directory, eg test/haiku