Page MenuHomePhabricator

[lit] lit.site.cfg.py: support symlinked lit.site.cfg.py files
AbandonedPublic

Authored by milianw on Apr 15 2020, 8:25 AM.

Details

Reviewers
thakis
hans
Summary

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 --
...

Diff Detail

Event Timeline

milianw created this revision.Apr 15 2020, 8:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 15 2020, 8:25 AM
Herald added a subscriber: mgorny. · View Herald Transcript
milianw updated this revision to Diff 257732.Apr 15 2020, 8:26 AM

fixup commit message

milianw edited the summary of this revision. (Show Details)Apr 15 2020, 8:27 AM

Doesn't this Just Work if you just _not_ create that symlink?

% ../../out/gn/bin/llvm-lit Index/cxx11-lambdas.cpp
llvm-lit: /Users/thakis/src/llvm-project/llvm/utils/lit/lit/llvm/config.py:343: note: using clang: /Users/thakis/src/llvm-project/out/gn/bin/clang
llvm-lit: /Users/thakis/src/llvm-project/llvm/utils/lit/lit/util.py:408: note: using SDKROOT: u'/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk'
-- Testing: 1 tests, 1 workers --
PASS: Clang :: Index/cxx11-lambdas.cpp (1 of 1)

Testing Time: 1.03s
  Expected Passes: 1

nope, without the symlink I get:

lit Index/cxx11-lambdas.cpp 
lit: /home/milian/.local/lib/python3.8/site-packages/lit/TestingConfig.py:100: fatal: unable to parse config file '/home/milian/projects/src/llvm-project/clang/test/lit.cfg.py', traceback: Traceback (most recent call last):
  File "/home/milian/.local/lib/python3.8/site-packages/lit/TestingConfig.py", line 89, in load_from_path
    exec(compile(data, path, 'exec'), cfg_globals, None)
  File "/home/milian/projects/src/llvm-project/clang/test/lit.cfg.py", line 25, in <module>
    config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
AttributeError: 'NoneType' object has no attribute 'use_lit_shell'

Can you describe your setup a bit more? You're using an installed lit? Does it work if you use llvm-lit in your bin/ dir in your build dir?

I'm using lit 0.10.0 installed via pip 20.0.2 using python 3.8.2

source dir: /home/milian/projects/src/llvm-project
build dir: /home/milian/projects/build/llvm-project

it indeed works fine with llvm-lit. why is that not installed?

It's build config dependent. Is there an advantage to using pip-installed lit vs the lit in the build dir (which trampolines to the one in the source dir)?

If this patch here fixes a problem for you, I don't have a problem with landing this, but your setup seems a bit uncommon to me and you might run into fewer problems over time if you use the setup that most folks seem to use.

with this patch I could just use the global lit and don't need to add the build dir to my PATH. But, thinking about it, I can also symlink llvm-lit into a custom folder in my PATH and see if that works. If you don't want to merge this, I'll abandon it, please tell me if you would prefer it like that.

milianw abandoned this revision.May 15 2020, 1:53 AM