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
--- 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()