This commit is contained in:
Tom Hicks
2025-04-09 20:26:37 -07:00
parent 4a44495abc
commit 415bdfcd3c
2 changed files with 87 additions and 4 deletions

View File

@@ -136,11 +136,56 @@ jobs:
working-directory: ${{github.workspace}}/build working-directory: ${{github.workspace}}/build
run: cmake --build . --config ${{ matrix.build_type }} run: cmake --build . --config ${{ matrix.build_type }}
# Test # Test - Run directly instead of using ctest
- name: Test - name: Test (Unix)
if: runner.os != 'Windows'
working-directory: ${{github.workspace}}/build working-directory: ${{github.workspace}}/build
run: ctest -C ${{ matrix.build_type }} --output-on-failure run: |
echo "Running TinyTest tests directly..."
# Find the test executable
if [ -f "tinytest_test" ]; then
TEST_EXEC="./tinytest_test"
elif [ -f "tinytest_tests" ]; then
TEST_EXEC="./tinytest_tests"
elif [ -f "${{ matrix.build_type }}/tinytest_test" ]; then
TEST_EXEC="./${{ matrix.build_type }}/tinytest_test"
elif [ -f "${{ matrix.build_type }}/tinytest_tests" ]; then
TEST_EXEC="./${{ matrix.build_type }}/tinytest_tests"
else
echo "Cannot find test executable!"
exit 1
fi
# Run the test
$TEST_EXEC
# Test - for Windows
- name: Test (Windows)
if: runner.os == 'Windows'
working-directory: ${{github.workspace}}/build
shell: pwsh
run: |
Write-Host "Running TinyTest tests directly..."
# Find the test executable
$testExec = $null
if (Test-Path "tinytest_test.exe") {
$testExec = ".\tinytest_test.exe"
} elseif (Test-Path "tinytest_tests.exe") {
$testExec = ".\tinytest_tests.exe"
} elseif (Test-Path "${{ matrix.build_type }}\tinytest_test.exe") {
$testExec = ".\${{ matrix.build_type }}\tinytest_test.exe"
} elseif (Test-Path "${{ matrix.build_type }}\tinytest_tests.exe") {
$testExec = ".\${{ matrix.build_type }}\tinytest_tests.exe"
} else {
Write-Host "Cannot find test executable!"
exit 1
}
# Run the test
& $testExec
# Verify installation - simplified version that doesn't compile code # Verify installation - simplified version that doesn't compile code
build-and-install: build-and-install:
name: Installation Test name: Installation Test

View File

@@ -111,6 +111,9 @@ if(NOT TINYTEST_USE_SYSTEM_CPPUTILS)
set(CPPUTILS_ENABLE_TESTING OFF CACHE BOOL "Disable CPPUtils testing framework" FORCE) set(CPPUTILS_ENABLE_TESTING OFF CACHE BOOL "Disable CPPUtils testing framework" FORCE)
set(CPPUTILS_SKIP_GOOGLETEST ON CACHE BOOL "Disable Google Test fetching in CPPUtils" FORCE) set(CPPUTILS_SKIP_GOOGLETEST ON CACHE BOOL "Disable Google Test fetching in CPPUtils" FORCE)
# Define these globally to prevent any test registration
set(CMAKE_DISABLE_TESTING ON CACHE INTERNAL "")
FetchContent_Declare( FetchContent_Declare(
cpputils cpputils
GIT_REPOSITORY https://github.com/headhunter45/cpp-utils.git GIT_REPOSITORY https://github.com/headhunter45/cpp-utils.git
@@ -168,11 +171,36 @@ endif()
# Re-enable testing for TinyTest # Re-enable testing for TinyTest
set(BUILD_TESTING ON CACHE BOOL "Enable testing for TinyTest" FORCE) set(BUILD_TESTING ON CACHE BOOL "Enable testing for TinyTest" FORCE)
set(CMAKE_DISABLE_TESTING OFF CACHE INTERNAL "")
# Include testing support - AFTER cpputils is added # Include testing support - AFTER cpputils is added
include(CTest) include(CTest)
enable_testing() enable_testing()
# Clear all existing tests to avoid running CPPUtils tests
execute_process(
COMMAND ${CMAKE_COMMAND} -E echo "Removing any existing tests"
COMMAND ${CMAKE_CTEST_COMMAND} --force-new-ctest-process -N
OUTPUT_VARIABLE ALL_TESTS
)
file(WRITE "${CMAKE_BINARY_DIR}/CTestTestfile.cmake" "# CTest test file - Generated by CMake\n")
# Create a hook to explicitly remove any CPPUtils tests before running our own
file(WRITE "${CMAKE_BINARY_DIR}/RemoveCPPUtilsTests.cmake" [[
file(GLOB_RECURSE cpputils_ctests
"${CMAKE_BINARY_DIR}/_deps/cpputils-build/*/CTestTestfile.cmake"
"${CMAKE_BINARY_DIR}/_deps/cpputils-build/CTestTestfile.cmake"
)
foreach(ctest_file ${cpputils_ctests})
file(WRITE "${ctest_file}" "# CPPUtils tests disabled\n")
endforeach()
]])
# Execute the hook to remove CPPUtils tests
execute_process(
COMMAND ${CMAKE_COMMAND} -P "${CMAKE_BINARY_DIR}/RemoveCPPUtilsTests.cmake"
)
# TinyTest library - renamed to avoid conflicts # TinyTest library - renamed to avoid conflicts
add_library(tinytest_lib ${TINYTEST_LIBRARY_TYPE} add_library(tinytest_lib ${TINYTEST_LIBRARY_TYPE}
tinytest.cpp tinytest.cpp
@@ -271,6 +299,16 @@ if(BUILD_TESTING)
# Explicitly set the test list to prevent picking up other tests # Explicitly set the test list to prevent picking up other tests
set_property(GLOBAL PROPERTY TEST_INCLUDE_FILES "") set_property(GLOBAL PROPERTY TEST_INCLUDE_FILES "")
# Add a special label to our test so we can run only our tests
set_tests_properties(tinytest_test PROPERTIES LABELS "TinyTest")
# Update the root CTestTestfile.cmake to only include our test
file(WRITE "${CMAKE_BINARY_DIR}/CTestTestfile.cmake"
"# TinyTest test file - Generated by CMake\n"
"add_test(tinytest_test \"${CMAKE_BINARY_DIR}/tinytest_test\")\n"
"set_tests_properties(tinytest_test PROPERTIES LABELS \"TinyTest\")\n"
)
endif() endif()
endif() endif()