[tor-commits] [stem/master] Test failures presented invalid '--test' arguments
atagar at torproject.org
atagar at torproject.org
Sat Aug 17 20:44:26 UTC 2019
commit 79cf4d383ef4e60fb386a4c148ee263d169e6d56
Author: Damian Johnson <atagar at torproject.org>
Date: Sat Jun 15 16:38:45 2019 -0700
Test failures presented invalid '--test' arguments
Our integ tests are rightfully failing right now, but the message presented at
the end is incorrect...
You can re-run just these tests with:
./run_tests.py --all --target ONLINE --test test.integ.manual
./run_tests.py --all --target ONLINE --test test.integ.descriptor.collector
The trouble is that to reduce verbosity I dropped the need for module prefixes
(so you can run '--test descriptor.collector' instead), but...
1. The above message didn't account for that.
2. We were bugged in that we no longer worked with full module names, so
running the command we advised didn't work.
Both accepting full module names and now presenting short test module names.
---
run_tests.py | 15 ++-------------
test/arguments.py | 21 ++++++++++++++++++++-
2 files changed, 22 insertions(+), 14 deletions(-)
diff --git a/run_tests.py b/run_tests.py
index 77db73b5..a3a90d04 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -146,18 +146,7 @@ def _get_tests(modules, module_prefixes):
if not module_prefixes:
yield import_name
else:
- # Example import_name: test.unit.util.conf.TestConf
- #
- # Our '--test' argument doesn't include the prefix, so excluding it from
- # the names we look for.
-
- if import_name.startswith('test.unit.'):
- cropped_name = import_name[10:]
- elif import_name.startswith('test.integ.'):
- cropped_name = import_name[11:]
- else:
- cropped_name = import_name
-
+ cropped_name = test.arguments.crop_module_name(import_name)
cropped_name = cropped_name.rsplit('.', 1)[0] # exclude the class name
for prefix in module_prefixes:
@@ -370,7 +359,7 @@ def main():
println('\nYou can re-run just these tests with:\n', ERROR, STDERR)
for module in error_modules:
- println(' %s --test %s' % (' '.join(sys.argv), module), ERROR, STDERR)
+ println(' %s --test %s' % (' '.join(sys.argv), test.arguments.crop_module_name(module)), ERROR, STDERR)
else:
if skipped_tests > 0:
println('%i TESTS WERE SKIPPED' % skipped_tests, STATUS)
diff --git a/test/arguments.py b/test/arguments.py
index 0fa492d8..a871b4e5 100644
--- a/test/arguments.py
+++ b/test/arguments.py
@@ -104,7 +104,7 @@ def parse(argv):
args['attribute_targets'] = attribute_targets
elif opt == '--test':
- args['specific_test'].append(arg)
+ args['specific_test'].append(crop_module_name(arg))
elif opt in ('-l', '--log'):
arg = arg.upper()
@@ -149,3 +149,22 @@ def get_help():
help_msg += '\n'
return help_msg
+
+
+def crop_module_name(name):
+ """
+ Test modules have a 'test.unit.' or 'test.integ.' prefix which can
+ be omitted from our '--test' argument. Cropping this so we can do
+ normalized comparisons.
+
+ :param str name: module name to crop
+
+ :returns: **str** with the cropped module name
+ """
+
+ if name.startswith('test.unit.'):
+ return name[10:]
+ elif name.startswith('test.integ.'):
+ return name[11:]
+ else:
+ return name
More information about the tor-commits
mailing list