fixed runner.py and added -v and -quick options

This commit is contained in:
Brian O'Connor
2013-09-11 14:45:48 -07:00
parent 1e9e781c12
commit 10fdd01dc8
Regular → Executable
+28 -9
View File
@@ -1,10 +1,29 @@
import glob #!/usr/bin/env python
import unittest
test_file_strings = glob.glob('test_*.py') """
module_strings = [str[0:len(str)-3] for str in test_file_strings] Run all mininet.examples tests
print module_strings -v : verbose output
suites = [unittest.defaultTestLoader.loadTestsFromName(str) for str -quick : skip tests that take more than ~30 seconds
in module_strings] """
testSuite = unittest.TestSuite(suites)
text_runner = unittest.TextTestRunner().run(testSuite) import unittest
import os
import sys
from mininet.util import ensureRoot
from mininet.clean import cleanup
def runTests( testDir, verbosity=1 ):
"discover and run all tests in testDir"
# ensure root and cleanup before starting tests
ensureRoot()
cleanup()
# discover all tests in testDir
testSuite = unittest.defaultTestLoader.discover( testDir )
# run tests
unittest.TextTestRunner( verbosity=verbosity ).run( testSuite )
if __name__ == '__main__':
# get the directory containing example tests
testDir = os.path.dirname( os.path.realpath( __file__ ) )
verbosity = 2 if '-v' in sys.argv else 1
runTests( testDir, verbosity )