[llvm-dev] [CMake] External File Dependencies for Unit Tests
James Henderson via llvm-dev
llvm-dev at lists.llvm.org
Mon Jun 24 02:18:53 PDT 2019
Hi Alex,
Not answering your question directly, but I'd highly recommend against
using CMake to bake the test outputs at the cmake step for several
different reasons:
1) If yaml2obj changes, you'd have to rerun cmake to see whether the new
version would cause the tests to fail. This is not the default, so could
easily lead to build-bot breakages.
2) It's not clear from your statement whether you're talking about lit
tests or gtest unit tests. If the former, there's no real precedence for
doing this. If the latter, you'd need to have your C++ code able to detect
the build output directory somehow, which feels like it would make the code
at least unclear, and at worst unusable.
3) In either case, if you wanted to change the test input, you'd need to
rerun CMake again, rather than it just working. Runnning CMake is not
cheap, especially on Windows for Visual Studio generators.
As Jordan has mentioned offline, and assuming you're talking about gtest,
you're probably better off just calling the corresponding library functions
to generate the object from YAML. Otherwise, just use yaml2obj directly.
If you want to explore your original suggestion further, and need help
doing so, you probably need to give a bit more context as to what you've
tried and what didn't work about it.
Regards,
James
On Sat, 22 Jun 2019 at 21:28, Alex Brachet-Mialot via llvm-dev <
llvm-dev at lists.llvm.org> wrote:
> Hi,
>
> I want to write unit tests for a project I am working on. I need to create
> object files, preferably I want to have yaml files in the source tree and
> have cmake generate object files using yaml2obj. Does anyone know what I
> would put in the CMakeLists.txt to get this behavior?
>
> For a concrete example if I didn’t explain clearly:
>
> In llvm/unittests/Object I would maybe have an Inputs directory, with a
> basic-obj.yaml. In llvm/unittests/Object I would want a test case which can
> open Inputs/basic-obj.o.
>
> Thanks,
> Alex
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190624/5fdcab5e/attachment.html>
More information about the llvm-dev
mailing list