[tor-commits] [stem/master] Integ test relied on tor being in path

atagar at torproject.org atagar at torproject.org
Mon Jun 25 01:45:01 UTC 2012


commit cec8ecfcf175af55d9503d45e169cd26f9664279
Author: Damian Johnson <atagar at torproject.org>
Date:   Tue Jun 19 09:47:33 2012 -0700

    Integ test relied on tor being in path
    
    I thought that it was a safe assumption that tor was in our path since the
    integ tests will only run if it can start tor. However, the tests have a
    '--tor <path to tor>' argument which means that the tests may be running
    without our path including the tor binary (or even having the binary called
    'tor').
    
    Changing the test to look for 'ls' or 'dir' instead since every platform that I
    can think of has that. Caught by Karsten.
---
 stem/util/system.py       |    3 +++
 test/integ/util/system.py |    7 +++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/stem/util/system.py b/stem/util/system.py
index d6a3ce2..73fd47e 100644
--- a/stem/util/system.py
+++ b/stem/util/system.py
@@ -74,6 +74,9 @@ def is_available(command, cached=True):
   than one command is present (for instance "ls -a | grep foo") then this
   just checks the first.
   
+  Note that many builtin common commands (like cd and ulimit) aren't in the
+  PATH so this lookup will fail for them.
+  
   :param str command: command to search for
   :param bool cached: makes use of available cached results if True
   
diff --git a/test/integ/util/system.py b/test/integ/util/system.py
index 6cdf0ec..174357e 100644
--- a/test/integ/util/system.py
+++ b/test/integ/util/system.py
@@ -61,8 +61,11 @@ class TestSystem(unittest.TestCase):
     Checks the stem.util.system.is_available function.
     """
     
-    # since we're running tor it would be kinda sad if this didn't detect it
-    self.assertTrue(stem.util.system.is_available("tor"))
+    # I have yet to see a platform without 'ls'
+    if stem.util.system.is_windows():
+      self.assertTrue(stem.util.system.is_available("dir"))
+    else:
+      self.assertTrue(stem.util.system.is_available("ls"))
     
     # but it would be kinda weird if this did...
     self.assertFalse(stem.util.system.is_available("blarg_and_stuff"))





More information about the tor-commits mailing list