Bug 1445944 - [moztest] Update shared test fixtures so they can work outside of mozilla-central draft
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Thu, 12 Apr 2018 12:03:16 -0400
changeset 781956 90fe6ea6fa690769a39dd769b5b192b63bb4c0c4
parent 781307 17dda59473c3d27d113dbd83ca0b198557b4e580
child 781957 cab9c623feb493d52529e3144940bdf079022347
push id106459
push userahalberstadt@mozilla.com
push dateFri, 13 Apr 2018 22:27:59 +0000
bugs1445944
milestone61.0a1
Bug 1445944 - [moztest] Update shared test fixtures so they can work outside of mozilla-central This isn't strictly related to this bug, but it is a change made to mozbase in the raptor repo that is worth backporting here. Figured it's easiest to land it alongside the other mozbase backports. MozReview-Commit-ID: DW7I2zKZZNk
testing/mozbase/moztest/moztest/selftest/fixtures.py
--- a/testing/mozbase/moztest/moztest/selftest/fixtures.py
+++ b/testing/mozbase/moztest/moztest/selftest/fixtures.py
@@ -10,33 +10,38 @@ from __future__ import absolute_import
 import os
 import shutil
 import sys
 
 import mozfile
 import mozinstall
 import pytest
 import requests
-from mozbuild.base import MozbuildObject
 
 here = os.path.abspath(os.path.dirname(__file__))
-build = MozbuildObject.from_environment(cwd=here)
+
+try:
+    from mozbuild.base import MozbuildObject
+    build = MozbuildObject.from_environment(cwd=here)
+except ImportError:
+    build = None
 
 
 HARNESS_ROOT_NOT_FOUND = """
 Could not find test harness root. Either a build or the 'GECKO_INSTALLER_URL'
 environment variable is required.
 """.lstrip()
 
 
 def _get_test_harness(suite, install_dir):
     # Check if there is a local build
-    harness_root = os.path.join(build.topobjdir, '_tests', install_dir)
-    if os.path.isdir(harness_root):
-        return harness_root
+    if build:
+        harness_root = os.path.join(build.topobjdir, '_tests', install_dir)
+        if os.path.isdir(harness_root):
+            return harness_root
 
     # Check if it was previously set up by another test
     harness_root = os.path.join(os.environ['PYTHON_TEST_TMP'], 'tests', suite)
     if os.path.isdir(harness_root):
         return harness_root
 
     # Check if there is a test package to download
     if 'GECKO_INSTALLER_URL' in os.environ:
@@ -108,8 +113,11 @@ def binary():
             return mozinstall.get_binary(bindir, app_name=app)
         except Exception:
             pass
 
     if 'GECKO_INSTALLER_URL' in os.environ:
         bindir = mozinstall.install(
             os.environ['GECKO_INSTALLER_URL'], os.environ['PYTHON_TEST_TMP'])
         return mozinstall.get_binary(bindir, app_name='firefox')
+
+    if 'GECKO_BINARY_PATH' in os.environ:
+        return os.environ['GECKO_BINARY_PATH']