llvm.org GIT mirror llvm / 5988879
lit: Provide file location in cfg error messages Python doesn't do a good job at diagnosing string exec() so use execfile() where available. This should be a timesaver when trying to get to the bottom of build bot failures. Before: File "llvm/utils/lit/lit/TestingConfig.py", line 93, in load_from_path exec("exec data in cfg_globals") File "<string>", line 1, in <module> File "<string>", line 194, in <module> NameError: name 'typo' is not defined After: File "llvm/utils/lit/lit/TestingConfig.py", line 95, in load_from_path execfile(path, cfg_globals) File "clang/test/lit.cfg", line 194, in <module> typo ^~~~ NameError: name 'typo' is not defined git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198766 91177308-0d34-0410-b5e6-96231b3b80d8 Alp Toker 5 years ago
1 changed file(s) with 11 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
0 import os
11 import sys
22
3 PY2 = sys.version_info[0] < 3
3 OldPy = sys.version_info[0] == 2 and sys.version_info[1] < 6
44
55 class TestingConfig:
66 """"
7373 """
7474
7575 # Load the config script data.
76 f = open(path)
77 try:
78 data = f.read()
79 except:
80 litConfig.fatal('unable to load config file: %r' % (path,))
81 f.close()
76 data = None
77 if OldPy:
78 f = open(path)
79 try:
80 data = f.read()
81 except:
82 litConfig.fatal('unable to load config file: %r' % (path,))
83 f.close()
8284
8385 # Execute the config script to initialize the object.
8486 cfg_globals = dict(globals())
8688 cfg_globals['lit_config'] = litConfig
8789 cfg_globals['__file__'] = path
8890 try:
89 if PY2:
91 if OldPy:
9092 exec("exec data in cfg_globals")
9193 else:
92 exec(data, cfg_globals)
94 execfile(path, cfg_globals)
9395 if litConfig.debug:
9496 litConfig.note('... loaded config %r' % path)
9597 except SystemExit: