[Workflow] Try to fix code-formatter failing to find changes in some cases.
[llvm-project.git] / lldb / scripts / use_lldb_suite.py
blob6388d87b181ce03f97c79650aaf846878b21d4bc
1 import inspect
2 import os
3 import sys
6 def find_lldb_root():
7 lldb_root = os.path.dirname(inspect.getfile(inspect.currentframe()))
8 while True:
9 parent = os.path.dirname(lldb_root)
10 if parent == lldb_root: # dirname('/') == '/'
11 raise Exception("use_lldb_suite_root.py not found")
12 lldb_root = parent
14 test_path = os.path.join(lldb_root, "use_lldb_suite_root.py")
15 if os.path.isfile(test_path):
16 return lldb_root
19 lldb_root = find_lldb_root()
20 import imp
22 fp, pathname, desc = imp.find_module("use_lldb_suite_root", [lldb_root])
23 try:
24 imp.load_module("use_lldb_suite_root", fp, pathname, desc)
25 finally:
26 if fp:
27 fp.close()