Bug 533246 Support latest Mozmill version (1.3/1.4) in Thunderbird tests. Patch by asuth and sid0. r=Standard8
--- a/mail/build.mk
+++ b/mail/build.mk
@@ -119,17 +119,17 @@ else
PROGRAM_LOCATION = ../../../$(DIST)/bin/
PROGRAM = $(PROGRAM_LOCATION)thunderbird$(BIN_SUFFIX)
endif
mozmill::
cd $(MOZMILLDIR) && MACOSX_DEPLOYMENT_TARGET= $(PYTHON) \
runtestlist.py --list=mozmilltests.list --binary=$(PROGRAM) \
--dir=$(topsrcdir)/mail/test/mozmill \
- --default-profile=$(PROGRAM_LOCATION)/defaults/profile $(MOZMILL_EXTRA)
+ $(MOZMILL_EXTRA)
mozmill-one::
cd $(MOZMILLDIR) && MACOSX_DEPLOYMENT_TARGET= $(PYTHON) runtest.py \
--test=$(topsrcdir)/mail/test/mozmill/$(SOLO_TEST) --binary=$(PROGRAM) \
- --default-profile=$(PROGRAM_LOCATION)/defaults/profile $(MOZMILL_EXTRA)
+ $(MOZMILL_EXTRA)
endif # ENABLE_TESTS
endif # COMM_BUILD
--- a/mail/test/mozmill/runtest.py
+++ b/mail/test/mozmill/runtest.py
@@ -140,113 +140,69 @@ class ThunderTestProfile(mozrunner.Thund
# Don't load what's new or the remote start page - keep everything local
# under our control.
'mailnews.start_page_override.mstone' : "ignore",
'mailnews.start_page.url': "about:blank",
# Do not enable gloda
'mailnews.database.global.indexer.enabled': False
}
- def __init__(self, default_profile=None, profile=None, create_new=True,
- plugins=[], preferences={}):
- self.init_env()
- self.profile_dir = os.path.join(SCRIPT_DIRECTORY, 'mozmillprofile')
-
- mozrunner.Profile.__init__(self, default_profile, profile, create_new, plugins, preferences)
-
-
- def init_env(self):
- self.base_env = dict(os.environ)
- # note, we do NOT want to set NO_EM_RESTART or jsbridge wouldn't work
- # avoid dialogs on windows
- self.base_env['XPCOM_DEBUG_BREAK'] = 'stack'
- # do not reuse an existing instance
- self.base_env['MOZ_NO_REMOTE'] = '1'
+ def create_new_profile(self, binary):
+ '''
+ We always put our profile in the same location. We only clear it out
+ when we are creating a new profile so that we can go in after the run
+ and examine things for debugging or general interest.
+ '''
+ profile_dir = os.path.join(SCRIPT_DIRECTORY, 'mozmillprofile')
+ # create a clean directory
+ if os.path.exists(profile_dir):
+ shutil.rmtree(profile_dir, onerror=rmtree_onerror)
+ os.makedirs(profile_dir)
- def _run(self, *args, **extraenv):
- env = self.base_env.copy()
- env.update(extraenv)
- allArgs = [BINARY]
- allArgs.extend(args)
- proc = automation.Process(allArgs, env=env)
- status = proc.wait()
-
- def create_new_profile(self, default_profile):
- # create a clean directory
- if os.path.exists(self.profile_dir):
- shutil.rmtree(self.profile_dir, onerror=rmtree_onerror)
- os.makedirs(self.profile_dir)
-
- # explicitly create a profile in that directory
- self._run('-CreateProfile', 'test ' + self.profile_dir)
- return self.profile_dir
+ return profile_dir
def cleanup(self):
'''
Do not cleanup at all. The next iteration will cleanup for us, but
until that time it's useful for debugging failures to leave everything
around.
'''
pass
class ThunderTestRunner(mozrunner.ThunderbirdRunner):
-
def __init__(self, *args, **kwargs):
- self.profile = args[1]
- kwargs['env'] = self.profile.base_env
+ kwargs['env'] = env = dict(os.environ)
+ # note, we do NOT want to set NO_EM_RESTART or jsbridge wouldn't work
+ # avoid dialogs on windows
+ env['XPCOM_DEBUG_BREAK'] = 'stack'
+ # do not reuse an existing instance
+ env['MOZ_NO_REMOTE'] = '1'
mozrunner.Runner.__init__(self, *args, **kwargs)
def find_binary(self):
return self.profile.app_path
class ThunderTestCLI(mozmill.CLI):
profile_class = ThunderTestProfile
runner_class = ThunderTestRunner
parser_options = copy.copy(mozmill.CLI.parser_options)
parser_options[('-m', '--bloat-tests')] = {"default":None, "dest":"created_profile", "help":"Log file name."}
- def parse_and_get_runner(self):
- """Parses the command line arguments and returns a runner instance."""
- (options, args) = self.parser.parse_args()
- self.options = options
- self.args = args
- if self.options.plugins is None:
- plugins = []
- else:
- plugins = self.options.plugins.split(',')
-
- if self.options.test is not None:
- curdir = os.getcwd()
- localprofile = os.path.join(curdir, self.options.test, "profile")
+ def __init__(self, *args, **kwargs):
+ # invoke jsbridge.CLI's constructor directly since we are explicitly
+ # trying to replace mozmill's CLI constructor here (which hardcodes
+ # the firefox runner and profile in 1.3 for no clear reason).
+ jsbridge.CLI.__init__(self, *args, **kwargs)
+ self.mozmill = self.mozmill_class(runner_class=self.runner_class,
+ profile_class=self.profile_class,
+ jsbridge_port=int(self.options.port))
- if os.path.isfile(localprofile):
- profilefile = open(localprofile, "r")
- nameinfile = profilefile.readline()
- default_profile = os.path.join(curdir, "profiles", nameinfile)
- else:
- default_profile = options.default_profile
-
- # We use a global as there appears to be no easy way of getting the
- # binary details into the profile without re-implementing what mozmill
- # gives us.
- global BINARY
- BINARY = self.options.binary
- print BINARY
-
- # We override profile in ThunderbirdTestProfile, so no point in setting
- # it here.
- profile = self.get_profile(default_profile,
- None, True,
- plugins=plugins)
- runner = self.get_runner(binary=self.options.binary,
- profile=profile)
-
- return runner
+ self.mozmill.add_global_listener(mozmill.LoggerListener())
TEST_RESULTS = []
# override mozmill's default logging case, which I hate.
def logFailure(obj):
FAILURE_LIST.append(obj)
def logEndTest(obj):
TEST_RESULTS.append(obj)
--- a/mail/test/mozmill/runtestlist.py
+++ b/mail/test/mozmill/runtestlist.py
@@ -52,21 +52,16 @@ class RunTestListOptions(optparse.Option
optparse.OptionParser.__init__(self, **kwargs)
defaults = {}
self.add_option("--binary",
action = "store", type = "string", dest = "binary",
help = "Binary to be run")
defaults["binary"] = ""
- self.add_option("--default-profile",
- action = "store", type = "string", dest = "default_profile",
- help = "Location of profile to copy from. May be overriden by individual test setups.")
- defaults["default_profile"] = ""
-
self.add_option("--list",
action = "store", type = "string", dest = "list",
help = "List of tests to be run")
defaults["list"] = ""
self.add_option("--dir",
action = "store", type = "string", dest = "dir",
help = "Directory of the tests, leave blank for current directory")
@@ -83,35 +78,34 @@ All arguments must be specified.
log = logging.getLogger()
handler = logging.StreamHandler(sys.stdout)
log.setLevel(logging.INFO)
log.addHandler(handler)
parser = RunTestListOptions()
options, args = parser.parse_args()
-if options.binary == "" or options.list == "" or options.default_profile == "":
+if options.binary == "" or options.list == "":
parser.print_help()
sys.exit(1)
totalTestErrors = 0
totalTestPasses = 0
totalDirectories = 0
f = open(options.list, 'rt')
for directory in f:
log.info("INFO | (runtestlist.py) | Running directory: %s",
directory.rstrip())
if options.dir != "":
testDirectory = os.path.join(options.dir, directory.rstrip())
else:
testDirectory = directory.rstrip()
args = ["python", "runtest.py", "-t", testDirectory,
- "--binary", options.binary,
- "--default-profile", options.default_profile]
+ "--binary", options.binary]
print args
outputPipe = subprocess.PIPE
proc = subprocess.Popen(args, cwd=SCRIPT_DIRECTORY, stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
testErrors = 0
testPasses = 0