tps: fix several trivial bugs

parent 43b3c95e
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
import sys import sys
import cmd import cmd
import glob
import os, os.path import os, os.path
import datetime import datetime
...@@ -23,21 +24,36 @@ class Suite(object): ...@@ -23,21 +24,36 @@ class Suite(object):
def run(self): def run(self):
ts = timestamp() ts = timestamp()
test_glob = os.path.join(self.path, self.pattern, '.py') test_glob = os.path.join(self.path, self.pattern + '.py')
sequence = glob.glob(test_glob) sequence = glob.glob(test_glob)
if self.path not in sys.path:
sys.path.append(self.path)
for test in sequence: for test in sequence:
testname, ext = os.path.splitext(os.path.basename(test))
try: try:
name = os.path.splitext(os.path.basename(test)) mod = __import__(testname, globals(), locals(), ['main'])
__import__(name, globals(), locals(), ['main']) mod.main()
name()
except TpsCritical, e: except TpsCritical, e:
print 'Tps Critical error, aborting: [%s]' % e.value print 'Tps Critical error, aborting: [%s]' % e.message
break break
except TpsError, e: except TpsError, e:
print 'Tps Error error, continuing: [%s]' % e.value print 'Tps Error error, continuing: [%s]' % e.message
except TpsUser, e:
print 'Tps User error, user intervention required: [%s]' % e.message
print 'Error %s found in test named %s. ',
while True:
ans = raw_input('Abort or Continue? (A/C) ')
ans = ans.lower()
if ans in ('a', 'c'):
break
if ans == 'a':
break
elif ans == 'c':
continue
except TpsWarning, e: except TpsWarning, e:
print 'Tps Warning: [%s]' % e.value print 'Tps Warning: [%s]' % e.message
finally: finally:
print 'ran test ', test
pass pass
def write_cfg(self): def write_cfg(self):
...@@ -72,7 +88,7 @@ def sha(blob, len=7): ...@@ -72,7 +88,7 @@ def sha(blob, len=7):
ret = hash.hexdigest() ret = hash.hexdigest()
if len: if len:
return ret[:len] return ret[:len]
if __name__ == '__main__': if __name__ == '__main__':
parser = OptionParser() parser = OptionParser()
...@@ -84,3 +100,4 @@ if __name__ == '__main__': ...@@ -84,3 +100,4 @@ if __name__ == '__main__':
s = Suite(options.config) s = Suite(options.config)
s.write_cfg() s.write_cfg()
s.run()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment