#!/usr/bin/env python

import sys
import pickle

res = pickle.load(open(sys.argv[1], 'r'))

total = len(res)

failed = [(name,error) for (name, time, output, error, r_code) in res
          if r_code > 0]
print "failed tests:", str(len(failed)) + '/' + str(total)

for (name, error) in failed:
    print "    ", name

print ""

n = 0
t = 0
correct = 0

for (name, time, output, error, r_code) in res:
    if r_code > 0:
        continue
    n += 1
    t += time
    ref = open(name.split('.')[0] + '.txt').read()
    if output == ref:
        correct += 1
    else:
        #TODO find and record the error
        pass

print "average runtime:", (t/n)
print "correct:", str(correct) + '/' + str(n)
