From 67eec7103fda90ed362df4154f62739ac89290f7 Mon Sep 17 00:00:00 2001 From: Geoff Brown Date: Wed, 9 May 2018 13:34:06 -0600 Subject: [PATCH] Bug 1460399 - Refactor emulator installation in android_emulator_unittest.py; r=me,a=test-only Remove EmulatorMixin, folding it in to android_emulator_unittest. Simplify installation options based on current needs. --- .../mozharness/mozilla/testing/unittest.py | 46 ------------------- .../scripts/android_emulator_unittest.py | 34 ++++++++------ 2 files changed, 21 insertions(+), 59 deletions(-) diff --git a/testing/mozharness/mozharness/mozilla/testing/unittest.py b/testing/mozharness/mozharness/mozilla/testing/unittest.py index 92cb393a244c..19733c6d638b 100755 --- a/testing/mozharness/mozharness/mozilla/testing/unittest.py +++ b/testing/mozharness/mozharness/mozilla/testing/unittest.py @@ -262,49 +262,3 @@ class DesktopUnittestOutputParser(OutputParser): self.crashed, self.leaked) self.info("TinderboxPrint: %s
%s\n" % (suite_name, summary)) - - -class EmulatorMixin(object): - """ Currently dependent on both TooltoolMixin and TestingMixin)""" - - def install_emulator_from_tooltool(self, manifest_path, do_unzip=True): - dirs = self.query_abs_dirs() - if self.tooltool_fetch(manifest_path, output_dir=dirs['abs_work_dir'], - cache=self.config.get("tooltool_cache", None) - ): - self.fatal("Unable to download emulator via tooltool!") - if do_unzip: - unzip = self.query_exe("unzip") - unzip_cmd = [unzip, '-q', os.path.join(dirs['abs_work_dir'], "emulator.zip")] - self.run_command(unzip_cmd, cwd=dirs['abs_emulator_dir'], halt_on_failure=True, - fatal_exit_code=3) - - def install_emulator(self): - dirs = self.query_abs_dirs() - self.mkdir_p(dirs['abs_emulator_dir']) - if self.config.get('emulator_url'): - self.download_unpack(self.config['emulator_url'], dirs['abs_emulator_dir']) - elif self.config.get('emulator_manifest'): - manifest_path = self.create_tooltool_manifest(self.config['emulator_manifest']) - do_unzip = True - if 'unpack' in self.config['emulator_manifest']: - do_unzip = False - self.install_emulator_from_tooltool(manifest_path, do_unzip) - elif self.buildbot_config: - props = self.buildbot_config.get('properties') - url = 'https://hg.mozilla.org/%s/raw-file/%s/b2g/test/emulator.manifest' % ( - props['repo_path'], props['revision']) - manifest_path = self.download_file(url, - file_name='tooltool.tt', - parent_dir=dirs['abs_work_dir']) - if not manifest_path: - self.fatal("Can't download emulator manifest from %s" % url) - self.install_emulator_from_tooltool(manifest_path) - else: - self.fatal("Can't get emulator; set emulator_url or emulator_manifest in the config!") - if self.config.get('tools_manifest'): - manifest_path = self.create_tooltool_manifest(self.config['tools_manifest']) - do_unzip = True - if 'unpack' in self.config['tools_manifest']: - do_unzip = False - self.install_emulator_from_tooltool(manifest_path, do_unzip) diff --git a/testing/mozharness/scripts/android_emulator_unittest.py b/testing/mozharness/scripts/android_emulator_unittest.py index aa098b2ecab0..dea5679cd90a 100644 --- a/testing/mozharness/scripts/android_emulator_unittest.py +++ b/testing/mozharness/scripts/android_emulator_unittest.py @@ -26,12 +26,10 @@ from mozharness.base.script import BaseScript, PreScriptAction, PostScriptAction from mozharness.mozilla.buildbot import TBPL_RETRY, EXIT_STATUS_DICT from mozharness.mozilla.mozbase import MozbaseMixin from mozharness.mozilla.testing.testbase import TestingMixin, testing_config_options -from mozharness.mozilla.testing.unittest import EmulatorMixin from mozharness.mozilla.testing.codecoverage import CodeCoverageMixin -class AndroidEmulatorTest(TestingMixin, EmulatorMixin, BaseScript, MozbaseMixin, - CodeCoverageMixin): +class AndroidEmulatorTest(TestingMixin, BaseScript, MozbaseMixin, CodeCoverageMixin): config_options = [[ ["--test-suite"], {"action": "store", @@ -126,7 +124,6 @@ class AndroidEmulatorTest(TestingMixin, EmulatorMixin, BaseScript, MozbaseMixin, dirs['abs_test_install_dir'], 'modules') dirs['abs_blob_upload_dir'] = os.path.join( abs_dirs['abs_work_dir'], 'blobber_upload_dir') - dirs['abs_emulator_dir'] = abs_dirs['abs_work_dir'] dirs['abs_mochitest_dir'] = os.path.join( dirs['abs_test_install_dir'], 'mochitest') dirs['abs_reftest_dir'] = os.path.join( @@ -506,21 +503,33 @@ class AndroidEmulatorTest(TestingMixin, EmulatorMixin, BaseScript, MozbaseMixin, return url def _tooltool_fetch(self, url, dir): - c = self.config - manifest_path = self.download_file( url, file_name='releng.manifest', parent_dir=dir ) - if not os.path.exists(manifest_path): self.fatal("Could not retrieve manifest needed to retrieve " "artifacts from %s" % manifest_path) + cache = self.config.get("tooltool_cache", None) + if self.tooltool_fetch(manifest_path, output_dir=dir, cache=cache): + self.warning("Unable to download from tooltool: %s" % url) - self.tooltool_fetch(manifest_path, - output_dir=dir, - cache=c.get("tooltool_cache", None)) + def _install_emulator(self): + dirs = self.query_abs_dirs() + self.mkdir_p(dirs['abs_work_dir']) + if self.config.get('emulator_url'): + self.download_unpack(self.config['emulator_url'], dirs['abs_work_dir']) + elif self.config.get('emulator_manifest'): + manifest_path = self.create_tooltool_manifest(self.config['emulator_manifest']) + dirs = self.query_abs_dirs() + cache = self.config.get("tooltool_cache", None) + if self.tooltool_fetch(manifest_path, + output_dir=dirs['abs_work_dir'], + cache=cache): + self.fatal("Unable to download emulator via tooltool!") + else: + self.warning("Cannot get emulator: configure emulator_url or emulator_manifest") ########################################## # Actions for AndroidEmulatorTest # @@ -563,9 +572,8 @@ class AndroidEmulatorTest(TestingMixin, EmulatorMixin, BaseScript, MozbaseMixin, ''' Starts the emulator ''' - if 'emulator_url' in self.config or 'emulator_manifest' in self.config or \ - 'tools_manifest' in self.config: - self.install_emulator() + if 'emulator_url' in self.config or 'emulator_manifest' in self.config: + self._install_emulator() if not os.path.isfile(self.adb_path): self.fatal("The adb binary '%s' is not a valid file!" % self.adb_path)