forked from toddlipcon/crepo
-
Notifications
You must be signed in to change notification settings - Fork 10
/
test.py
executable file
·34 lines (29 loc) · 914 Bytes
/
test.py
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
#!/usr/bin/env python
# (c) Copyright 2009 Cloudera, Inc.
import unittest
from unittest import TestCase
import os
import subprocess
import sys
import re
TESTS_DIR=os.path.join(os.getcwd(), "shell-tests")
class ShellTests(TestCase):
def _run_shell_test(self, path):
print "running: " + path
p = subprocess.Popen([os.path.join(TESTS_DIR, path)],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
ret = p.wait()
if ret != 0:
print >>sys.stderr, "Stderr:\n%s\n\nStdout:\n%s\n" % (stderr, stdout)
self.fail("Test at %s failed" % path)
def __add_tests():
for x in os.listdir(TESTS_DIR):
if x.startswith("."): continue
t = lambda self,x=x: self._run_shell_test(x)
t.__name__ = 'test' + re.sub('[^a-zA-Z0-9]', '_', 'test' + x)
setattr(ShellTests, t.__name__, t)
__add_tests()
if __name__ == "__main__":
unittest.main()