[tor-commits] [stem/master] Synchronizing runner config

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


commit 0a5ff78074309be31ce6f71fde2b0eca86a8c3e6
Author: Damian Johnson <atagar at torproject.org>
Date:   Sun Jan 22 22:15:52 2012 -0800

    Synchronizing runner config
    
    Using the shiny new sync() method for the runner config to make the world a
    better place.
---
 test/runner.py |   20 +++++++++-----------
 1 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/test/runner.py b/test/runner.py
index 2ca380b..c9e3c3e 100644
--- a/test/runner.py
+++ b/test/runner.py
@@ -40,13 +40,15 @@ import stem.util.conf
 import stem.util.enum
 import stem.util.term as term
 
-DEFAULT_CONFIG = {
+CONFIG = {
   "test.integ.test_directory": "./test/data",
   "test.integ.log": "./test/data/log",
   "test.target.online": False,
   "test.target.relative_data_dir": False,
 }
 
+stem.util.conf.get_config("test").sync(CONFIG)
+
 STATUS_ATTR = (term.Color.BLUE, term.Attr.BOLD)
 SUBSTATUS_ATTR = (term.Color.BLUE, )
 ERROR_ATTR = (term.Color.RED, term.Attr.BOLD)
@@ -110,7 +112,6 @@ def get_runner():
 
 class Runner:
   def __init__(self):
-    self._config = dict(DEFAULT_CONFIG)
     self._runner_lock = threading.RLock()
     
     # runtime attributes, set by the start method
@@ -137,9 +138,6 @@ class Runner:
     
     self._runner_lock.acquire()
     
-    test_config = stem.util.conf.get_config("test")
-    test_config.update(self._config)
-    
     # if we're holding on to a tor process (running or not) then clean up after
     # it so we can start a fresh instance
     if self._tor_process: self.stop(quiet)
@@ -149,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 = self._config["test.integ.test_directory"]
+    config_test_dir = CONFIG["test.integ.test_directory"]
     
     if config_test_dir:
       self._test_dir = stem.util.system.expand_path(config_test_dir, STEM_BASE)
@@ -158,7 +156,7 @@ class Runner:
     
     original_cwd, data_dir_path = os.getcwd(), self._test_dir
     
-    if self._config["test.target.relative_data_dir"]:
+    if CONFIG["test.target.relative_data_dir"]:
       tor_cwd = os.path.dirname(self._test_dir)
       if not os.path.exists(tor_cwd): os.makedirs(tor_cwd)
       
@@ -177,7 +175,7 @@ class Runner:
       self._start_tor(tor_cmd, quiet)
       
       # revert our cwd back to normal
-      if self._config["test.target.relative_data_dir"]:
+      if CONFIG["test.target.relative_data_dir"]:
         os.chdir(original_cwd)
     except OSError, exc:
       self.stop(quiet)
@@ -201,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 self._config["test.integ.test_directory"] == "":
+    if self._test_dir and CONFIG["test.integ.test_directory"] == "":
       shutil.rmtree(self._test_dir, ignore_errors = True)
     
     self._test_dir = ""
@@ -472,7 +470,7 @@ class Runner:
         raise exc
     
     # configures logging
-    logging_path = self._config["test.integ.log"]
+    logging_path = CONFIG["test.integ.log"]
     
     if logging_path:
       logging_path = stem.util.system.expand_path(logging_path, STEM_BASE)
@@ -532,7 +530,7 @@ class Runner:
     try:
       # wait to fully complete if we're running tests with network activity,
       # otherwise finish after local bootstraping
-      complete_percent = 100 if self._config["test.target.online"] else 5
+      complete_percent = 100 if CONFIG["test.target.online"] else 5
       
       # prints output from tor's stdout while it starts up
       print_init_line = lambda line: _print_status("  %s\n" % line, SUBSTATUS_ATTR, quiet)





More information about the tor-commits mailing list