From f166c71e88d84a640eed1bc99535856f5baac95b Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Wed, 24 Mar 2021 21:18:49 +0300 Subject: add CTest tests --- .github/workflows/ci.yml | 23 +++-------------------- CMakeLists.txt | 2 ++ test/CMakeLists.txt | 2 ++ test/unit_tests/CMakeLists.txt | 2 ++ utils/CMakeLists.txt | 4 ++++ 5 files changed, 13 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5dc021c..0ba4227 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -70,25 +70,8 @@ jobs: with: name: 'pdb-repo-${{ matrix.os }}-${{ matrix.toolset }}-${{ matrix.platform }}-${{ matrix.configuration }}' path: '${{ runner.workspace }}/build/install/' - - name: Run unit tests - run: ../build/install/bin/test/unit_tests --log_level=all - if: runner.os == 'Windows' - - name: Run enum_symbols tests - run: ../build/install/bin/enum_symbols --pdb ../build/install/bin/test/test_lib.pdb --mask 'test_ns:*' - if: runner.os == 'Windows' - - name: Check enum_symbols output - run: | - $(../build/install/bin/enum_symbols --pdb ../build/install/bin/test/test_lib.pdb | Select-String -Pattern 'test_ns::baz' -SimpleMatch -Quiet) -or $(throw 'test_ns::baz not enumerated among the symbols') - $(../build/install/bin/enum_symbols --pdb ../build/install/bin/test/test_lib.pdb | Select-String -Pattern 'test_ns::bar' -SimpleMatch -Quiet) -or $(throw 'test_ns::bar not enumerated among the symbols') - $(../build/install/bin/enum_symbols --pdb ../build/install/bin/test/test_lib.pdb | Select-String -Pattern 'test_ns::foo' -SimpleMatch -Quiet) -or $(throw 'test_ns::foo not enumerated among the symbols') - $(../build/install/bin/enum_symbols --pdb ../build/install/bin/test/test_lib.pdb | Select-String -Pattern 'test_ns::var' -SimpleMatch -Quiet) -or $(throw 'test_ns::var not enumerated among the symbols') - if: runner.os == 'Windows' - - name: Run call_stack - run: ../build/install/bin/test/call_stack - if: runner.os == 'Windows' - - name: Check call_stack output + - name: Test run: | - $(../build/install/bin/test/call_stack | Select-String -Pattern '[test_lib!test_ns::baz' -SimpleMatch -Quiet) -or $(throw 'test_ns::baz not found in the call stack') - $(../build/install/bin/test/call_stack | Select-String -Pattern '[test_lib!test_ns::bar' -SimpleMatch -Quiet) -or $(throw 'test_ns::bar not found in the call stack') - $(../build/install/bin/test/call_stack | Select-String -Pattern '[test_lib!test_ns::foo' -SimpleMatch -Quiet) -or $(throw 'test_ns::foo not found in the call stack') + cd ../build/cmake + ctest -C '${{ env.CONFIGURATION }}' --verbose if: runner.os == 'Windows' diff --git a/CMakeLists.txt b/CMakeLists.txt index 326519b..f86a3a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.5) # for Boost::* imported targets project(pdb_repo CXX) +enable_testing() + if(MSVC) # This is an ugly hack to make the tests work. # With incremental linking, the &func address does not point to the diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8851856..d429bce 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -18,4 +18,6 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") install(FILES "$" DESTINATION bin/test OPTIONAL) endif() +add_test(NAME call_stack COMMAND call_stack) + add_subdirectory(unit_tests) diff --git a/test/unit_tests/CMakeLists.txt b/test/unit_tests/CMakeLists.txt index 1241061..90f8bed 100644 --- a/test/unit_tests/CMakeLists.txt +++ b/test/unit_tests/CMakeLists.txt @@ -8,3 +8,5 @@ install(TARGETS unit_tests RUNTIME DESTINATION bin/test) if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") install(FILES "$" DESTINATION bin/test OPTIONAL) endif() + +add_test(NAME unit_tests COMMAND unit_tests --log_level=all --no_color_output) diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index f724654..712a9e8 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -13,3 +13,7 @@ endfunction() add_util(enum_symbols enum_symbols.cpp command_line.hpp pdb_descr.hpp) add_util(name2addr name2addr.cpp) add_util(addr2name addr2name.cpp command_line.hpp pdb_descr.hpp) + +if(MSVC) + add_test(NAME enum_symbols COMMAND enum_symbols --pdb "$" --mask "test_ns:*") +endif() -- cgit v1.2.3