Skip to content

Commit

Permalink
Don't import mozrunner unless it's actually going to be used
Browse files Browse the repository at this point in the history
This is only required for running android tests, so avoid importing it
until the relevant code is called so the top-level module can still be
loaded. This is required by at least the docs-generating code.
  • Loading branch information
jgraham authored and Hexcles committed Sep 6, 2019
1 parent 196a44e commit 03011fb
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions tools/wpt/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,23 @@
import subprocess

import requests
from mozrunner.devices import android_device

android_device.TOOLTOOL_PATH = os.path.join(os.path.dirname(__file__),
os.pardir,
"third_party",
"tooltool",
"tooltool.py")
android_device = None

here = os.path.abspath(os.path.dirname(__file__))
wpt_root = os.path.abspath(os.path.join(here, os.pardir, os.pardir))


def do_delayed_imports():
global android_device
from mozrunner.devices import android_device
android_device.TOOLTOOL_PATH = os.path.join(os.path.dirname(__file__),
os.pardir,
"third_party",
"tooltool",
"tooltool.py")


def get_parser_install():
parser = argparse.ArgumentParser()
parser.add_argument("--reinstall", action="store_true", default=False,
Expand Down Expand Up @@ -103,6 +108,8 @@ def install_android_packages(logger, sdk_path, no_prompt=False):


def get_emulator(sdk_path):
if android_device is None:
do_delayed_imports()
if "ANDROID_SDK_ROOT" not in os.environ:
os.environ["ANDROID_SDK_ROOT"] = sdk_path
substs = {"top_srcdir": wpt_root, "TARGET_CPU": "x86"}
Expand Down

0 comments on commit 03011fb

Please sign in to comment.