示例#1
0
    def __init__(self, **kwargs):

        optparse.OptionParser.__init__(self, **kwargs)
        for option, value in self.mochitest_options:
            self.add_option(*option, **value)
        addCommonOptions(self)
        self.set_usage(self.__doc__)
    def __init__(self, **kwargs):

        optparse.OptionParser.__init__(self, **kwargs)
        for option, value in self.mochitest_options:
            self.add_option(*option, **value)
        addCommonOptions(self)
        self.set_usage(self.__doc__)
示例#3
0
    def __init__(self, **kwargs):

        optparse.OptionParser.__init__(self, **kwargs)
        for option, value in self.mochitest_options:
            # Allocate new lists so references to original don't get mutated.
            # allowing multiple uses within a single process.
            if "default" in value and isinstance(value["default"], list):
                value["default"] = []
            self.add_option(*option, **value)
        addCommonOptions(self)
        self.set_usage(self.__doc__)
示例#4
0
    def __init__(self, **kwargs):

        optparse.OptionParser.__init__(self, **kwargs)
        for option, value in self.mochitest_options:
            # Allocate new lists so references to original don't get mutated.
            # allowing multiple uses within a single process.
            if "default" in value and isinstance(value["default"], list):
                value["default"] = []
            self.add_option(*option, **value)
        addCommonOptions(self)
        self.set_usage(self.__doc__)
    def __init__(self, automation=None, **kwargs):
        self._automation = automation or Automation()
        optparse.OptionParser.__init__(self, **kwargs)
        defaults = {}

        # we want to pass down everything from self._automation.__all__
        addCommonOptions(self, defaults=dict(zip(self._automation.__all__,
                 [getattr(self._automation, x) for x in self._automation.__all__])))

        for option in self.mochitest_options:
            self.add_option(*option[0], **option[1])

        self.set_defaults(**defaults)
        self.set_usage(self.__doc__)
def main():
  """Process command line arguments and call runTests() to do the real work."""
  parser = OptionParser()

  addCommonOptions(parser)
  parser.add_option("--interactive",
                    action="store_true", dest="interactive", default=False,
                    help="don't automatically run tests, drop to an xpcshell prompt")
  parser.add_option("--logfiles",
                    action="store_true", dest="logfiles", default=True,
                    help="create log files (default, only used to override --no-logfiles)")
  parser.add_option("--manifest",
                    type="string", dest="manifest", default=None,
                    help="Manifest of test directories to use")
  parser.add_option("--no-logfiles",
                    action="store_false", dest="logfiles",
                    help="don't create log files")
  parser.add_option("--test-path",
                    type="string", dest="testPath", default=None,
                    help="single path and/or test filename to test")
  options, args = parser.parse_args()

  if len(args) < 2 and options.manifest is None or \
     (len(args) < 1 and options.manifest is not None):
    print >>sys.stderr, """Usage: %s <path to xpcshell> <test dirs>
  or: %s --manifest=test.manifest <path to xpcshell>""" % (sys.argv[0],
                                                           sys.argv[0])
    sys.exit(1)

  if options.interactive and not options.testPath:
    print >>sys.stderr, "Error: You must specify a test filename in interactive mode!"
    sys.exit(1)

  if not runTests(args[0],
                  xrePath=options.xrePath,
                  symbolsPath=options.symbolsPath,
                  manifest=options.manifest,
                  testdirs=args[1:],
                  testPath=options.testPath,
                  interactive=options.interactive,
                  logfiles=options.logfiles):
    sys.exit(1)
示例#7
0
    def __init__(self, automation=None):
        self.automation = automation or Automation()
        OptionParser.__init__(self)
        defaults = {}

        # we want to pass down everything from automation.__all__
        addCommonOptions(self,
                         defaults=dict(
                             zip(self.automation.__all__, [
                                 getattr(self.automation, x)
                                 for x in self.automation.__all__
                             ])))
        self.automation.addCommonOptions(self)
        self.add_option(
            "--appname",
            action="store",
            type="string",
            dest="app",
            default=os.path.join(SCRIPT_DIRECTORY,
                                 self.automation.DEFAULT_APP),
            help="absolute path to application, overriding default")
        self.add_option("--extra-profile-file",
                        action="append",
                        dest="extraProfileFiles",
                        default=[],
                        help="copy specified files/dirs to testing profile")
        self.add_option(
            "--timeout",
            action="store",
            dest="timeout",
            type="int",
            default=5 * 60,  # 5 minutes per bug 479518
            help=
            "reftest will timeout in specified number of seconds. [default %default s]."
        )
        self.add_option("--leak-threshold",
                        action="store",
                        type="int",
                        dest="defaultLeakThreshold",
                        default=0,
                        help="fail if the number of bytes leaked in default "
                        "processes through refcounted objects (or bytes "
                        "in classes with MOZ_COUNT_CTOR and MOZ_COUNT_DTOR) "
                        "is greater than the given number")
        self.add_option("--utility-path",
                        action="store",
                        type="string",
                        dest="utilityPath",
                        default=self.automation.DIST_BIN,
                        help="absolute path to directory containing utility "
                        "programs (xpcshell, ssltunnel, certutil)")
        defaults["utilityPath"] = self.automation.DIST_BIN

        self.add_option("--total-chunks",
                        type="int",
                        dest="totalChunks",
                        help="how many chunks to split the tests up into")
        defaults["totalChunks"] = None

        self.add_option("--this-chunk",
                        type="int",
                        dest="thisChunk",
                        help="which chunk to run between 1 and --total-chunks")
        defaults["thisChunk"] = None

        self.add_option("--log-file",
                        action="store",
                        type="string",
                        dest="logFile",
                        default=None,
                        help="file to log output to in addition to stdout")
        defaults["logFile"] = None

        self.add_option("--skip-slow-tests",
                        dest="skipSlowTests",
                        action="store_true",
                        help="skip tests marked as slow when running")
        defaults["skipSlowTests"] = False

        self.add_option(
            "--ignore-window-size",
            dest="ignoreWindowSize",
            action="store_true",
            help=
            "ignore the window size, which may cause spurious failures and passes"
        )
        defaults["ignoreWindowSize"] = False

        self.add_option(
            "--install-extension",
            action="append",
            dest="extensionsToInstall",
            help="install the specified extension in the testing profile. "
            "The extension file's name should be <id>.xpi where <id> is "
            "the extension's id as indicated in its install.rdf. "
            "An optional path can be specified too.")
        defaults["extensionsToInstall"] = []

        self.add_option("--run-tests-in-parallel",
                        action="store_true",
                        dest="runTestsInParallel",
                        help="run tests in parallel if possible")
        self.add_option("--no-run-tests-in-parallel",
                        action="store_false",
                        dest="runTestsInParallel",
                        help="do not run tests in parallel")
        defaults["runTestsInParallel"] = False

        self.add_option("--setenv",
                        action="append",
                        type="string",
                        dest="environment",
                        metavar="NAME=VALUE",
                        help="sets the given variable in the application's "
                        "environment")
        defaults["environment"] = []

        self.add_option(
            "--filter",
            action="store",
            type="string",
            dest="filter",
            help="specifies a regular expression (as could be passed to the JS "
            "RegExp constructor) to test against URLs in the reftest manifest; "
            "only test items that have a matching test URL will be run.")
        defaults["filter"] = None

        self.add_option("--shuffle",
                        action="store_true",
                        dest="shuffle",
                        help="run reftests in random order")
        defaults["shuffle"] = False

        self.add_option(
            "--focus-filter-mode",
            action="store",
            type="string",
            dest="focusFilterMode",
            help="filters tests to run by whether they require focus. "
            "Valid values are `all', `needs-focus', or `non-needs-focus'. "
            "Defaults to `all'.")
        defaults["focusFilterMode"] = "all"

        self.add_option("--e10s",
                        action="store_true",
                        dest="e10s",
                        help="enables content processes")
        defaults["e10s"] = False

        self.set_defaults(**defaults)
  def __init__(self, automation=None):
    self.automation = automation or Automation()
    OptionParser.__init__(self)
    defaults = {}

    # we want to pass down everything from automation.__all__
    addCommonOptions(self,
                     defaults=dict(zip(self.automation.__all__,
                            [getattr(self.automation, x) for x in self.automation.__all__])))
    self.automation.addCommonOptions(self)
    self.add_option("--appname",
                    action = "store", type = "string", dest = "app",
                    default = os.path.join(SCRIPT_DIRECTORY, self.automation.DEFAULT_APP),
                    help = "absolute path to application, overriding default")
    self.add_option("--extra-profile-file",
                    action = "append", dest = "extraProfileFiles",
                    default = [],
                    help = "copy specified files/dirs to testing profile")
    self.add_option("--timeout",
                    action = "store", dest = "timeout", type = "int",
                    default = 5 * 60, # 5 minutes per bug 479518
                    help = "reftest will timeout in specified number of seconds. [default %default s].")
    self.add_option("--leak-threshold",
                    action = "store", type = "int", dest = "leakThreshold",
                    default = 0,
                    help = "fail if the number of bytes leaked through "
                           "refcounted objects (or bytes in classes with "
                           "MOZ_COUNT_CTOR and MOZ_COUNT_DTOR) is greater "
                           "than the given number")
    self.add_option("--utility-path",
                    action = "store", type = "string", dest = "utilityPath",
                    default = self.automation.DIST_BIN,
                    help = "absolute path to directory containing utility "
                           "programs (xpcshell, ssltunnel, certutil)")
    defaults["utilityPath"] = self.automation.DIST_BIN

    self.add_option("--total-chunks",
                    type = "int", dest = "totalChunks",
                    help = "how many chunks to split the tests up into")
    defaults["totalChunks"] = None

    self.add_option("--this-chunk",
                    type = "int", dest = "thisChunk",
                    help = "which chunk to run between 1 and --total-chunks")
    defaults["thisChunk"] = None

    self.add_option("--log-file",
                    action = "store", type = "string", dest = "logFile",
                    default = None,
                    help = "file to log output to in addition to stdout")
    defaults["logFile"] = None

    self.add_option("--skip-slow-tests",
                    dest = "skipSlowTests", action = "store_true",
                    help = "skip tests marked as slow when running")
    defaults["skipSlowTests"] = False

    self.add_option("--ignore-window-size",
                    dest = "ignoreWindowSize", action = "store_true",
                    help = "ignore the window size, which may cause spurious failures and passes")
    defaults["ignoreWindowSize"] = False

    self.add_option("--install-extension",
                    action = "append", dest = "extensionsToInstall",
                    help = "install the specified extension in the testing profile. "
                           "The extension file's name should be <id>.xpi where <id> is "
                           "the extension's id as indicated in its install.rdf. "
                           "An optional path can be specified too.")
    defaults["extensionsToInstall"] = []

    self.add_option("--run-tests-in-parallel",
                    action = "store_true", dest = "runTestsInParallel",
                    help = "run tests in parallel if possible")
    self.add_option("--no-run-tests-in-parallel",
                    action = "store_false", dest = "runTestsInParallel",
                    help = "do not run tests in parallel")
    defaults["runTestsInParallel"] = False

    self.add_option("--setenv",
                    action = "append", type = "string",
                    dest = "environment", metavar = "NAME=VALUE",
                    help = "sets the given variable in the application's "
                           "environment")
    defaults["environment"] = []

    self.add_option("--filter",
                    action = "store", type="string", dest = "filter",
                    help = "specifies a regular expression (as could be passed to the JS "
                           "RegExp constructor) to test against URLs in the reftest manifest; "
                           "only test items that have a matching test URL will be run.")
    defaults["filter"] = None

    self.add_option("--shuffle",
                    action = "store_true", dest = "shuffle",
                    help = "run reftests in random order")
    defaults["shuffle"] = False

    self.add_option("--focus-filter-mode",
                    action = "store", type = "string", dest = "focusFilterMode",
                    help = "filters tests to run by whether they require focus. "
                           "Valid values are `all', `needs-focus', or `non-needs-focus'. "
                           "Defaults to `all'.")
    defaults["focusFilterMode"] = "all"

    self.add_option("--e10s",
                    action = "store_true",
                    dest = "e10s",
                    help = "enables content processes")
    defaults["e10s"] = False

    self.set_defaults(**defaults)
示例#9
0
  def __init__(self):
    OptionParser.__init__(self)
    defaults = {}
    addCommonOptions(self)

    self.add_option("--appname",
                    action = "store", type = "string", dest = "app",
                    help = "absolute path to application, overriding default")
    # Certain paths do not make sense when we're cross compiling Fennec.  This
    # logic is cribbed from the example in
    # python/mozbuild/mozbuild/mach_commands.py.
    defaults['app'] = build_obj.get_binary_path() if \
        build_obj and build_obj.substs['MOZ_BUILD_APP'] != 'mobile/android' else None

    self.add_option("--extra-profile-file",
                    action = "append", dest = "extraProfileFiles",
                    default = [],
                    help = "copy specified files/dirs to testing profile")
    self.add_option("--timeout",
                    action = "store", dest = "timeout", type = "int",
                    default = 5 * 60, # 5 minutes per bug 479518
                    help = "reftest will timeout in specified number of seconds. [default %default s].")
    self.add_option("--leak-threshold",
                    action = "store", type = "int", dest = "defaultLeakThreshold",
                    default = 0,
                    help = "fail if the number of bytes leaked in default "
                           "processes through refcounted objects (or bytes "
                           "in classes with MOZ_COUNT_CTOR and MOZ_COUNT_DTOR) "
                           "is greater than the given number")
    self.add_option("--utility-path",
                    action = "store", type = "string", dest = "utilityPath",
                    help = "absolute path to directory containing utility "
                           "programs (xpcshell, ssltunnel, certutil)")
    defaults["utilityPath"] = build_obj.bindir if \
        build_obj and build_obj.substs['MOZ_BUILD_APP'] != 'mobile/android' else None

    self.add_option("--total-chunks",
                    type = "int", dest = "totalChunks",
                    help = "how many chunks to split the tests up into")
    defaults["totalChunks"] = None

    self.add_option("--this-chunk",
                    type = "int", dest = "thisChunk",
                    help = "which chunk to run between 1 and --total-chunks")
    defaults["thisChunk"] = None

    self.add_option("--log-file",
                    action = "store", type = "string", dest = "logFile",
                    default = None,
                    help = "file to log output to in addition to stdout")
    defaults["logFile"] = None

    self.add_option("--skip-slow-tests",
                    dest = "skipSlowTests", action = "store_true",
                    help = "skip tests marked as slow when running")
    defaults["skipSlowTests"] = False

    self.add_option("--ignore-window-size",
                    dest = "ignoreWindowSize", action = "store_true",
                    help = "ignore the window size, which may cause spurious failures and passes")
    defaults["ignoreWindowSize"] = False

    self.add_option("--install-extension",
                    action = "append", dest = "extensionsToInstall",
                    help = "install the specified extension in the testing profile. "
                           "The extension file's name should be <id>.xpi where <id> is "
                           "the extension's id as indicated in its install.rdf. "
                           "An optional path can be specified too.")
    defaults["extensionsToInstall"] = []

    self.add_option("--run-tests-in-parallel",
                    action = "store_true", dest = "runTestsInParallel",
                    help = "run tests in parallel if possible")
    self.add_option("--no-run-tests-in-parallel",
                    action = "store_false", dest = "runTestsInParallel",
                    help = "do not run tests in parallel")
    defaults["runTestsInParallel"] = False

    self.add_option("--setenv",
                    action = "append", type = "string",
                    dest = "environment", metavar = "NAME=VALUE",
                    help = "sets the given variable in the application's "
                           "environment")
    defaults["environment"] = []

    self.add_option("--filter",
                    action = "store", type="string", dest = "filter",
                    help = "specifies a regular expression (as could be passed to the JS "
                           "RegExp constructor) to test against URLs in the reftest manifest; "
                           "only test items that have a matching test URL will be run.")
    defaults["filter"] = None

    self.add_option("--shuffle",
                    action = "store_true", dest = "shuffle",
                    help = "run reftests in random order")
    defaults["shuffle"] = False

    self.add_option("--focus-filter-mode",
                    action = "store", type = "string", dest = "focusFilterMode",
                    help = "filters tests to run by whether they require focus. "
                           "Valid values are `all', `needs-focus', or `non-needs-focus'. "
                           "Defaults to `all'.")
    defaults["focusFilterMode"] = "all"

    self.add_option("--e10s",
                    action = "store_true",
                    dest = "e10s",
                    help = "enables content processes")
    defaults["e10s"] = False

    self.add_option("--setpref",
                    action = "append", type = "string",
                    default = [],
                    dest = "extraPrefs", metavar = "PREF=VALUE",
                    help = "defines an extra user preference")

    self.set_defaults(**defaults)
示例#10
0
PORT = 8888
PROFILE_DIRECTORY = os.path.abspath(os.path.join(SCRIPT_DIR, "./pgoprofile"))
MOZ_JAR_LOG_DIR = os.path.abspath(os.getenv("JARLOG_DIR"))
os.chdir(SCRIPT_DIR)


class EasyServer(SocketServer.TCPServer):
    allow_reuse_address = True


if __name__ == '__main__':
    from optparse import OptionParser
    automation = Automation()

    parser = OptionParser()
    addCommonOptions(parser)

    options, args = parser.parse_args()

    debuggerInfo = getDebuggerInfo(".", options.debugger, options.debuggerArgs,
                                   options.debuggerInteractive)

    httpd = EasyServer(("", PORT), SimpleHTTPServer.SimpleHTTPRequestHandler)
    t = threading.Thread(target=httpd.serve_forever)
    t.setDaemon(True)  # don't hang on exit
    t.start()

    automation.setServerInfo("localhost", PORT)
    automation.initializeProfile(PROFILE_DIRECTORY)
    browserEnv = automation.environment()
    browserEnv["XPCOM_DEBUG_BREAK"] = "warn"
示例#11
0
    def __init__(self):
        OptionParser.__init__(self)
        defaults = {}
        addCommonOptions(self)

        self.add_option(
            "--appname",
            action="store",
            type="string",
            dest="app",
            help="absolute path to application, overriding default")
        # Certain paths do not make sense when we're cross compiling Fennec.  This
        # logic is cribbed from the example in
        # python/mozbuild/mozbuild/mach_commands.py.
        defaults['app'] = build_obj.get_binary_path() if \
            build_obj and build_obj.substs['MOZ_BUILD_APP'] != 'mobile/android' else None

        self.add_option("--extra-profile-file",
                        action="append",
                        dest="extraProfileFiles",
                        default=[],
                        help="copy specified files/dirs to testing profile")
        self.add_option(
            "--timeout",
            action="store",
            dest="timeout",
            type="int",
            default=5 * 60,  # 5 minutes per bug 479518
            help=
            "reftest will timeout in specified number of seconds. [default %default s]."
        )
        self.add_option("--leak-threshold",
                        action="store",
                        type="int",
                        dest="defaultLeakThreshold",
                        default=0,
                        help="fail if the number of bytes leaked in default "
                        "processes through refcounted objects (or bytes "
                        "in classes with MOZ_COUNT_CTOR and MOZ_COUNT_DTOR) "
                        "is greater than the given number")
        self.add_option("--utility-path",
                        action="store",
                        type="string",
                        dest="utilityPath",
                        help="absolute path to directory containing utility "
                        "programs (xpcshell, ssltunnel, certutil)")
        defaults["utilityPath"] = build_obj.bindir if \
            build_obj and build_obj.substs['MOZ_BUILD_APP'] != 'mobile/android' else None

        self.add_option("--total-chunks",
                        type="int",
                        dest="totalChunks",
                        help="how many chunks to split the tests up into")
        defaults["totalChunks"] = None

        self.add_option("--this-chunk",
                        type="int",
                        dest="thisChunk",
                        help="which chunk to run between 1 and --total-chunks")
        defaults["thisChunk"] = None

        self.add_option("--log-file",
                        action="store",
                        type="string",
                        dest="logFile",
                        default=None,
                        help="file to log output to in addition to stdout")
        defaults["logFile"] = None

        self.add_option("--skip-slow-tests",
                        dest="skipSlowTests",
                        action="store_true",
                        help="skip tests marked as slow when running")
        defaults["skipSlowTests"] = False

        self.add_option(
            "--ignore-window-size",
            dest="ignoreWindowSize",
            action="store_true",
            help=
            "ignore the window size, which may cause spurious failures and passes"
        )
        defaults["ignoreWindowSize"] = False

        self.add_option(
            "--install-extension",
            action="append",
            dest="extensionsToInstall",
            help="install the specified extension in the testing profile. "
            "The extension file's name should be <id>.xpi where <id> is "
            "the extension's id as indicated in its install.rdf. "
            "An optional path can be specified too.")
        defaults["extensionsToInstall"] = []

        self.add_option("--run-tests-in-parallel",
                        action="store_true",
                        dest="runTestsInParallel",
                        help="run tests in parallel if possible")
        self.add_option("--no-run-tests-in-parallel",
                        action="store_false",
                        dest="runTestsInParallel",
                        help="do not run tests in parallel")
        defaults["runTestsInParallel"] = False

        self.add_option("--setenv",
                        action="append",
                        type="string",
                        dest="environment",
                        metavar="NAME=VALUE",
                        help="sets the given variable in the application's "
                        "environment")
        defaults["environment"] = []

        self.add_option(
            "--filter",
            action="store",
            type="string",
            dest="filter",
            help="specifies a regular expression (as could be passed to the JS "
            "RegExp constructor) to test against URLs in the reftest manifest; "
            "only test items that have a matching test URL will be run.")
        defaults["filter"] = None

        self.add_option("--shuffle",
                        action="store_true",
                        dest="shuffle",
                        help="run reftests in random order")
        defaults["shuffle"] = False

        self.add_option(
            "--focus-filter-mode",
            action="store",
            type="string",
            dest="focusFilterMode",
            help="filters tests to run by whether they require focus. "
            "Valid values are `all', `needs-focus', or `non-needs-focus'. "
            "Defaults to `all'.")
        defaults["focusFilterMode"] = "all"

        self.add_option("--e10s",
                        action="store_true",
                        dest="e10s",
                        help="enables content processes")
        defaults["e10s"] = False

        self.add_option("--setpref",
                        action="append",
                        type="string",
                        default=[],
                        dest="extraPrefs",
                        metavar="PREF=VALUE",
                        help="defines an extra user preference")

        self.set_defaults(**defaults)
示例#12
0
from automationutils import getDebuggerInfo, addCommonOptions

PORT = 8888
PROFILE_DIRECTORY = os.path.abspath(os.path.join(SCRIPT_DIR, "./pgoprofile"))
MOZ_JAR_LOG_DIR = os.path.abspath(os.path.join(os.path.join(os.getenv("OBJDIR"), "dist"), "jarlog"))
os.chdir(SCRIPT_DIR)

class EasyServer(SocketServer.TCPServer):
  allow_reuse_address = True

if __name__ == '__main__':
  from optparse import OptionParser
  automation = Automation()

  parser = OptionParser()
  addCommonOptions(parser)

  options, args = parser.parse_args()

  debuggerInfo = getDebuggerInfo(".", options.debugger, options.debuggerArgs,
          options.debuggerInteractive)

  httpd = EasyServer(("", PORT), SimpleHTTPServer.SimpleHTTPRequestHandler)
  t = threading.Thread(target=httpd.serve_forever)
  t.setDaemon(True) # don't hang on exit
  t.start()
  
  automation.setServerInfo("localhost", PORT)
  automation.initializeProfile(PROFILE_DIRECTORY)
  browserEnv = automation.environment()
  browserEnv["XPCOM_DEBUG_BREAK"] = "warn"
示例#13
0
def main():
    parser = OptionParser()

    # we want to pass down everything from automation.__all__
    addCommonOptions(
        parser,
        defaults=dict(
            zip(automation.__all__,
                [getattr(automation, x) for x in automation.__all__])))
    parser.add_option("--appname",
                      action="store",
                      type="string",
                      dest="app",
                      default=os.path.join(SCRIPT_DIRECTORY,
                                           automation.DEFAULT_APP),
                      help="absolute path to application, overriding default")
    parser.add_option("--extra-profile-file",
                      action="append",
                      dest="extraProfileFiles",
                      default=[],
                      help="copy specified files/dirs to testing profile")
    parser.add_option(
        "--timeout",
        action="store",
        dest="timeout",
        type="int",
        default=5 * 60 * 1000,  # 5 minutes per bug 479518
        help=
        "reftest will timeout in specified number of milleseconds. [default %default ms]."
    )
    parser.add_option("--leak-threshold",
                      action="store",
                      type="int",
                      dest="leakThreshold",
                      default=0,
                      help="fail if the number of bytes leaked through "
                      "refcounted objects (or bytes in classes with "
                      "MOZ_COUNT_CTOR and MOZ_COUNT_DTOR) is greater "
                      "than the given number")
    parser.add_option("--utility-path",
                      action="store",
                      type="string",
                      dest="utilityPath",
                      default=automation.DIST_BIN,
                      help="absolute path to directory containing utility "
                      "programs (xpcshell, ssltunnel, certutil)")

    options, args = parser.parse_args()

    if len(args) != 1:
        print >> sys.stderr, "No reftest.list specified."
        sys.exit(1)

    options.app = getFullPath(options.app)
    if not os.path.exists(options.app):
        print """Error: Path %(app)s doesn't exist.
Are you executing $objdir/_tests/reftest/runreftest.py?""" \
            % {"app": options.app}
        sys.exit(1)

    if options.xrePath is None:
        options.xrePath = os.path.dirname(options.app)
    else:
        # allow relative paths
        options.xrePath = getFullPath(options.xrePath)

    options.symbolsPath = getFullPath(options.symbolsPath)
    options.utilityPath = getFullPath(options.utilityPath)

    profileDir = None
    try:
        profileDir = mkdtemp()
        createReftestProfile(options, profileDir)
        copyExtraFilesToProfile(options, profileDir)

        # browser environment
        browserEnv = dict(os.environ)

        # These variables are necessary for correct application startup; change
        # via the commandline at your own risk.
        # NO_EM_RESTART: will do a '-silent' run instead.
        browserEnv["NO_EM_RESTART"] = "1"
        browserEnv["XPCOM_DEBUG_BREAK"] = "warn"
        if automation.UNIXISH:
            browserEnv["LD_LIBRARY_PATH"] = options.xrePath
            browserEnv["MOZILLA_FIVE_HOME"] = options.xrePath
            browserEnv["GNOME_DISABLE_CRASH_DIALOG"] = "1"

        # Enable leaks detection to its own log file.
        leakLogFile = os.path.join(profileDir, "runreftest_leaks.log")
        browserEnv["XPCOM_MEM_BLOAT_LOG"] = leakLogFile

        # run once with -silent to let the extension manager do its thing
        # and then exit the app
        automation.log.info(
            "REFTEST INFO | runreftest.py | Performing extension manager registration: start.\n"
        )
        # Don't care about this |status|: |runApp()| reporting it should be enough.
        status = automation.runApp(None,
                                   browserEnv,
                                   options.app,
                                   profileDir, ["-silent"],
                                   utilityPath=options.utilityPath,
                                   xrePath=options.xrePath,
                                   symbolsPath=options.symbolsPath)
        # We don't care to call |processLeakLog()| for this step.
        automation.log.info(
            "\nREFTEST INFO | runreftest.py | Performing extension manager registration: end."
        )

        # Remove the leak detection file so it can't "leak" to the tests run.
        # The file is not there if leak logging was not enabled in the application build.
        if os.path.exists(leakLogFile):
            os.remove(leakLogFile)

        # then again to actually run reftest
        automation.log.info(
            "REFTEST INFO | runreftest.py | Running tests: start.\n")
        reftestlist = getFullPath(args[0])
        status = automation.runApp(None,
                                   browserEnv,
                                   options.app,
                                   profileDir, ["-reftest", reftestlist],
                                   utilityPath=options.utilityPath,
                                   xrePath=options.xrePath,
                                   symbolsPath=options.symbolsPath)
        processLeakLog(leakLogFile, options.leakThreshold)
        automation.log.info(
            "\nREFTEST INFO | runreftest.py | Running tests: end.")
    finally:
        if profileDir:
            shutil.rmtree(profileDir)
    sys.exit(status)