Bug 1248711 - Make Mochitest NSPR upload work with --run-by-dir, r=jmaher
authorHonza Bambas <honzab.moz>
Wed, 17 Feb 2016 10:30:00 +0100
changeset 284647 22fe66c4313f7b0475cfd445f22d97cff318df34
parent 284646 56a0fc6a78003c56e747f619420b60c79f40d377
child 284648 f5a6fa884f9f478f660b733459ec2df6b5d70576
push id72059
push usercbook@mozilla.com
push dateThu, 18 Feb 2016 09:48:34 +0000
treeherdermozilla-inbound@22fe66c4313f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher
bugs1248711
milestone47.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 1248711 - Make Mochitest NSPR upload work with --run-by-dir, r=jmaher
testing/mochitest/runtests.py
--- a/testing/mochitest/runtests.py
+++ b/testing/mochitest/runtests.py
@@ -26,16 +26,17 @@ import re
 import shutil
 import signal
 import subprocess
 import sys
 import tempfile
 import time
 import traceback
 import urllib2
+import uuid
 import zipfile
 import bisection
 
 from datetime import datetime
 from manifestparser import TestManifest
 from manifestparser.filters import (
     chunk_by_dir,
     chunk_by_runtime,
@@ -1205,18 +1206,16 @@ toolbar#nav-bar {
         if options.fatalAssertions:
             browserEnv["XPCOM_DEBUG_BREAK"] = "stack-and-abort"
 
         # Produce an NSPR log, is setup (see NSPR_LOG_MODULES global at the top of
         # this script).
         self.nsprLogs = NSPR_LOG_MODULES and "MOZ_UPLOAD_DIR" in os.environ
         if self.nsprLogs:
             browserEnv["NSPR_LOG_MODULES"] = NSPR_LOG_MODULES
-
-            browserEnv["NSPR_LOG_FILE"] = "%s/nspr.log" % tempfile.gettempdir()
             browserEnv["GECKO_SEPARATE_NSPR_LOGS"] = "1"
 
         if debugger and not options.slowscript:
             browserEnv["JS_DISABLE_SLOW_SCRIPT_SIGNALS"] = "1"
 
         # For e10s, our tests default to suppressing the "unsafe CPOW usage"
         # warnings that can plague test logs.
         if not options.enableCPOWWarnings:
@@ -2283,16 +2282,19 @@ class MochitestDesktop(MochitestBase):
         if 'MOZ_DISABLE_NONLOCAL_CONNECTIONS' in self.browserEnv:
             if mozinfo.info.get('buildapp') == 'mulet' or options.subsuite == 'push':
                 del self.browserEnv['MOZ_DISABLE_NONLOCAL_CONNECTIONS']
                 os.environ["MOZ_DISABLE_NONLOCAL_CONNECTIONS"] = "0"
 
         if self.browserEnv is None:
             return 1
 
+        if self.nsprLogs:
+            self.browserEnv["NSPR_LOG_FILE"] = "{}/nspr-pid=%PID-uid={}.log".format(self.browserEnv["MOZ_UPLOAD_DIR"], str(uuid.uuid4()))
+
         try:
             self.startServers(options, debuggerInfo)
 
             # testsToFilter parameter is used to filter out the test list that
             # is sent to buildTestPath
             testURL = self.buildTestPath(options, testsToFilter)
 
             # read the number of tests here, if we are not going to run any,
@@ -2395,24 +2397,16 @@ class MochitestDesktop(MochitestBase):
             self.leak_report_file,
             leak_thresholds=options.leakThresholds,
             ignore_missing_leaks=options.ignoreMissingLeaks,
             log=self.log,
             stack_fixer=get_stack_fixer_function(options.utilityPath,
                                                  options.symbolsPath),
         )
 
-        if self.nsprLogs:
-            with zipfile.ZipFile("%s/nsprlog.zip" % self.browserEnv["MOZ_UPLOAD_DIR"], "w", zipfile.ZIP_DEFLATED) as logzip:
-                for logfile in glob.glob(
-                        "%s/nspr*.log*" %
-                        tempfile.gettempdir()):
-                    logzip.write(logfile)
-                    os.remove(logfile)
-
         self.log.info("runtests.py | Running tests: end.")
 
         if self.manifest is not None:
             self.cleanup(options)
 
         return status
 
     def handleTimeout(self, timeout, proc, utilityPath, debuggerInfo,
@@ -2649,16 +2643,24 @@ def run_test_harness(options):
     if runner.getTestFlavor(options) == 'chrome':
         options.runByDir = True
 
     if mozinfo.info.get('buildapp') == 'mulet':
         options.runByDir = False
 
     result = runner.runTests(options)
 
+    if runner.nsprLogs:
+        with zipfile.ZipFile("{}/nsprlogs.zip".format(runner.browserEnv["MOZ_UPLOAD_DIR"]),
+                             "w", zipfile.ZIP_DEFLATED) as logzip:
+            for logfile in glob.glob("{}/nspr*.log*".format(runner.browserEnv["MOZ_UPLOAD_DIR"])):
+                logzip.write(logfile)
+                os.remove(logfile)
+            logzip.close()
+
     # don't dump failures if running from automation as treeherder already displays them
     if build_obj:
         if runner.message_logger.errors:
             result = 1
             runner.message_logger.logger.warning("The following tests failed:")
             for error in runner.message_logger.errors:
                 runner.message_logger.logger.log_raw(error)