commit 408dbe96e88767ca55688d196287e41c57345219 Author: Damian Johnson atagar@torproject.org Date: Tue Jun 12 09:58:08 2012 -0700
Adding --test argument to selectively run tests
Adding an argument that'll only run tests matching the given module prefix. This is to make it faster to write new tests (so we don't need to wait a minute for the full integ suite to run each time).
Also adding examples to the '--help' output and rearranging the options so '--config' is at the end (it isn't especially useful and may be dropped in the future. --- run_tests.py | 15 +++++++++++++-- test/settings.cfg | 13 ++++++++++++- test/testrc.sample | 1 + 3 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/run_tests.py b/run_tests.py index 3029094..cd7c688 100755 --- a/run_tests.py +++ b/run_tests.py @@ -50,13 +50,14 @@ import stem.util.enum import stem.util.log as log import stem.util.term as term
-OPT = "uic:l:t:h" -OPT_EXPANDED = ["unit", "integ", "config=", "targets=", "log=", "tor=", "help"] +OPT = "uit:l:c:h" +OPT_EXPANDED = ["unit", "integ", "targets=", "test=", "log=", "tor=", "config=", "help"] DIVIDER = "=" * 70
CONFIG = stem.util.conf.config_dict("test", { "argument.unit": False, "argument.integ": False, + "argument.test": "", "argument.log": None, "argument.tor": "tor", "argument.no_color": False, @@ -168,6 +169,8 @@ def load_user_configuration(test_config): else: target_config = test_config.get("target.config", {}).get(target) if target_config: arg_overrides[target_config] = "true" + elif opt in ("-l", "--test"): + arg_overrides["argument.test"] = arg elif opt in ("-l", "--log"): arg_overrides["argument.log"] = arg.upper() elif opt in ("--tor"): @@ -255,6 +258,10 @@ if __name__ == '__main__': error_tracker.set_category("UNIT TEST")
for test_class in UNIT_TESTS: + if CONFIG["argument.test"] and \ + not test_class.__module__.startswith(CONFIG["argument.test"]): + continue + test.output.print_divider(test_class.__module__) suite = unittest.TestLoader().loadTestsFromTestCase(test_class) test_results = StringIO.StringIO() @@ -327,6 +334,10 @@ if __name__ == '__main__': print
for test_class in INTEG_TESTS: + if CONFIG["argument.test"] and \ + not test_class.__module__.startswith(CONFIG["argument.test"]): + continue + test.output.print_divider(test_class.__module__) suite = unittest.TestLoader().loadTestsFromTestCase(test_class) test_results = StringIO.StringIO() diff --git a/test/settings.cfg b/test/settings.cfg index 77156c5..44e28ab 100644 --- a/test/settings.cfg +++ b/test/settings.cfg @@ -12,13 +12,24 @@ msg.help | | -u, --unit runs unit tests | -i, --integ runs integration tests -| -c, --config PATH path to a custom test configuration | -t, --target TARGET comma separated list of extra targets for integ tests +| --test TEST_NAME only run tests modules matching the given name prefix | -l, --log RUNLEVEL includes logging output with test results, runlevels: | TRACE, DEBUG, INFO, NOTICE, WARN, ERROR | --tor PATH custom tor binary to run testing against +| -c, --config PATH path to a custom test configuration | -h, --help presents this help | +| Examples: +| run_tests.py --unit --integ +| Run unit and integraiton tests. +| +| run_tests.py --integ --target RUN_ALL +| Run integraion tests against all tor configurations. +| +| run_tests.py --integ --test test.integ.util +| Only run integration tests for the util modules. +| | Integration targets:
################## diff --git a/test/testrc.sample b/test/testrc.sample index 165a8d8..444d7f2 100644 --- a/test/testrc.sample +++ b/test/testrc.sample @@ -33,6 +33,7 @@
argument.unit false argument.integ false +argument.test argument.log argument.tor tor argument.no_color false
tor-commits@lists.torproject.org