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
--- 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']