Skip to content

Instantly share code, notes, and snippets.

@ashashwat
Created December 7, 2013 05:49
Show Gist options
  • Save ashashwat/7837708 to your computer and use it in GitHub Desktop.
Save ashashwat/7837708 to your computer and use it in GitHub Desktop.
Runs all tests from greed generated source code as different process.
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import os
import re
import sys
import subprocess
try:
FILE = sys.argv [1]
except IndexError:
print "Usage: % python tctest.py filename"
exit (0)
BASENAME = os.path.splitext (FILE) [0]
data = open (BASENAME + ".sample", 'r').read ()
BASENAME = BASENAME.replace (' ', '\ ')
tests = int (re.findall (r'-- Example (\d+)', data) [-1])
subprocess.check_output ("g++ -O2 " + BASENAME + ".cpp", shell = True)
for test in range (tests):
print subprocess.check_output ("./a.out " + str (test), shell=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment