Commit ab6bbc55 authored by Serge Gautherie's avatar Serge Gautherie
Browse files

Bug 480077 - automation.py.in : additional fix to bug 472706 for |runApp()|...

Bug 480077 - automation.py.in : additional fix to bug 472706 for |runApp()| return value(s); (Bv1a) Replace external times by internal duration ++; r=jwalden+bmo
parent a0a5fce8
Loading
Loading
Loading
Loading
+13 −13
Original line number Diff line number Diff line
@@ -120,7 +120,7 @@ class Process(subprocess.Popen):
        try:
          subprocess.Popen(["kill", "-f", pid]).wait()
        except:
          log.info("TEST-UNEXPECTED-FAIL | Missing 'kill' utility to kill process with pid=%s. Kill it manually!", pid)
          log.info("TEST-UNEXPECTED-FAIL | (automation.py) | Missing 'kill' utility to kill process with pid=%s. Kill it manually!", pid)
      else:
        # Windows XP and later.
        subprocess.Popen(["taskkill", "/F", "/PID", pid]).wait()
@@ -408,22 +408,19 @@ def environment(env = None, xrePath = DIST_BIN):
###############

def runApp(testURL, env, app, profileDir, extraArgs, runSSLTunnel = False, utilityPath = DIST_BIN, xrePath = DIST_BIN, certPath = CERTS_SRC_DIR):
  "Run the app, returning a tuple containing the status code and the time at which it was started."
  "Run the app, log the duration it took to execute, return the status code."

  if IS_TEST_BUILD and runSSLTunnel:
    # create certificate database for the profile
    certificateStatus = fillCertificateDB(profileDir, certPath, utilityPath, xrePath)
    if certificateStatus != 0:
      log.info("TEST-UNEXPECTED FAIL | Certificate integration failed")
      log.info("TEST-UNEXPECTED FAIL | (automation.py) | Certificate integration failed")
      return certificateStatus

    # start ssltunnel to provide https:// URLs capability
    ssltunnel = os.path.join(utilityPath, "ssltunnel" + BIN_SUFFIX)
    ssltunnelProcess = Process([ssltunnel, os.path.join(profileDir, "ssltunnel.cfg")], env = environment(xrePath = xrePath))
    log.info("SSL tunnel pid: %d", ssltunnelProcess.pid)
  
  "Run the app, returning the time at which it was started."
  # mark the start
  start = datetime.now()
    log.info("INFO | (automation.py) | SSL tunnel pid: %d", ssltunnelProcess.pid)

  # now run with the profile we created
  cmd = app
@@ -447,17 +444,20 @@ def runApp(testURL, env, app, profileDir, extraArgs, runSSLTunnel = False, utili
    else:
      args.append((testURL))
  args.extend(extraArgs)

  startTime = datetime.now()
  proc = Process([cmd] + args, env = environment(env), stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
  log.info("Application pid: %d", proc.pid)
  log.info("INFO | (automation.py) | Application pid: %d", proc.pid)
  line = proc.stdout.readline()
  while line != "":
    log.info(line.rstrip())
    line = proc.stdout.readline()
  status = proc.wait()
  if status != 0:
    log.info("TEST-UNEXPECTED-FAIL | Exited with code %d during test run", status)
    log.info("TEST-UNEXPECTED-FAIL | (automation.py) | Exited with code %d during test run", status)
  log.info("INFO | (automation.py) | Application ran for: %s", str(datetime.now() - startTime))

  if IS_TEST_BUILD and runSSLTunnel:
    ssltunnelProcess.kill()

  return (status, start)
  return status
+2 −2
Original line number Diff line number Diff line
@@ -84,6 +84,6 @@ if __name__ == '__main__':

    url = "http://localhost:%d/bloatcycle.html" % PORT
    appPath = os.path.join(SCRIPT_DIR, automation.DEFAULT_APP)
    (status, start) = automation.runApp(url, browserEnv, appPath,
                                        PROFILE_DIRECTORY, extraArgs)
    status = automation.runApp(url, browserEnv, appPath, PROFILE_DIRECTORY,
                               extraArgs)
    sys.exit(status)
+2 −4
Original line number Diff line number Diff line
@@ -75,7 +75,5 @@ if __name__ == '__main__':

  url = "http://localhost:%d/index.html" % PORT
  appPath = os.path.join(SCRIPT_DIR, automation.DEFAULT_APP)
  (status, start) = automation.runApp(url, browserEnv, appPath, 
                                      PROFILE_DIRECTORY, {})
  status = automation.runApp(url, browserEnv, appPath, PROFILE_DIRECTORY, {})
  sys.exit(status)
+5 −7
Original line number Diff line number Diff line
@@ -135,8 +135,7 @@ Are you executing $objdir/_tests/reftest/runreftest.py?""" \
    # run once with -silent to let the extension manager do its thing
    # and then exit the app
    log.info("REFTEST INFO | runreftest.py | Performing extension manager registration: start.\n")
    (status, start) = automation.runApp(None, browserEnv, options.app,
                                        profileDir,
    status = automation.runApp(None, browserEnv, options.app, profileDir,
                               extraArgs = ["-silent"])
    # We don't care to call |processLeakLog()| for this step.
    log.info("\nREFTEST INFO | runreftest.py | Performing extension manager registration: end.")
@@ -144,8 +143,7 @@ Are you executing $objdir/_tests/reftest/runreftest.py?""" \
    # then again to actually run reftest
    log.info("REFTEST INFO | runreftest.py | Running tests: start.\n")
    reftestlist = getFullPath(args[0])
    (status, start) = automation.runApp(None, browserEnv, options.app,
                                        profileDir,
    status = automation.runApp(None, browserEnv, options.app, profileDir,
                               extraArgs = ["-reftest", reftestlist])
    processLeakLog()
    log.info("\nREFTEST INFO | runreftest.py | Running tests: end.")
+6 −12
Original line number Diff line number Diff line
@@ -394,7 +394,7 @@ Are you executing $objdir/_tests/testing/mochitest/runtests.py?"""
  if options.fatalAssertions:
    browserEnv["XPCOM_DEBUG_BREAK"] = "stack-and-abort"

  (status, start) = automation.runApp(testURL, browserEnv, options.app,
  status = automation.runApp(testURL, browserEnv, options.app,
                             PROFILE_DIRECTORY, options.browserArgs,
                             runSSLTunnel = True,
                             utilityPath = options.utilityPath,
@@ -476,12 +476,6 @@ Are you executing $objdir/_tests/testing/mochitest/runtests.py?"""
      log.info("TEST-UNEXPECTED-FAIL | runtests-leaks | missing output line for total leaks!")
    leaks.close()


  # print test run times
  finish = datetime.now()
  log.info(" started: %s", str(start))
  log.info("finished: %s", str(finish))

  # delete the profile and manifest
  os.remove(manifest)