Use os.path.realpath(__file__) instead of os.path.abspath(__file__)
to get an absolute path pointing to the lit.site.cfg.py in the
build directory. That way one can symlink the generated
lit.site.cfg.py file into the source directory and run lit seamlessly
on individual files.
Before:
$ ln -s .../build/llvm-project/tools/clang/test/lit.site.cfg.py $ lit --debug Index/cxx17-structured-binding.cpp lit: .../lit/discovery.py:63: note: loading suite config '.../src/llvm-project/clang/test/lit.site.cfg.py' ... lit: .../lit/LitConfig.py:115: note: load_config from '.../llvm-project/clang/test/lit.cfg.py' lit: .../lit/TestingConfig.py:100: fatal: unable to parse config file '.../src/llvm-project/clang/test/lit.site.cfg.py', traceback: Traceback (most recent call last): File ".../lit/TestingConfig.py", line 89, in load_from_path exec(compile(data, path, 'exec'), cfg_globals, None) File ".../src/llvm-project/clang/test/lit.site.cfg.py", line 64, in <module> lit_config.load_config( File ".../lit/LitConfig.py", line 116, in load_config config.load_from_path(path, self) File ".../lit/TestingConfig.py", line 76, in load_from_path f = open(path) FileNotFoundError: [Errno 2] No such file or directory: '.../src/llvm-project/clang/test/lit.cfg.py'
After:
$ ln -s .../build/llvm-project/tools/clang/test/lit.site.cfg.py $ lit --debug Index/cxx17-structured-binding.cpp lit: .../lit/discovery.py:63: note: loading suite config '.../src/llvm-project/clang/test/lit.site.cfg.py' ... lit: .../lit/llvm/config.py:342: note: using clang: .../build/llvm-project/bin/clang ... -- Testing: 1 tests, 1 workers -- ...