Skip to content

Commit

Permalink
tests: stop using boost tests
Browse files Browse the repository at this point in the history
  • Loading branch information
james-d-mitchell committed Oct 24, 2023
1 parent d5beea9 commit 0678b00
Show file tree
Hide file tree
Showing 8 changed files with 1,791 additions and 1,731 deletions.
52 changes: 52 additions & 0 deletions etc/test-renumber.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash
set -e

bold() {
printf "\033[1m%s\033[0m\n" "$*"
}

re='^[0-9]+$'

if [[ $# -ne 1 && $# -ne 2 ]]; then
bold "error expected 1 or 2 arguments, got $#!"
exit 1
elif [[ ! -f $1 ]]; then
bold "Error, expected a file as first argument, $1 is not a file!"
exit 1
elif [[ $# -eq 2 && ! $2 =~ $re ]]; then
bold "Error, expected a positive integer as second argument, $2 is not a positive integer!"
exit 1
fi

if [[ $# -eq 2 ]]; then
export START="$2"
else
export START=0
fi

FNAME="$1" python3 - <<END
import os, re, sys
p1 = re.compile(r'\[\d\d\d\]')
p2 = re.compile(r'(TEST_CASE|TEST_AGREES)')
lines = []
fnam = os.environ['FNAME']
start = int(os.environ['START'])
with open(fnam, 'r') as f:
lines = f.readlines()
prev1 = ''
prev2 = ''
nr = start
for i in range(len(lines)):
if p1.search(lines[i]) and (p2.search(lines[i]) or p2.search(prev1) or p2.search(prev2)):
lines[i] = re.sub(p1, f'[{str(nr).zfill(3)}]', lines[i])
nr += 1
prev2 = prev1
prev1 = lines[i]
print(f"{fnam}: {nr - start} tests renumbered")
print(f"{fnam}: next test number is {str(nr).zfill(3)}")
with open(os.environ['FNAME'], 'w') as f:
f.writelines(lines)
sys.exit(0)
END
32 changes: 20 additions & 12 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,42 @@
# http://www.gnu.org/licenses/ #
#****************************************************************************#

find_package(Catch2 3 REQUIRED)

message(STATUS "Building tests")
if(NOT Catch2_FOUND)
message(STATUS "Cloning Catch2 from GIT_REPOSITORY https://github.com/catchorg/Catch2.git")
Include(FetchContent)

FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.4.0 # or a later release
)

FetchContent_MakeAvailable(Catch2)
else()
message(STATUS "Using system Catch2")
endif()

find_package (Boost COMPONENTS unit_test_framework REQUIRED)
message(STATUS "Building tests")

include_directories ( ${Boost_INCLUDE_DIRS} )
include_directories(
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/include/fallback
${PROJECT_BINARY_DIR})

add_definitions (-DBOOST_TEST_DYN_LINK)

set(test_src
test_epu.cpp test_perm16.cpp test_perm_all.cpp test_bmat8.cpp)
foreach(f ${test_src})
get_filename_component(testName ${f} NAME_WE)
add_executable (${testName} ${f})
target_link_libraries(${testName} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} )
add_executable (${testName} ${f} test_main.cpp)
target_link_libraries(${testName} PRIVATE Catch2::Catch2WithMain)
endforeach(f)

# Test for multiple inclusions
add_executable (test_mincl test_mincl.cpp test_mincl0.cpp test_mincl1.cpp)
target_link_libraries(test_mincl ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} )
add_executable(test_all ${test_src} test_main.cpp)
target_link_libraries(test_all PRIVATE Catch2::Catch2WithMain)

add_test (TestEPU test_epu)
add_test (TestPerm16 test_perm16)
add_test (TestPermAll test_perm_all)
add_test (TestBMat8 test_bmat8)
add_test (TestMultIncl test_mincl)

Loading

0 comments on commit 0678b00

Please sign in to comment.