[clang-tools-extra] r338518 - [clangd] Receive compilationDatabasePath in 'initialize' request

Alex L via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 1 12:49:04 PDT 2018


On 1 August 2018 at 11:21, Simon Marchi <simon.marchi at ericsson.com> wrote:

> On 2018-08-01 01:30 PM, Alex L wrote:
> > Is there a particular reason why this commit didn't have a corresponding
> test included?
> > Cheers,
> > Alex
>
> Back when we made the corresponding change in "onChangeConfiguration",
> there was no
> straightforward way to make a lit test for it:
>
> https://reviews.llvm.org/D39571?id=124024#inline-359345
>
> I am not sure, but I think the issue was that we had to hard-code the
> length of the
> messages we sent.  Since we had to use temp directory names, the length
> was not
> known in advance.  I don't think we have that limitation anymore.
>

Yes, I believe this limitation doesn't exist anymore.


>
> We would need to create a temporary directory hierarchy, and then refer to
> it in
> the messages we send to switch between build configurations.  Is it
> something that
> sounds possible with lit?  Do you know about other tests doing something
> similar?
>

I think it's be possible, albeit in a more complicated way than the regular
Clangd test. We just need to generate a new test file that we can give to
the Clangd from the included test file.

I think this kind of solution should work (*) :

First, you would create a temporary directory in lit:

RUN: rm -rf %t.dir
RUN: mkdir %t.dir
RUN: ... populate the temporary directory ...

Then, you would generate the input file (i.e. replace INPUT_DIR in the
original test with the temporary directory):

RUN: rm -rf %t.test
RUN: sed -e "s:INPUT_DIR:%t.dir:g" %s > %t.test

And then you can invoke the test:

RUN: clang -lit-test < %t.test | FileCheck -strict-whitespace %s

* The only problem might be JSON string encoding of the INPUT_DIR (i.e.
you'll generate a test file that contains "C:\\temp\foo" on Windows, which
would be invalid JSON string). You should be able to use 'sed' here as well
to fix this up.

Thanks,
Alex



>
> Thanks,
>
> Simon
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180801/6c7aaab5/attachment.html>


More information about the cfe-commits mailing list