[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Didn't account for test modules citing the class



commit 3263d5bd94e79f68c91c4ff27244878c5483d032
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Tue Mar 3 09:23:13 2015 -0800

    Didn't account for test modules citing the class
    
    Oops! Didn't catch that the test modules include the class. For example...
    
      test.unit.util.conf.TestConf.test_parse_enum_csv
    
    civ's original patch did, though he surfaced it in our output which caused our
    test names to be a lot longer. Changing us back so we hide it.
---
 run_tests.py |   18 ++++++++++++------
 test/util.py |    8 +++++---
 2 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/run_tests.py b/run_tests.py
index 3af6d31..8e2b8f2 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -445,12 +445,18 @@ def _run_test(args, test_class, output_filters, logging_buffer):
   if args.verbose:
     test.output.print_divider(test_class)
   else:
-    label = test_class
-
-    if label.startswith('test.unit.'):
-      label = label[10:]
-    elif label.startswith('test.integ.'):
-      label = label[11:]
+    # Test classes look like...
+    #
+    #   test.unit.util.conf.TestConf.test_parse_enum_csv
+    #
+    # We want to strip the 'test.unit.' or 'test.integ.' prefix since it's
+    # redundant. We also want to drop the test class name. The individual test
+    # name at the end it optional (only present if we used the '--test'
+    # argument).
+
+    label_comp = test_class.split('.')[2:]
+    del label_comp[-1 if label_comp[-1][0].isupper() else -2]
+    label = '.'.join(label_comp)
 
     label = '  %s...' % label
     label = '%-54s' % label
diff --git a/test/util.py b/test/util.py
index 35909e5..eb8b5eb 100644
--- a/test/util.py
+++ b/test/util.py
@@ -110,16 +110,18 @@ def get_integ_tests(module_prefix = None):
 def _get_tests(modules, module_prefix):
   for import_name in modules:
     if import_name:
-      if not module_prefix or import_name.startswith(module_prefix):
+      module, module_name = import_name.rsplit('.', 1)  # example: util.conf.TestConf
+
+      if not module_prefix or module.startswith(module_prefix):
         yield import_name
-      elif module_prefix.startswith(import_name):
+      elif module_prefix.startswith(module):
         # might be a single test in this module, check if we match any
 
         module, test = module_prefix.rsplit('.', 1)
 
         # TODO: should check if the test exists
 
-        yield module_prefix
+        yield '%s.%s' % (import_name, test)
 
 
 def get_help_message():



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits