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 783080 f0750f24891eb4e99d427d865c62c08643679f66
parent 782895 6276ec7ebbf33e3484997b189f20fc1511534187
child 783081 a5deca5affc9d7a6000b5e4f1524a7525ef75fbe
push id106597
push userahalberstadt@mozilla.com
push dateMon, 16 Apr 2018 14:41:52 +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']