Add support for importing enum types and enum values (as constexprs).
1 # vim: set ts=2 sw=4 tw=99 ft=python et:
8 from subprocess import *
9 from threading import Thread
10 from display import Interactive
12 def FindTests(tests, root, folder):
14 for name in os.listdir(os.path.join(root, folder)):
15 path = os.path.join(root, folder, name)
16 if os.path.isdir(path):
20 out = re.match("^([^\.]+)\.out$", name)
21 err = re.match("^([^\.]+)\.err$", name)
23 name = os.path.join(folder, out.group(1))
24 tests.append(Test(root, name, 'out'))
26 name = os.path.join(folder, err.group(1))
27 tests.append(Test(root, name, 'err'))
30 path = os.path.join(folder, name)
31 FindTests(tests, root, path)
33 def IsTestRoot(path, name):
34 return os.path.isdir(path)
36 def RunTest_(argv, options, L):
37 if sys.platform != 'win32':
38 options['close_fds'] = True
40 p = Popen(argv, stdin=PIPE, stdout=PIPE, stderr=PIPE, **options)
43 out, err = p.communicate()
44 L[1] = (out, err, p.returncode)
46 def RunTest(test, options, shell):
47 argv = [shell, test.cmd()]
51 th = Thread(target = RunTest_, args = (argv, options, L))
64 (out, err, code) = L[1]
66 return test.check(out, err, code, timeout)
68 def RunTests(display, tests, shell):
74 result = RunTest(test, options, shell)
78 display.result(test, result)
79 except KeyboardInterrupt:
87 root = os.path.dirname(os.path.abspath(__file__))
89 from optparse import OptionParser
90 op = OptionParser(usage='%prog [options] <shell>')
91 (options, args) = op.parse_args(argv)
94 op.error('missing <shell> argument')
96 shell = os.path.normpath(args[0])
99 for name in os.listdir(root):
100 path = os.path.join(root, name)
101 if IsTestRoot(path, name):
102 FindTests(tests, root, name)
105 op.error('no test cases found')
107 display = Interactive()
108 ok = RunTests(display, tests, shell)
114 if __name__ == '__main__':