[tor-commits] [stem/master] Report to the user new capabilities found in Tor

atagar at torproject.org atagar at torproject.org
Mon Mar 23 01:28:54 UTC 2015


commit f363591d9658f63385a0d32c7d30eecfa659a50b
Author: Cristóbal <cristobal.leiva at usach.cl>
Date:   Thu Mar 12 00:28:50 2015 -0300

    Report to the user new capabilities found in Tor
---
 run_tests.py                               |   18 +++++++++++-------
 test/integ/descriptor/server_descriptor.py |   16 ++++++----------
 test/util.py                               |   18 ++++++++++++++----
 3 files changed, 31 insertions(+), 21 deletions(-)

diff --git a/run_tests.py b/run_tests.py
index 70e0648..2a44366 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -58,6 +58,15 @@ version 0.8.0 or later...
 https://pypi.python.org/pypi/mock/
 """
 
+NEW_CAPABILITIES_FOUND = """\
+Your version of Tor has capabilities stem presently isn't taking advantage of.
+If you're running the latest version of stem then please file a ticket on:
+
+https://trac.torproject.org/projects/tor/wiki/doc/stem/bugs
+
+New capabilities are:
+"""
+
 PYFLAKES_TASK = Task(
   'running pyflakes',
   stem.util.test_tools.pyflakes_issues,
@@ -288,19 +297,14 @@ def main():
 
     println('TESTING PASSED %s\n' % runtime_label, SUCCESS)
     
-  new_capabilities = test.util.check_new_capabilities()
+  new_capabilities = test.util.get_new_capabilities()
   
   if new_capabilities:
-    println()
-
-    println('Your version of tor has capabilities stem presently isn\'t taking advantage of. If you\'re running the latest version of stem then please file a ticket on...\n', ERROR)
-    println('https://trac.torproject.org/projects/tor/wiki/doc/stem/bugs', ERROR)
-    println('\nNew capabilities are...\n', ERROR)
+    println(NEW_CAPABILITIES_FOUND, ERROR)
     
     for item in new_capabilities:
       println('%s: %s' % (new_capabilities[item], item), ERROR)
 
-    println()
 
   sys.exit(1 if error_tracker.has_errors_occured() else 0)
 
diff --git a/test/integ/descriptor/server_descriptor.py b/test/integ/descriptor/server_descriptor.py
index 74f8afd..e7d49fd 100644
--- a/test/integ/descriptor/server_descriptor.py
+++ b/test/integ/descriptor/server_descriptor.py
@@ -39,15 +39,11 @@ class TestServerDescriptor(unittest.TestCase):
 
         unrecognized_lines = desc.get_unrecognized_lines()
 
-        if unrecognized_lines:
-          # TODO: This isn't actually a problem, and rather than failing we
-          # should alert the user about these entries at the end of the tests
-          # (along with new events, getinfo options, and such). For now though
-          # there doesn't seem to be anything in practice to trigger this so
-          # failing to get our attention if it does.
-          
+        if unrecognized_lines:          
+          # Forward-compability:
+          # 1) SHOULD function at least as it does normally (ignore the unknown)
+          # 2) Report each of the aditional (unrecognized) fields to the user
+
           for line in unrecognized_lines:
             key = line.split()[0]
-            test.util.NEW_CAPABILITIES[key] = 'Extrainfo Descriptor Entry'
-
-          #self.fail('Unrecognized descriptor content: %s' % unrecognized_lines)
+            test.util.register_new_capability(key, 'Server Descriptor Entry')
diff --git a/test/util.py b/test/util.py
index a6c6515..10fd408 100644
--- a/test/util.py
+++ b/test/util.py
@@ -80,7 +80,7 @@ Target = stem.util.enum.UppercaseEnum(
 
 STEM_BASE = os.path.sep.join(__file__.split(os.path.sep)[:-2])
 
-# register new capabilities found
+# Store new capabilities (events, descriptor entries, etc.)
 
 NEW_CAPABILITIES = {}
 
@@ -179,6 +179,13 @@ def get_torrc_entries(target):
   return torrc_opts
 
 
+def get_new_capabilities():
+  """
+  Return list of new capabilities found during the tests
+  """
+  return NEW_CAPABILITIES
+
+
 def check_stem_version():
   return stem.__version__
 
@@ -269,11 +276,14 @@ def check_for_unused_tests(paths):
     raise ValueError('Test modules are missing from our test/settings.cfg:\n%s' % '\n'.join(unused_tests))
     
 
-def check_new_capabilities():
+def register_new_capability(key, label):
   """
-  Return list of new capabilities found during tests
+  Register new capability found during the tests.
+  
+  :param str key: unique string to identify this new capability
+  :param str label: string describing where we found this new capability
   """
-  return NEW_CAPABILITIES
+  NEW_CAPABILITIES[key] = label
 
 
 def _is_test_data(path):





More information about the tor-commits mailing list