[PATCH] D33059: Create an shared include directory for gtest helper functions

Chandler Carruth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 12 17:34:18 PDT 2017


chandlerc added a reviewer: rsmith.
chandlerc added a comment.

FYI, I chatted with Zach in person to understand why the directory layout was as complicated as it was. I really wanted to simplify it. However, my initial attempts broke cross-project usage as Richard Smith pointed out, and this is *exactly* the kind of thing that we will really want to share across LLVM projects: Both LLD and potentially Clang will want access to things like the error matching utilities for their unittests.

With that constraint in mind, I talked for a long time with Richard about the tradeoffs here. Our suggested approach is to be less inventive: testing libraries are, fundamentally, *just libraries*. We probably don't want to install them and it should be clear that they are for testing (and so shouldn't be used elsewhere and can carry more dependencies than would be acceptable elsewhere). But they're still libraries. We suggest the file layout:

  include/llvm/Testing/Support/Error.h
  lib/Testing/Support/Error.cpp

And then you could use it from `unittests/Support/FooTest.cpp` in the obvious way:

  #include "llvm/Testing/Support/Error.h"

This may be a bit controversial so it is worth making sure others are on board with this direction. The big thing that makes all of the other alternatives hard is ending up with a way for a Clang or LLD unittest to include a header for the `llvm/Support` or `llvm/CodeGen` testing utilities as well as their own `clang/Basic` or `clang/CodeGen` (see what I did there?) without confusion or in the latter case, a flat ambiguity.

An alternative if people are strongly opposed to just treating this like any other collection of LLVM libraries would have the file layout like:

  utils/unittest/llvm-testing/Support/Error.cpp
  utils/unittest/llvm-testing/Support/SupportHelpers.h

And then usage from `unittests/Support/FooTest.cpp` would look like:

  #include "llvm-testing/Support/Error.h"


https://reviews.llvm.org/D33059





More information about the llvm-commits mailing list