-
Notifications
You must be signed in to change notification settings - Fork 4
/
run
executable file
·72 lines (49 loc) · 2.17 KB
/
run
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env python2
import os
import sys
from time import time
BOLD = '\033[1m'
RESET = '\033[0m'
WHITE = '\033[37m'
BLUE = '\033[34m'
GREEN = '\033[32m'
def print_heading(text):
print "%s%s==>%s %s%s" % (BOLD, BLUE, WHITE, text, RESET)
def print_subheading(text):
print "%s%s==>%s %s%s" % (BOLD, GREEN, WHITE, text, RESET)
if __name__ == '__main__':
CURRENT_PATH = os.path.dirname(os.path.realpath(__file__))
PROGRAMS_PATH = os.path.join(CURRENT_PATH, 'programs')
if len(sys.argv) > 1:
language_filter = sys.argv[1]
else:
language_filter = ""
for test_program_type_dir in sorted(os.listdir(PROGRAMS_PATH)):
test_program_type_path = os.path.join(PROGRAMS_PATH, test_program_type_dir)
print_heading(test_program_type_dir)
for implementation_dir in sorted(dir_name for dir_name in os.listdir(test_program_type_path)
if '_' in dir_name):
language, implementation = implementation_dir.split('_')
print_subheading("%s (%s)" % (language, implementation))
if language_filter not in implementation_dir.lower():
print "Skipping due to filter %r" % language_filter
continue
test_program_path = os.path.join(test_program_type_path, implementation_dir)
os.chdir(test_program_path)
build_script_path = os.path.join(test_program_path, 'build')
run_script_path = os.path.join(test_program_path, 'run')
# Build "bin" if it doesn't already exist.
if os.path.exists(build_script_path):
if not os.path.exists(os.path.join(test_program_path, 'bin')):
print "Building."
os.system(build_script_path)
if os.path.exists(run_script_path):
print "Running test program."
before = time()
return_code = os.system(run_script_path)
after = time()
elapsed = after - before
if return_code == 0:
print "Took %.3f seconds." % (elapsed,)
else:
print "Failed."