[libc-commits] [libc] fb6faf4 - [libc] Improve the add_libc_test rule.

Siva Chandra Reddy via libc-commits libc-commits at lists.llvm.org
Thu May 4 11:53:21 PDT 2023


Author: Siva Chandra Reddy
Date: 2023-05-04T18:53:13Z
New Revision: fb6faf4798b1cb327e719898e2ea6eff7f597c49

URL: https://github.com/llvm/llvm-project/commit/fb6faf4798b1cb327e719898e2ea6eff7f597c49
DIFF: https://github.com/llvm/llvm-project/commit/fb6faf4798b1cb327e719898e2ea6eff7f597c49.diff

LOG: [libc] Improve the add_libc_test rule.

A target for the test named ${fq_target_name} has been added. It depends
on ${fq_target_name}.__unit__ and ${fq_target_name}.__hermetic__ as
relevant.

Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D149730

Added: 
    

Modified: 
    libc/cmake/modules/LLVMLibCTestRules.cmake

Removed: 
    


################################################################################
diff  --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake
index 4c1b143b6618..cb2e2a66ae4f 100644
--- a/libc/cmake/modules/LLVMLibCTestRules.cmake
+++ b/libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -705,10 +705,18 @@ function(add_libc_test test_name)
     "" # Multi-value arguments
     ${ARGN}
   )
+  get_fq_target_name(${test_name} fq_target_name)
+  if(LIBC_TEST_UNIT_TEST_ONLY AND LIBC_TEST_HERMETIC_TEST_ONLY)
+    message(FATAL_ERROR
+            "${fq_target_name}: Only one of UNIT_TEST_ONLY and HERMETIC_TEST_ONLY can be listed.")
+  endif()
+  add_custom_target(${fq_target_name})
   if(LIBC_ENABLE_UNITTESTS AND NOT LIBC_TEST_HERMETIC_TEST_ONLY)
     add_libc_unittest(${test_name}.__unit__ ${LIBC_TEST_UNPARSED_ARGUMENTS})
+    add_dependencies(${fq_target_name} ${fq_target_name}.__unit__)
   endif()
   if(LIBC_ENABLE_HERMETIC_TESTS AND NOT LIBC_TEST_UNIT_TEST_ONLY)
     add_libc_hermetic_test(${test_name}.__hermetic__ ${LIBC_TEST_UNPARSED_ARGUMENTS})
+    add_dependencies(${fq_target_name} ${fq_target_name}.__hermetic__)
   endif()
 endfunction(add_libc_test)


        


More information about the libc-commits mailing list