[tor-commits] [stem/master] Make interpreter integ test work with all targets

atagar at torproject.org atagar at torproject.org
Tue Apr 18 17:25:54 UTC 2017


commit d9fa8fb42f764ee75008713cc9fe12b5e645e58b
Author: Damian Johnson <atagar at torproject.org>
Date:   Tue Apr 18 10:15:40 2017 -0700

    Make interpreter integ test work with all targets
    
    Oops, this new test was only compatable with the default target. Having it
    account for others so it runs with '--target RUN_ALL'. Caught thanks to our
    jenkins test runs.
---
 test/integ/interpreter.py | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/test/integ/interpreter.py b/test/integ/interpreter.py
index 4681c57..5e7c94b 100644
--- a/test/integ/interpreter.py
+++ b/test/integ/interpreter.py
@@ -11,15 +11,37 @@ import stem.util.system
 import test.runner
 import test.util
 
+from test.util import require_controller
+
 PROMPT_CMD = os.path.join(test.util.STEM_BASE, 'tor-prompt')
 
 
+def _run_prompt(*args):
+  if test.runner.Torrc.SOCKET not in test.runner.get_runner().get_options():
+    return stem.util.system.call([PROMPT_CMD, '--interface', test.runner.CONTROL_PORT] + list(args))
+  else:
+    return stem.util.system.call([PROMPT_CMD, '--socket', test.runner.CONTROL_SOCKET_PATH] + list(args))
+
+
 class TestInterpreter(unittest.TestCase):
+  @require_controller
   def test_running_command(self):
+    # We'd need to provide the password to stdin. Fine test to add later but
+    # not gonna hassle for now.
+
+    if test.runner.Torrc.PASSWORD in test.runner.get_runner().get_options():
+      self.skipTest('password auth unsupported')
+      return
+
     expected = ['250-config-file=%s' % test.runner.get_runner().get_torrc_path(), '250 OK']
-    self.assertEqual(expected, stem.util.system.call([PROMPT_CMD, '--interface', test.runner.CONTROL_PORT, '--run', 'GETINFO config-file']))
+    self.assertEqual(expected, _run_prompt('--run', 'GETINFO config-file'))
 
+  @require_controller
   def test_running_file(self):
+    if test.runner.Torrc.PASSWORD in test.runner.get_runner().get_options():
+      self.skipTest('password auth unsupported')
+      return
+
     expected = [
       '250-config-file=%s' % test.runner.get_runner().get_torrc_path(),
       '250 OK',
@@ -32,4 +54,4 @@ class TestInterpreter(unittest.TestCase):
       tmp.write('GETINFO config-file\nGETINFO version')
       tmp.flush()
 
-      self.assertEqual(expected, stem.util.system.call([PROMPT_CMD, '--interface', test.runner.CONTROL_PORT, '--run', tmp.name]))
+      self.assertEqual(expected, _run_prompt('--run', tmp.name))



More information about the tor-commits mailing list