From af723fa23726f1a083599110d3043e0e943a3e91 Mon Sep 17 00:00:00 2001 From: Tom Prince Date: Tue, 14 Nov 2017 15:15:56 -0700 Subject: [PATCH] Bug 1415618: Allow specifying extra paths to search for config files mozharness. r=jlund MozReview-Commit-ID: 3xkUaDwYB6v --HG-- extra : rebase_source : e80f0f20213e76ee68e62757eab8c788b7d398c6 extra : source : 780f67a36d6d91d4ee35070dc7f8d8c598106929 --- testing/mozharness/mozharness/base/config.py | 9 ++++++++- .../mozharness/mozilla/building/buildbase.py | 11 +++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/testing/mozharness/mozharness/base/config.py b/testing/mozharness/mozharness/base/config.py index df2b8896732b..15fc275475d7 100644 --- a/testing/mozharness/mozharness/base/config.py +++ b/testing/mozharness/mozharness/base/config.py @@ -280,6 +280,10 @@ class BaseConfig(object): type="string", default=os.getcwd(), help="Specify the absolute path of the parent of the working directory" ) + self.config_parser.add_option( + "--extra-config-path", action='extend', dest="config_paths", + type="string", help="Specify additional paths to search for config files.", + ) self.config_parser.add_option( "-c", "--config-file", "--cfg", action="extend", dest="config_files", type="string", help="Specify a config file; can be repeated" @@ -433,6 +437,7 @@ class BaseConfig(object): way that self.config is made up. See `mozharness.mozilla.building.buildbase.BuildingConfig` for an example. """ + config_paths = options.config_paths or ['.'] all_cfg_files_and_dicts = [] for cf in all_config_files: try: @@ -444,7 +449,9 @@ class BaseConfig(object): (file_path, parse_config_file(file_path, search_path=["."])) ) else: - all_cfg_files_and_dicts.append((cf, parse_config_file(cf))) + all_cfg_files_and_dicts.append( + (cf, parse_config_file(cf, search_path=config_paths + [DEFAULT_CONFIG_PATH])) + ) except Exception: if cf in options.opt_config_files: print( diff --git a/testing/mozharness/mozharness/mozilla/building/buildbase.py b/testing/mozharness/mozharness/mozilla/building/buildbase.py index 5acc96a63953..cc1cd4edb61b 100755 --- a/testing/mozharness/mozharness/mozilla/building/buildbase.py +++ b/testing/mozharness/mozharness/mozilla/building/buildbase.py @@ -399,9 +399,6 @@ class BuildOptionParser(object): # TODO add nosetests for this class platform = None bits = None - config_file_search_path = [ - DEFAULT_CONFIG_PATH, - ] # add to this list and you can automagically do things like # --custom-build-variant-cfg asan @@ -521,9 +518,15 @@ class BuildOptionParser(object): # now let's see if we were given a valid pathname valid_variant_cfg_path = value else: + # FIXME: We should actually wait until we have parsed all arguments + # before looking at this, otherwise the behavior will depend on the + # order of arguments. But that isn't a problem as long as --extra-config-path + # is always passed first. + extra_config_paths = parser.values.config_paths or [] + config_paths = extra_config_paths + [DEFAULT_CONFIG_PATH] # let's take our prospective_cfg_path and see if we can # determine an existing file - for path in cls.config_file_search_path: + for path in config_paths: if os.path.exists(os.path.join(path, prospective_cfg_path)): # success! we found a config file valid_variant_cfg_path = os.path.join(path,