From 815d2f11b3684e01ec4c455179691d344201ea2b Mon Sep 17 00:00:00 2001 From: Andrew Halberstadt Date: Mon, 17 Jun 2013 13:22:39 -0700 Subject: [PATCH] Bug 882461 - add mozbase packages to sys.path in automation, r=jhammel --- build/automation.py.in | 17 ++++++----------- testing/xpcshell/runxpcshelltests.py | 21 +++++++-------------- 2 files changed, 13 insertions(+), 25 deletions(-) diff --git a/build/automation.py.in b/build/automation.py.in index 29a57daeeb72f..f3d75590cbed9 100644 --- a/build/automation.py.in +++ b/build/automation.py.in @@ -30,17 +30,12 @@ import automationutils here = os.path.dirname(__file__) mozbase = os.path.realpath(os.path.join(os.path.dirname(here), 'mozbase')) -try: - import mozcrash -except: - deps = ['mozcrash', - 'mozfile', - 'mozlog'] - for dep in deps: - module = os.path.join(mozbase, dep) - if module not in sys.path: - sys.path.append(module) - import mozcrash +if os.path.isdir(mozbase): + for package in os.listdir(mozbase): + sys.path.append(os.path.join(mozbase, package)) + +import mozcrash + # --------------------------------------------------------------- _DEFAULT_PREFERENCE_FILE = os.path.join(SCRIPT_DIR, 'prefs_general.js') diff --git a/testing/xpcshell/runxpcshelltests.py b/testing/xpcshell/runxpcshelltests.py index 80b7f74e55dcf..43371aea6456c 100644 --- a/testing/xpcshell/runxpcshelltests.py +++ b/testing/xpcshell/runxpcshelltests.py @@ -11,7 +11,6 @@ from subprocess import Popen, PIPE, STDOUT from tempfile import mkdtemp, gettempdir from threading import Timer -import mozinfo import random import socket import time @@ -27,19 +26,13 @@ here = os.path.dirname(__file__) mozbase = os.path.realpath(os.path.join(os.path.dirname(here), 'mozbase')) -# hand enumerate our own deps -modules = [('mozcrash', ['mozcrash', 'mozfile', 'mozlog']), - ('manifestparser', ['manifestdestiny'])] - -for module, deps in modules: - try: - globals()[module] = __import__(module) - except ImportError: - for dep in deps: - module_path = os.path.join(mozbase, dep) - if module_path not in sys.path: - sys.path.append(module_path) - globals()[module] = __import__(module) +if os.path.isdir(mozbase): + for package in os.listdir(mozbase): + sys.path.append(os.path.join(mozbase, package)) + +import manifestparser +import mozcrash +import mozinfo # --------------------------------------------------------------- #TODO: replace this with json.loads when Python 2.6 is required.