Bug 1372697 - Add __file__ to locals in evaluated config file; r?glandium draft
authorGregory Szorc <gps@mozilla.com>
Tue, 13 Jun 2017 13:57:15 -0700
changeset 593522 ff417b5e669e2a8291be82ecdb1f717ee8fa5464
parent 593475 91134c95d68cbcfe984211fa3cbd28d610361ef1
child 593523 9577665fd7f4779e4f5e6986c3935cf4d30fe9cc
push id63733
push userbmo:gps@mozilla.com
push dateTue, 13 Jun 2017 20:57:48 +0000
reviewersglandium
bugs1372697
milestone56.0a1
Bug 1372697 - Add __file__ to locals in evaluated config file; r?glandium Currently, mozharness config files are executed with an empty globals and locals dict. I'm actually surprised the import mechanism works in this scenario. But whatever. I have evil plans to make use of __file__ in mozharness configs in a subsequent change. So let's introduce it. MozReview-Commit-ID: JAZZFkI6FhP
testing/mozharness/mozharness/base/config.py
--- a/testing/mozharness/mozharness/base/config.py
+++ b/testing/mozharness/mozharness/base/config.py
@@ -150,17 +150,17 @@ def parse_config_file(file_name, quiet=F
         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 = {}
-        local_dict = {}
+        local_dict = {'__file__': file_name}
         execfile(file_path, global_dict, local_dict)
         config = local_dict[config_dict_name]
     elif file_name.endswith('.json'):
         fh = open(file_path)
         config = {}
         json_config = json.load(fh)
         config = dict(json_config)
         fh.close()