Bug 745538 - Port mozmill test steps from Thunderbird's buildbotcustom to production buildbotcustom. r=bhearsum
authorJohn Hopkins <jhopkins@mozilla.com>
Mon, 16 Apr 2012 14:09:55 -0400
changeset 2243 57c563fd8024e304146bab53d95b25ca12f00bbc
parent 2242 2558c57ddca50799184974b4c813cb7074dcdf2d
child 2244 b375f14334ea4965eebe8cd6d0093a53cd0473a0
push id1683
push userjohn.hopkins@mozillamessaging.com
push dateMon, 16 Apr 2012 18:10:28 +0000
reviewersbhearsum
bugs745538
Bug 745538 - Port mozmill test steps from Thunderbird's buildbotcustom to production buildbotcustom. r=bhearsum
process/factory.py
--- a/process/factory.py
+++ b/process/factory.py
@@ -7107,54 +7107,101 @@ class UnittestPackagedBuildFactory(Mozil
                 self.addStep(unittest_steps.MozillaPackagedReftests(
                  suite=suite,
                  env=self.env,
                  leakThreshold=leak_threshold,
                  symbols_path=symbols_path,
                  maxTime=2*60*60, # Two Hours
                 ))
             elif suite == 'mozmill':
-
-                # Unpack the tests
+                MOZMILL_VIRTUALENV_DIR = os.path.join('..', 'mozmill-virtualenv')
+                mozmill_env = self.env.copy()
+                mozmill_env['MOZMILL_NO_VNC'] = "1"
+                mozmill_env['NO_EM_RESTART'] = "0"
+                mozmill_env['MOZMILL_RICH_FAILURES'] = "1"
+
+                # Workaround for Mozrunner bug 575863.
+                if 'LD_LIBRARY_PATH' in mozmill_env:
+                    mozmill_env['LD_LIBRARY_PATH'] = WithProperties("../%(exedir)s")
+
+                # Find the application app bundle, workaround for mozmill on OS X
+                #XXX
+                self.brandName = "Shredder"
+                if self.platform.startswith('macosx'):
+                    self.addStep(SetProperty(
+                        name='Find executable .app',
+                        command=['bash', '-c', WithProperties('echo %(exedir)s | cut -d/ -f1-2') ],
+                        property='exepath',
+                        workdir='.',
+                    ))
                 self.addStep(UnpackTest(
                  filename=WithProperties('%(tests_filename)s'),
                  testtype='mozmill',
                  haltOnFailure=True,
-                 name='unpack mochitest tests',
+                 name='unpack mozmill tests',
                  ))
-
-                # install mozmill into its virtualenv
+                self.addStep(ShellCommand(
+                  name='install plugins',
+                  command=['sh', '-c', WithProperties('if [ ! -d %(exedir)s/plugins ]; then mkdir %(exedir)s/plugins; fi && cp -R bin/plugins/* %(exedir)s/plugins/')],
+                  haltOnFailure=True,
+                  ))
+
+                # Older comm-central branches use a centrally-installed
+                # MozMill. We figure this out by seeing if installmozmill.py is
+                # present.
+                self.addStep(SetProperty(
+                  name='check mozmill virtualenv setup',
+                  property='mozmillVirtualenvSetup',
+                  command=['bash', '-c', 'test -e installmozmill.py && ls installmozmill.py'],
+                  workdir='build/mozmill/resources',
+                  flunkOnFailure=False,
+                  haltOnFailure=False,
+                  warnOnFailure=False
+                ))
+                def isVirtualenvSetup(step):
+                    return (step.build.getProperties().has_key("mozmillVirtualenvSetup") and
+                            len(step.build.getProperty("mozmillVirtualenvSetup")) > 0)
+
+                # We want to use system python on non-Windows
+                virtualenv_python = 'python' if self.platform.startswith('win') else '/usr/bin/python'
+
                 self.addStep(ShellCommand(
-                    name='install mozmill',
-                    command=['python',
-                             'mozmill/installmozmill.py'],
-                    flunkOnFailure=True,
-                    haltOnFailure=True,
-                    ))
-
-                # run the mozmill tests
-                self.addStep(unittest_steps.MozillaPackagedMozmillTests(
-                    name="run_mozmill",
-                    tests_dir='tests/firefox',
-                    binary='../%(exepath)s',
-                    platform=self.platform,
-                    workdir='build/mozmill',
-                    timeout=10*60,
-                    flunkOnFailure=True
-                    ))
-                self.addStep(unittest_steps.MozillaPackagedMozmillTests(
-                    name="run_mozmill_restart",
-                    tests_dir='tests/firefox/restartTests',
-                    binary='../%(exepath)s',
-                    platform=self.platform,
-                    restart=True,
-                    workdir='build/mozmill',
-                    timeout=5*60,
-                    flunkOnFailure=True
-                    ))
+                  name='setup virtualenv',
+                  command=[virtualenv_python, 'resources/installmozmill.py',
+                           MOZMILL_VIRTUALENV_DIR],
+                  doStepIf=isVirtualenvSetup,
+                  flunkOnFailure=True,
+                  haltOnFailure=True,
+                  workdir='build/mozmill'
+                  ))
+                bindir = 'Scripts' if self.platform.startswith('win') else 'bin'
+
+                # PYTHONHOME overrides virtualenv install directories, so get rid of it
+                mozmill_virtualenv_env = mozmill_env.copy()
+                mozmill_virtualenv_env['PYTHONHOME'] = None
+
+                mozmillpython = os.path.join(MOZMILL_VIRTUALENV_DIR, bindir, 'python')
+                self.addStep(unittest_steps.MozillaCheck,
+                  test_name="mozmill virtualenv",
+                  warnOnWarnings=True,
+                  command = ['bash', '-c', WithProperties(mozmillpython + ' runtestlist.py --binary=../%(exepath)s --symbols-path=../symbols --list=mozmilltests.list')],
+                  doStepIf=isVirtualenvSetup,
+                  env=mozmill_virtualenv_env,
+                  workdir='build/mozmill',
+                )
+                # ... and add another step for older branches, run if the above isn't
+                self.addStep(unittest_steps.MozillaCheck,
+                  test_name="mozmill legacy",
+                  warnOnWarnings=True,
+                  command=['python', 'runtestlist.py', WithProperties('--binary=../%(exepath)s') ,'--symbols-path=../symbols','--list=mozmilltests.list'],
+                  doStepIf=lambda step: not isVirtualenvSetup(step),
+                  env=mozmill_env,
+                  workdir='build/mozmill',
+                )
+
         if self.platform.startswith('macosx64'):
             self.addStep(resolution_step())
 
 
 class RemoteUnittestFactory(MozillaTestFactory):
     def __init__(self, platform, suites, hostUtils, productName='fennec',
                 downloadSymbols=False, downloadTests=True, posixBinarySuffix='',
                 remoteExtras=None, branchName=None, **kwargs):