[PATCH] D44080: [XRay][compiler-rt] Make unit tests depend on implementation files

Dean Michael Berris via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 4 16:25:43 PST 2018


dberris created this revision.
dberris added reviewers: pelikan, kpw, nglevin.
Herald added a subscriber: mgorny.

This change makes changes to XRay implementation files trigger re-builds
of the unit tests. Prior to this change, the unit tests were not built
and run properly if the implementation files were changed during the
development process. This change forces the dependency on all files in
the XRay include and lib hosted files in compiler-rt.

Caveat is, that new files added to the director(ies) will need a re-run
of CMake to re-generate the fileset.

We think this is an OK compromise, since adding new files may
necessitate editing (or adding) new unit tests. It's also less likely
that we're adding new files without updating the CMake configuration to
include the functionality in the XRay runtime implementation anyway.


https://reviews.llvm.org/D44080

Files:
  compiler-rt/lib/xray/tests/CMakeLists.txt


Index: compiler-rt/lib/xray/tests/CMakeLists.txt
===================================================================
--- compiler-rt/lib/xray/tests/CMakeLists.txt
+++ compiler-rt/lib/xray/tests/CMakeLists.txt
@@ -3,6 +3,12 @@
 add_custom_target(XRayUnitTests)
 set_target_properties(XRayUnitTests PROPERTIES FOLDER "XRay unittests")
 
+# Create an XRAY_IMPL_FILES variable which will include all the implementation
+# files that are in the lib directory. Unfortunately, when new files are added
+# to the implementation, CMake must be run so that this variable is
+# re-generated.
+file(GLOB XRAY_IMPL_FILES "../*.cc" "../*.h")
+
 set(XRAY_UNITTEST_CFLAGS
   ${XRAY_CFLAGS}
   ${COMPILER_RT_UNITTEST_CFLAGS}
@@ -24,6 +30,11 @@
       generate_compiler_rt_tests(TEST_OBJECTS
         XRayUnitTests "${testname}-${arch}-Test" "${arch}"
         SOURCES ${TEST_SOURCES} ${COMPILER_RT_GTEST_SOURCE}
+        # Note that any change in the implementations will cause all the unit
+        # tests to be re-built. This is by design, but may be cumbersome during
+        # the build/test cycle.
+        COMPILE_DEPS ${TEST_SOURCES} ${COMPILER_RT_GTEST_SOURCE}
+        ${XRAY_HEADERS} ${XRAY_IMPL_FILES}
         DEPS gtest xray llvm-xray
         CFLAGS ${XRAY_UNITTEST_CFLAGS}
         LINK_FLAGS -fxray-instrument


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44080.136945.patch
Type: text/x-patch
Size: 1311 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180305/a373512b/attachment.bin>


More information about the llvm-commits mailing list