Skip to content

Commit

Permalink
Improve lit testing scripts.
Browse files Browse the repository at this point in the history
- Let `check-llvm-dialects-lit` depend on the `llvm-dialects-test-depends` custom target
- Convert `add_dialects_unit_test` to a macro
  • Loading branch information
Thomas Symalla committed May 23, 2024
1 parent 28eac73 commit c11f6ba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
7 changes: 3 additions & 4 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
##
#######################################################################################################################
#
# Copyright (c) 2020-2023 Advanced Micro Devices, Inc. All Rights Reserved.
# Copyright (c) 2020-2024 Advanced Micro Devices, Inc. All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -42,10 +42,9 @@ configure_lit_site_cfg(

add_lit_testsuite(check-llvm-dialects-lit "Running the llvm-dialects regression tests"
${CMAKE_CURRENT_BINARY_DIR}
${exclude_from_check_all}
DEPENDS ${LLVM_DIALECTS_TEST_DEPENDS}
${EXCLUDE_FROM_CHECK_ALL}
DEPENDS llvm-dialects-test-depends
)
set_target_properties(check-llvm-dialects-lit PROPERTIES FOLDER "Tests")

add_lit_testsuites(LLVM_DIALECTS ${CMAKE_CURRENT_SOURCE_DIR}
${exclude_from_check_all}
Expand Down
11 changes: 8 additions & 3 deletions test/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ llvm_map_components_to_libnames(llvm_libs Support Core)
set(DIALECTS_UNIT_TEST_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(DIALECTS_UNIT_TEST_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})

function(add_dialects_unit_test test_folder)
# Define test suite, link each test suite to llvm_dialects
macro(add_dialects_unit_test test_folder)
add_unittest(DialectsUnitTests ${test_folder} ${ARGN})
target_link_libraries(${test_folder} PRIVATE ${llvm_libs} llvm_dialects)

Expand All @@ -20,10 +21,9 @@ function(add_dialects_unit_test test_folder)
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../dialect
${CMAKE_CURRENT_BINARY_DIR}/../dialect)
endfunction()
endmacro()

add_subdirectory(dialect)
add_subdirectory(interface)

# Let lit discover the GTest tests
configure_lit_site_cfg(
Expand All @@ -33,7 +33,12 @@ configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
)

# Define the actual testing target. The tests are added in interface/.
add_lit_testsuite(check-llvm-dialects-units "Running the llvm-dialects unit tests"
${CMAKE_CURRENT_SOURCE_DIR}
${EXCLUDE_FROM_CHECK_ALL}
DEPENDS TestDialectTableGen DialectsUnitTests)

add_subdirectory(interface)

set_target_properties(check-llvm-dialects-units PROPERTIES FOLDER "Tests")

0 comments on commit c11f6ba

Please sign in to comment.