Bug 892121 - Every xpcshell test should get its own plugins dir. r=gbrown, r=ted
authorMihnea Dobrescu-Balaur <mihneadb@gmail.com>
Wed, 17 Jul 2013 10:53:30 -0700
changeset 152251 cc264e28ac833e189212d6a4f5acab41538b9566
parent 152250 40ecd8a299adb836435a207187663abc26800a27
child 152252 27377c1b3282db20fd8b17085b236e30fb68d087
push id382
push userakeybl@mozilla.com
push dateMon, 21 Oct 2013 21:47:13 +0000
treeherdermozilla-release@5f1868ee45cb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgbrown, ted
bugs892121
milestone25.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 892121 - Every xpcshell test should get its own plugins dir. r=gbrown, r=ted
testing/xpcshell/remotexpcshelltests.py
testing/xpcshell/runxpcshelltests.py
--- a/testing/xpcshell/remotexpcshelltests.py
+++ b/testing/xpcshell/remotexpcshelltests.py
@@ -245,25 +245,34 @@ class XPCShellRemote(xpcshell.XPCShellTe
             remoteName = os.path.basename(name)
         else:
             remoteName = self.remoteJoin(remoteDir, os.path.basename(name))
         return ['-e', 'const _TEST_FILE = ["%s"];' %
                  replaceBackSlashes(remoteName)]
 
     def setupTempDir(self):
         # make sure the temp dir exists
-        if self.device.dirExists(self.remoteTmpDir):
-            self.device.removeDir(self.remoteTmpDir)
-        self.device.mkDir(self.remoteTmpDir)
+        if not self.device.dirExists(self.remoteTmpDir):
+            self.device.mkDir(self.remoteTmpDir)
 
         self.env["XPCSHELL_TEST_TEMP_DIR"] = self.remoteTmpDir
         if self.interactive:
             self.log.info("TEST-INFO | temp dir is %s" % self.remoteTmpDir)
         return self.remoteTmpDir
 
+    def setupPluginsDir(self):
+        # making sure tmp dir is set up
+        self.setupTempDir()
+
+        pluginsDir = self.remoteJoin(self.remoteTmpDir, "plugins")
+        self.device.pushDir(self.pluginsPath, pluginsDir)
+        if self.interactive:
+            self.log.info("TEST-INFO | plugins dir is %s" % pluginsDir)
+        return pluginsDir
+
     def setupProfileDir(self):
         self.device.removeDir(self.profileDir)
         self.device.mkDir(self.profileDir)
         if self.interactive or self.singleFile:
             self.log.info("TEST-INFO | profile dir is %s" % self.profileDir)
         return self.profileDir
 
     def logCommand(self, name, completeCmd, testdir):
--- a/testing/xpcshell/runxpcshelltests.py
+++ b/testing/xpcshell/runxpcshelltests.py
@@ -1,16 +1,17 @@
 #!/usr/bin/env python
 #
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 import re, sys, os, os.path, logging, shutil, signal, math, time, traceback
 import xml.dom.minidom
+from distutils import dir_util
 from glob import glob
 from optparse import OptionParser
 from subprocess import Popen, PIPE, STDOUT
 from tempfile import mkdtemp, gettempdir
 from threading import Timer
 import random
 import socket
 import time
@@ -233,17 +234,20 @@ class XPCShellTests(object):
             ])
 
         self.xpcsCmd.extend(['-f', os.path.join(self.testharnessdir, 'head.js')])
 
         if self.debuggerInfo:
             self.xpcsCmd = [self.debuggerInfo["path"]] + self.debuggerInfo["args"] + self.xpcsCmd
 
         if self.pluginsPath:
-            self.xpcsCmd.extend(['-p', os.path.abspath(self.pluginsPath)])
+            self.pluginsDir = self.setupPluginsDir()
+            self.xpcsCmd.extend(['-p', self.pluginsDir])
+        else:
+            self.pluginsDir = None
 
     def buildTestPath(self):
         """
           If we specifiy a testpath, set the self.testPath variable to be the given directory or file.
 
           |testPath| will be the optional path only, or |None|.
           |singleFile| will be the optional test only, or |None|.
         """
@@ -284,16 +288,26 @@ class XPCShellTests(object):
                 if not os.path.isfile(path):
                     raise Exception('%s file is not a file: %s' % (kind, path))
 
                 yield path
 
         return (list(sanitize_list(test['head'], 'head')),
                 list(sanitize_list(test['tail'], 'tail')))
 
+    def setupPluginsDir(self):
+        pluginsDir = mkdtemp()
+        # shutil.copytree requires dst to not exist. Deleting the tempdir
+        # would make a race condition possible in a concurrent environment,
+        # so we are using dir_utils.copy_tree which accepts an existing dst
+        dir_util.copy_tree(self.pluginsPath, pluginsDir)
+        if self.interactive:
+            self.log.info("TEST-INFO | plugins dir is %s" % pluginsDir)
+        return pluginsDir
+
     def setupProfileDir(self):
         """
           Create a temporary folder for the profile and set appropriate environment variables.
           When running check-interactive and check-one, the directory is well-defined and
           retained for inspection once the tests complete.
 
           On a remote system, this may be overloaded to use a remote path structure.
         """
@@ -1043,16 +1057,19 @@ class XPCShellTests(object):
 
             # We don't want to delete the profile when running check-interactive
             # or check-one.
             if self.profileDir and not self.interactive and not self.singleFile:
                 self.cleanupDir(self.profileDir, name, stdout, xunit_result)
 
             self.cleanupDir(self.tempDir, name, stdout, xunit_result)
 
+            if self.pluginsDir:
+                self.cleanupDir(self.pluginsDir, name, stdout, xunit_result)
+
         if gotSIGINT:
             xunit_result["passed"] = False
             xunit_result["time"] = "0.0"
             xunit_result["failure"] = {
                 "type": "SIGINT",
                 "message": "Received SIGINT",
                 "text": "Received SIGINT (control-C) during test execution."
             }