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

[tor-commits] [stem/master] Integ tests resulted in temporary directories



commit 13dc7861ae7bfa280fda8536ca39fcf6135d7b56
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Thu May 16 09:20:11 2013 -0700

    Integ tests resulted in temporary directories
    
    Our integ test runner created temporary directories for our control socket but
    failed to clean them up. On reflection it's simpler for us to use a UUID rather
    than tempfile.mkdtemp() here so our start() and stop() methods can perform the
    creation/cleanup.
    
    Tested by running our integ tests with a control socket...
    
    ./run_tests.py --integ --target RUN_SOCKET
    
    ... and confirming both that a temporary resource is made with our control
    socket and that it's cleaned up afterward.
    
    Issue caught thanks to help from Ashish on...
    
    https://trac.torproject.org/8622
---
 test/runner.py |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/test/runner.py b/test/runner.py
index 0ea840a..3614816 100644
--- a/test/runner.py
+++ b/test/runner.py
@@ -46,6 +46,7 @@ import stat
 import tempfile
 import threading
 import time
+import uuid
 
 import stem.connection
 import stem.prereq
@@ -79,7 +80,7 @@ INTEG_RUNNER = None
 # control authentication options and attributes
 CONTROL_PASSWORD = "pw"
 CONTROL_PORT = 1111
-CONTROL_SOCKET_PATH = os.path.join(tempfile.mkdtemp(), 'socket')
+CONTROL_SOCKET_PATH = os.path.join(tempfile.gettempdir(), str(uuid.uuid4()), 'socket')
 
 Torrc = stem.util.enum.Enum(
   ("PORT", "ControlPort %i" % CONTROL_PORT),
@@ -357,6 +358,12 @@ class Runner(object):
         stem.socket.recv_message = self._original_recv_message
         self._original_recv_message = None
 
+      # clean up our socket directory if we made one
+      socket_dir = os.path.dirname(CONTROL_SOCKET_PATH)
+
+      if os.path.exists(socket_dir):
+        shutil.rmtree(socket_dir, ignore_errors = True)
+
       self._test_dir = ""
       self._tor_cmd = None
       self._tor_cwd = ""

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