[tor-commits] [stem/master] Eliminating the 'test.' config prefix

atagar at torproject.org atagar at torproject.org
Mon Jan 23 07:06:16 UTC 2012


commit 92f97544455aee94a229daee20f099f14f92829e
Author: Damian Johnson <atagar at torproject.org>
Date:   Sun Jan 22 22:24:53 2012 -0800

    Eliminating the 'test.' config prefix
    
    It's redundant for testing configurations to have a 'test.' prefix.
    Configurations are already segregated by their handle so they would be only
    accessed via the 'test' config anyway.
    
    My heart isn't set on these config hierarchies but this will do until someone
    proposes something better.
---
 run_tests.py       |   38 +++++++++++++-------------
 test/runner.py     |   10 +++---
 test/settings.cfg  |   22 ++++++++--------
 test/testrc.sample |   72 ++++++++++++++++++++++++++--------------------------
 4 files changed, 71 insertions(+), 71 deletions(-)

diff --git a/run_tests.py b/run_tests.py
index 364d411..b344111 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -37,11 +37,11 @@ OPT_EXPANDED = ["unit", "integ", "config=", "targets=", "log=", "tor=", "no-colo
 DIVIDER = "=" * 70
 
 CONFIG = {
-  "test.arg.unit": False,
-  "test.arg.integ": False,
-  "test.arg.log": None,
-  "test.arg.tor": "tor",
-  "test.arg.no_color": False,
+  "argument.unit": False,
+  "argument.integ": False,
+  "argument.log": None,
+  "argument.tor": "tor",
+  "argument.no_color": False,
   "target.config": {},
   "target.description": {},
   "target.prereq": {},
@@ -123,9 +123,9 @@ def load_user_configuration(test_config):
   
   for opt, arg in opts:
     if opt in ("-u", "--unit"):
-      arg_overrides["test.arg.unit"] = "true"
+      arg_overrides["argument.unit"] = "true"
     elif opt in ("-i", "--integ"):
-      arg_overrides["test.arg.integ"] = "true"
+      arg_overrides["argument.integ"] = "true"
     elif opt in ("-c", "--config"):
       config_path = os.path.abspath(arg)
     elif opt in ("-t", "--targets"):
@@ -144,9 +144,9 @@ def load_user_configuration(test_config):
           target_config = test_config.get("target.config", {}).get(target)
           if target_config: arg_overrides[target_config] = "true"
     elif opt in ("-l", "--log"):
-      arg_overrides["test.arg.log"] = arg.upper()
+      arg_overrides["argument.log"] = arg.upper()
     elif opt in ("--tor"):
-      arg_overrides["test.arg.tor"] = arg
+      arg_overrides["argument.tor"] = arg
     elif opt in ("-h", "--help"):
       # Prints usage information and quits. This includes a listing of the
       # valid integration targets.
@@ -178,13 +178,13 @@ def load_user_configuration(test_config):
   
   # basic validation on user input
   
-  log_config = CONFIG["test.arg.log"]
+  log_config = CONFIG["argument.log"]
   if log_config and not log_config in log.LOG_VALUES:
     print "'%s' isn't a logging runlevel, use one of the following instead:" % log_config
     print "  TRACE, DEBUG, INFO, NOTICE, WARN, ERROR"
     sys.exit(1)
   
-  tor_config = CONFIG["test.arg.tor"]
+  tor_config = CONFIG["argument.tor"]
   if not os.path.exists(tor_config) and not stem.util.system.is_available(tor_config):
     print "Unable to start tor, '%s' does not exists." % tor_config
     sys.exit(1)
@@ -201,12 +201,12 @@ if __name__ == '__main__':
   
   load_user_configuration(test_config)
   
-  if not CONFIG["test.arg.unit"] and not CONFIG["test.arg.integ"]:
+  if not CONFIG["argument.unit"] and not CONFIG["argument.integ"]:
     print "Nothing to run (for usage provide --help)\n"
     sys.exit()
   
   # if we have verbose logging then provide the testing config
-  our_level = stem.util.log.logging_level(CONFIG["test.arg.log"])
+  our_level = stem.util.log.logging_level(CONFIG["argument.log"])
   info_level = stem.util.log.logging_level(stem.util.log.INFO)
   
   if our_level <= info_level: test.output.print_config(test_config)
@@ -220,10 +220,10 @@ if __name__ == '__main__':
   )
   
   stem_logger = log.get_logger()
-  logging_buffer = log.LogBuffer(CONFIG["test.arg.log"])
+  logging_buffer = log.LogBuffer(CONFIG["argument.log"])
   stem_logger.addHandler(logging_buffer)
   
-  if CONFIG["test.arg.unit"]:
+  if CONFIG["argument.unit"]:
     test.output.print_divider("UNIT TESTS", True)
     
     for test_class in UNIT_TESTS:
@@ -239,7 +239,7 @@ if __name__ == '__main__':
     
     print
   
-  if CONFIG["test.arg.integ"]:
+  if CONFIG["argument.integ"]:
     test.output.print_divider("INTEGRATION TESTS", True)
     integ_runner = test.runner.get_runner()
     
@@ -248,7 +248,7 @@ if __name__ == '__main__':
     integ_run_targets = []
     all_run_targets = [t for t in TARGETS if CONFIG["target.torrc"].get(t)]
     
-    if test_config.get("test.target.run.all", False):
+    if test_config.get("integ.target.run.all", False):
       # test against everything with torrc options
       integ_run_targets = all_run_targets
     else:
@@ -273,7 +273,7 @@ if __name__ == '__main__':
       if target_prereq:
         # lazy loaded to skip system call if we don't have any prereqs
         if not our_version:
-          our_version = stem.version.get_system_tor_version(CONFIG["test.arg.tor"])
+          our_version = stem.version.get_system_tor_version(CONFIG["argument.tor"])
         
         if our_version < stem.version.Requirement[target_prereq]:
           skip_targets.append(target)
@@ -292,7 +292,7 @@ if __name__ == '__main__':
             print "'%s' isn't a test.runner.Torrc enumeration" % opt
             sys.exit(1)
         
-        integ_runner.start(CONFIG["test.arg.tor"], extra_torrc_opts = torrc_opts)
+        integ_runner.start(CONFIG["argument.tor"], extra_torrc_opts = torrc_opts)
         
         print term.format("Running tests...", term.Color.BLUE, term.Attr.BOLD)
         print
diff --git a/test/runner.py b/test/runner.py
index c9e3c3e..f7a78dc 100644
--- a/test/runner.py
+++ b/test/runner.py
@@ -41,8 +41,8 @@ import stem.util.enum
 import stem.util.term as term
 
 CONFIG = {
-  "test.integ.test_directory": "./test/data",
-  "test.integ.log": "./test/data/log",
+  "integ.test_directory": "./test/data",
+  "integ.log": "./test/data/log",
   "test.target.online": False,
   "test.target.relative_data_dir": False,
 }
@@ -147,7 +147,7 @@ class Runner:
     # if 'test_directory' is unset then we make a new data directory in /tmp
     # and clean it up when we're done
     
-    config_test_dir = CONFIG["test.integ.test_directory"]
+    config_test_dir = CONFIG["integ.test_directory"]
     
     if config_test_dir:
       self._test_dir = stem.util.system.expand_path(config_test_dir, STEM_BASE)
@@ -199,7 +199,7 @@ class Runner:
       self._tor_process.communicate() # blocks until the process is done
     
     # if we've made a temporary data directory then clean it up
-    if self._test_dir and CONFIG["test.integ.test_directory"] == "":
+    if self._test_dir and CONFIG["integ.test_directory"] == "":
       shutil.rmtree(self._test_dir, ignore_errors = True)
     
     self._test_dir = ""
@@ -470,7 +470,7 @@ class Runner:
         raise exc
     
     # configures logging
-    logging_path = CONFIG["test.integ.log"]
+    logging_path = CONFIG["integ.log"]
     
     if logging_path:
       logging_path = stem.util.system.expand_path(logging_path, STEM_BASE)
diff --git a/test/settings.cfg b/test/settings.cfg
index bf90ee0..19f5187 100644
--- a/test/settings.cfg
+++ b/test/settings.cfg
@@ -13,17 +13,17 @@
 # Configuration option with which the target is synced. If an option is set via
 # both the config and '--target' argument then the argument takes precedence.
 
-target.config ONLINE       => test.target.online
-target.config RELATIVE     => test.target.relative_data_dir
-target.config RUN_NONE     => test.target.run.none
-target.config RUN_OPEN     => test.target.run.open
-target.config RUN_PASSWORD => test.target.run.password
-target.config RUN_COOKIE   => test.target.run.cookie
-target.config RUN_MULTIPLE => test.target.run.multiple
-target.config RUN_SOCKET   => test.target.run.socket
-target.config RUN_SCOOKIE  => test.target.run.scookie
-target.config RUN_PTRACE   => test.target.run.ptrace
-target.config RUN_ALL      => test.target.run.all
+target.config ONLINE       => integ.target.online
+target.config RELATIVE     => integ.target.relative_data_dir
+target.config RUN_NONE     => integ.target.run.none
+target.config RUN_OPEN     => integ.target.run.open
+target.config RUN_PASSWORD => integ.target.run.password
+target.config RUN_COOKIE   => integ.target.run.cookie
+target.config RUN_MULTIPLE => integ.target.run.multiple
+target.config RUN_SOCKET   => integ.target.run.socket
+target.config RUN_SCOOKIE  => integ.target.run.scookie
+target.config RUN_PTRACE   => integ.target.run.ptrace
+target.config RUN_ALL      => integ.target.run.all
 
 # The '--help' description of the target.
 
diff --git a/test/testrc.sample b/test/testrc.sample
index 25ca9aa..a1cd5a6 100644
--- a/test/testrc.sample
+++ b/test/testrc.sample
@@ -1,13 +1,13 @@
 # Integration Test Settings
 #
-# test.arg.unit
-# test.arg.integ
-# test.arg.log
-# test.arg.tor
-# test.arg.no_color
+# argument.unit
+# argument.integ
+# argument.log
+# argument.tor
+# argument.no_color
 #   Default values for runner arguments.
 #
-# test.integ.test_directory
+# integ.test_directory
 #   Path used for our data directory and any temporary test resources. Relative
 #   paths are expanded in reference to the location of 'run_tests.py'.
 #   
@@ -15,48 +15,48 @@
 #   have a faster startup and lower load on authorities). If set to an empty
 #   value then this makes a fresh data directory for each test run.
 #
-# test.integ.log
+# integ.log
 #   Path runtime logs are placed. Relative paths are expanded in reference to
 #   'run_tests.py'. Logging is disabled if set ot an empty value.
 #
-# test.target.online
+# integ.target.online
 #   Runs tests with network activity. If set then we'll wait for tor to fully
 #   bootstrap when starting, which won't happen without a network connection.
 #
-# test.target.relative_data_dir
+# integ.target.relative_data_dir
 #   Uses a relative path for the tor data directory if set.
 #
-# test.target.run.none
-# test.target.run.open
-# test.target.run.password
-# test.target.run.cookie
-# test.target.run.multiple
-# test.target.run.socket
-# test.target.run.scookie
-# test.target.run.ptrace
-# test.target.run.all
+# integ.target.run.none
+# integ.target.run.open
+# integ.target.run.password
+# integ.target.run.cookie
+# integ.target.run.multiple
+# integ.target.run.socket
+# integ.target.run.scookie
+# integ.target.run.ptrace
+# integ.target.run.all
 #   Runs the integration test suite for all of the given connection and
 #   authentication configurations. If the 'all' option is set then the other
 #   flags are ignored.
 
-test.arg.unit false
-test.arg.integ false
-test.arg.log
-test.arg.tor tor
-test.arg.no_color false
+argument.unit false
+argument.integ false
+argument.log
+argument.tor tor
+argument.no_color false
 
-test.integ.test_directory ./test/data
-test.integ.log ./test/data/log
+integ.test_directory ./test/data
+integ.log ./test/data/log
 
-test.target.online false
-test.target.relative_data_dir false
-test.target.run.none false
-test.target.run.open true
-test.target.run.password false
-test.target.run.cookie false
-test.target.run.muiltipe false
-test.target.run.socket false
-test.target.run.scookie false
-test.target.run.ptrace false
-test.target.run.all false
+integ.target.online false
+integ.target.relative_data_dir false
+integ.target.run.none false
+integ.target.run.open true
+integ.target.run.password false
+integ.target.run.cookie false
+integ.target.run.muiltipe false
+integ.target.run.socket false
+integ.target.run.scookie false
+integ.target.run.ptrace false
+integ.target.run.all false
 





More information about the tor-commits mailing list