Bug 1415618: Use path relative to mozharness config modules to find configs. r=jlund
MozReview-Commit-ID: 6D6QEz9ulYX
--- a/testing/mozharness/mozharness/base/config.py
+++ b/testing/mozharness/mozharness/base/config.py
@@ -130,28 +130,29 @@ class ReadOnlyDict(dict):
memo[id(self)] = result
for k, v in self.__dict__.items():
setattr(result, k, deepcopy(v, memo))
result._lock = False
for k, v in self.items():
result[k] = deepcopy(v, memo)
return result
+DEFAULT_CONFIG_PATH = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "configs")
+
# parse_config_file {{{1
def parse_config_file(file_name, quiet=False, search_path=None,
config_dict_name="config"):
"""Read a config file and return a dictionary.
"""
file_path = None
if os.path.exists(file_name):
file_path = file_name
else:
if not search_path:
- search_path = ['.', os.path.join(sys.path[0], '..', 'configs'),
- os.path.join(sys.path[0], '..', '..', 'configs')]
+ search_path = ['.', DEFAULT_CONFIG_PATH]
for path in search_path:
if os.path.exists(os.path.join(path, file_name)):
file_path = os.path.join(path, file_name)
break
else:
raise IOError("Can't find %s in %s!" % (file_name, search_path))
if file_name.endswith('.py'):
global_dict = {}
--- a/testing/mozharness/mozharness/mozilla/building/buildbase.py
+++ b/testing/mozharness/mozharness/mozilla/building/buildbase.py
@@ -21,17 +21,17 @@ import copy
import glob
import shlex
from itertools import chain
# import the power of mozharness ;)
import sys
from datetime import datetime
import re
-from mozharness.base.config import BaseConfig, parse_config_file
+from mozharness.base.config import BaseConfig, parse_config_file, DEFAULT_CONFIG_PATH
from mozharness.base.log import ERROR, OutputParser, FATAL
from mozharness.base.script import PostScriptRun
from mozharness.base.vcs.vcsbase import MercurialScript
from mozharness.mozilla.buildbot import (
BuildbotMixin,
EXIT_STATUS_DICT,
TBPL_STATUS_DICT,
TBPL_EXCEPTION,
@@ -395,18 +395,17 @@ class BuildingConfig(BaseConfig):
# noinspection PyUnusedLocal
class BuildOptionParser(object):
# TODO add nosetests for this class
platform = None
bits = None
config_file_search_path = [
- '.', os.path.join(sys.path[0], '..', 'configs'),
- os.path.join(sys.path[0], '..', '..', 'configs')
+ DEFAULT_CONFIG_PATH,
]
# add to this list and you can automagically do things like
# --custom-build-variant-cfg asan
# and the script will pull up the appropriate path for the config
# against the current platform and bits.
# *It will warn and fail if there is not a config for the current
# platform/bits