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

[tor-commits] [stem/master] Drop get_prereq() helper



commit bf94336ecec090a27f47fe4754c8bf13bc8b023e
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sun May 21 18:41:54 2017 -0700

    Drop get_prereq() helper
    
    Huh. Not sure why we even had this. Only caller is run_tests.py and it can do
    this just as well itself.
---
 run_tests.py | 13 +++++++------
 test/util.py | 22 ----------------------
 2 files changed, 7 insertions(+), 28 deletions(-)

diff --git a/run_tests.py b/run_tests.py
index 026e09c..f3eabf4 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -24,6 +24,7 @@ import stem.util.enum
 import stem.util.log
 import stem.util.system
 import stem.util.test_tools
+import stem.version
 
 import test.arguments
 import test.integ.installation
@@ -37,6 +38,7 @@ from test.util import STEM_BASE
 
 CONFIG = stem.util.conf.config_dict('test', {
   'integ.test_directory': './test/data',
+  'target.prereq': {},
 })
 
 MOCK_UNAVAILABLE_MSG = """\
@@ -185,7 +187,7 @@ def main():
     # these at the end of the test run so they're more noticeable.
 
     our_version = stem.version.get_system_tor_version(args.tor_path)
-    skipped_targets = []
+    skipped_targets = {}
     integ_setup_thread = None
 
     if not args.specific_test or 'test.integ.installation'.startswith(args.specific_test):
@@ -194,10 +196,10 @@ def main():
     for target in args.run_targets:
       # check if we meet this target's tor version prerequisites
 
-      target_prereq = test.util.get_prereq(target)
+      target_prereq = CONFIG['target.prereq'].get(target)
 
-      if target_prereq and our_version < target_prereq:
-        skipped_targets.append(target)
+      if target_prereq and our_version < stem.version.Requirement(target_prereq):
+        skipped_targets[target] = target_prereq
         continue
 
       error_tracker.set_category(target)
@@ -254,8 +256,7 @@ def main():
     if skipped_targets:
       println()
 
-      for target in skipped_targets:
-        req_version = test.util.get_prereq(target)
+      for target, req_version in skipped_targets.items():
         println('Unable to run target %s, this requires tor version %s' % (target, req_version), ERROR)
 
       println()
diff --git a/test/util.py b/test/util.py
index 56bf975..2731f63 100644
--- a/test/util.py
+++ b/test/util.py
@@ -9,9 +9,7 @@ Helper functions for our test framework.
   get_unit_tests - provides our unit tests
   get_integ_tests - provides our integration tests
 
-  get_prereq - provides the tor version required to run the given target
   get_torrc_entries - provides the torrc entries for a given target
-
   get_all_combinations - provides all combinations of attributes
   tor_version - provides the version of tor we're testing against
 """
@@ -25,7 +23,6 @@ import stem.util.enum
 import stem.version
 
 CONFIG = stem.util.conf.config_dict('test', {
-  'target.prereq': {},
   'target.torrc': {},
   'integ.test_directory': './test/data',
   'test.unit_tests': '',
@@ -124,25 +121,6 @@ def _get_tests(modules, module_prefix):
         yield '%s.%s' % (import_name, test_module)
 
 
-def get_prereq(target):
-  """
-  Provides the tor version required to run the given target. If the target
-  doesn't have any prerequisite then this provides **None**.
-
-  :param Target target: target to provide the prerequisite for
-
-  :returns: :class:`~stem.version.Version` required to run the given target, or
-    **None** if there is no prerequisite
-  """
-
-  target_prereq = CONFIG['target.prereq'].get(target)
-
-  if target_prereq:
-    return stem.version.Requirement[target_prereq]
-  else:
-    return None
-
-
 def get_torrc_entries(target):
   """
   Provides the torrc entries used to run the given target.



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