Changeset View
Changeset View
Standalone View
Standalone View
bin/test/runtests.py
Show All 33 Lines | |||||
34 | 34 | | |||
35 | Just run this file as a python script to execute all tests | 35 | Just run this file as a python script to execute all tests | ||
36 | """ | 36 | """ | ||
37 | 37 | | |||
38 | import os | 38 | import os | ||
39 | import sys | 39 | import sys | ||
40 | import unittest | 40 | import unittest | ||
41 | import optparse | 41 | import optparse | ||
42 | import tempfile | ||||
43 | | ||||
44 | | ||||
45 | sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir)) | ||||
46 | | ||||
47 | import EmergeDebug | ||||
48 | import EmergeConfig | ||||
42 | 49 | | |||
43 | 50 | | |||
44 | def main(): | 51 | def main(): | ||
45 | """Run all the tests in the emerge test suite""" | 52 | """Run all the tests in the emerge test suite""" | ||
46 | 53 | | |||
47 | parser = optparse.OptionParser() | 54 | parser = optparse.OptionParser() | ||
48 | parser.set_defaults(verbosity=1) | 55 | parser.set_defaults(verbosity=1) | ||
49 | parser.add_option("-v", "--verbose", action="store_const", const=3, | 56 | parser.add_option("-v", "--verbose", action="store_const", const=3, | ||
50 | dest="verbosity") | 57 | dest="verbosity") | ||
51 | opts, rest = parser.parse_args() | 58 | opts, rest = parser.parse_args() | ||
52 | 59 | | |||
53 | os.environ["EMERGE_VERBOSE"] = str(opts.verbosity) | | |||
54 | 60 | | |||
55 | files = os.listdir(os.curdir) | 61 | EmergeDebug.setVerbose(opts.verbosity) | ||
62 | os.environ["EMERGE_TEST_VERBOSITY"] = str(opts.verbosity) | ||||
63 | | ||||
64 | files = os.listdir(os.path.dirname(__file__)) | ||||
56 | names = [] | 65 | names = [] | ||
57 | for file in files: | 66 | for file in files: | ||
58 | if file[:4] == "test" and file[-3:] == ".py": | 67 | if file[:4] == "test" and file[-3:] == ".py": | ||
59 | names.append(file[:-3]) | 68 | names.append(file[:-3]) | ||
60 | 69 | | |||
61 | suite = unittest.defaultTestLoader.loadTestsFromNames(names) | 70 | suite = unittest.defaultTestLoader.loadTestsFromNames(names) | ||
62 | runner = unittest.TextTestRunner(verbosity = opts.verbosity) | 71 | runner = unittest.TextTestRunner(verbosity = opts.verbosity) | ||
63 | result = runner.run(suite) | 72 | result = runner.run(suite) | ||
64 | 73 | | |||
65 | sys.exit(not result.wasSuccessful()) | 74 | sys.exit(not result.wasSuccessful()) | ||
66 | 75 | | |||
67 | 76 | | |||
68 | if __name__ == "__main__": | 77 | if __name__ == "__main__": | ||
69 | main() | 78 | main() |