Skip to content

Commit

Permalink
Add CTest testsuite
Browse files Browse the repository at this point in the history
  • Loading branch information
tbeu committed Oct 23, 2024
1 parent ca4750b commit 5e95967
Show file tree
Hide file tree
Showing 57 changed files with 41,385 additions and 551 deletions.
61 changes: 15 additions & 46 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 5
submodules: recursive
- name: Setup python environment
uses: actions/setup-python@v5
with:
Expand All @@ -59,13 +60,13 @@ jobs:
echo "/Users/runner/Library/Python/${{ matrix.python-version }}/bin" >> $GITHUB_PATH
fi
if [ "${{ matrix.compiler }}" == "msvc" ]; then
cmake -S . -B build -DMATIO_USE_CONAN=ON -DMATIO_SHARED=OFF
cmake -S . -B build -DMATIO_USE_CONAN=ON -DMATIO_SHARED=OFF -DBUILD_TESTING=ON
elif [ "${{ matrix.compiler }}" == "mingw" ]; then
cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DMATIO_USE_CONAN=ON -DMATIO_SHARED=OFF -DMATIO_ENABLE_CPPCHECK=ON -G "MinGW Makefiles"
cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DMATIO_USE_CONAN=ON -DMATIO_SHARED=OFF -DBUILD_TESTING=ON -DMATIO_ENABLE_CPPCHECK=ON -G "MinGW Makefiles"
elif [ "${{ matrix.compiler }}" == "gcc" ]; then
cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DMATIO_USE_CONAN=ON -DMATIO_SHARED=OFF -DMATIO_ENABLE_CPPCHECK=ON
cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DMATIO_USE_CONAN=ON -DMATIO_SHARED=OFF -DBUILD_TESTING=ON -DMATIO_ENABLE_CPPCHECK=ON
else
cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DMATIO_USE_CONAN=ON -DMATIO_SHARED=OFF
cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DMATIO_USE_CONAN=ON -DMATIO_SHARED=OFF -DBUILD_TESTING=ON
fi
- name: Build with ${{ matrix.compiler }}
run: |
Expand All @@ -75,19 +76,7 @@ jobs:
cmake --build build -- -j8
fi
- name: Test
run: |
if [ "${{ matrix.compiler }}" == "msvc" ]; then
MATDUMP="./build/Release/matdump.exe"
else
MATDUMP="./build/bin/matdump"
fi
for file in ./share/*.mat; do
"$MATDUMP" -d "$file" d
"$MATDUMP" -v "$file"
"$MATDUMP" -v -f whos "$file"
done
"$MATDUMP" -v -H
"$MATDUMP" -V
run: ctest --no-tests=error --output-on-failure --test-dir build --build-config ${{ matrix.configuration }} --verbose

build-openbsd:
name: openbsd-clang
Expand All @@ -97,6 +86,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 5
submodules: recursive
- name: Test with clang
uses: vmactions/openbsd-vm@v1
with:
Expand All @@ -107,17 +97,9 @@ jobs:
pkg_add cmake
run: |
set -e
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DMATIO_SHARED=OFF -DMATIO_MAT73=OFF
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DMATIO_SHARED=OFF -DMATIO_MAT73=OFF -DBUILD_TESTING=ON
cmake --build build -- -j8
./build/test_snprintf
./build/test_mat -H
./build/test_mat -L
./build/test_mat -V
./build/matdump -v -H
./build/matdump -V
./build/matdump -d ./share/test_file.mat structure
./build/matdump -v ./share/test_file.mat
./build/matdump -v -f whos ./share/test_file.mat
ctest --no-tests=error --output-on-failure --test-dir build --build-config ${{ matrix.configuration }} --verbose
build-solaris:
name: solaris-gcc
Expand All @@ -127,6 +109,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 5
submodules: recursive
- name: Test with gcc
uses: vmactions/solaris-vm@v1
with:
Expand All @@ -139,17 +122,9 @@ jobs:
run: |
set -e
mkdir build
cmake -S . -Bbuild -DCMAKE_BUILD_TYPE=Release -DMATIO_SHARED=OFF -DMATIO_MAT73=OFF
cmake -S . -Bbuild -DCMAKE_BUILD_TYPE=Release -DMATIO_SHARED=OFF -DMATIO_MAT73=OFF -DBUILD_TESTING=ON
cmake --build build -- -j8
./build/test_snprintf
./build/test_mat -H
./build/test_mat -L
./build/test_mat -V
./build/matdump -v -H
./build/matdump -V
./build/matdump -d ./share/test_file.mat structure
./build/matdump -v ./share/test_file.mat
./build/matdump -v -f whos ./share/test_file.mat
ctest --no-tests=error --output-on-failure --test-dir build --build-config ${{ matrix.configuration }} --verbose
build-cygwin:
name: windows-cygwin
Expand All @@ -161,6 +136,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 5
submodules: recursive
- name: Setup cygwin
uses: cygwin/cygwin-install-action@master
with:
Expand All @@ -175,7 +151,7 @@ jobs:
- name: Configure
run: |
export PATH=/usr/bin:$PATH
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -G Ninja
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -G Ninja
shell: C:\cygwin\bin\bash.exe -eo pipefail -o igncr '{0}'
env:
CYGWIN_NOWINPATH: 1
Expand All @@ -185,12 +161,5 @@ jobs:
cmake --build build -- -j8
shell: C:\cygwin\bin\bash.exe -eo pipefail -o igncr '{0}'
- name: Test
run: |
for file in ./share/*.mat; do
./build/matdump -d "$file" d
./build/matdump -v "$file"
./build/matdump -v -f whos "$file"
done
./build/matdump -v -H
./build/matdump -V
run: ctest --no-tests=error --output-on-failure --test-dir build --build-config ${{ matrix.configuration }} --verbose
shell: C:\cygwin\bin\bash.exe -eo pipefail -o igncr '{0}'
7 changes: 7 additions & 0 deletions cmake/test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,10 @@ if(NOT HAVE_SNPRINTF OR UNIX)
${PROJECT_BINARY_DIR}/src
)
endif()

if(BUILD_TESTING)
file(GLOB CMAKE_TEST_FILES "${CMAKE_SOURCE_DIR}/test/ctests/*.cmake")
foreach(test_file ${CMAKE_TEST_FILES})
include(${test_file})
endforeach()
endif()
33 changes: 33 additions & 0 deletions test/ctests/cell_api.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Auto-generated CMake/CTest tests
enable_testing()


# Set cell array elements
if(True)
add_test(NAME cell_api_set_cell_array_elements_1
COMMAND $<TARGET_FILE:test_mat> cell_api_set -o cell_api_set_cell_array_elements_1_output.txt)
set_tests_properties(cell_api_set_cell_array_elements_1 PROPERTIES LABELS "read;api;cell;cell_api")
add_test(NAME cell_api_set_cell_array_elements_2
COMMAND ${CMAKE_COMMAND} -E compare_files --ignore-eol ${PROJECT_SOURCE_DIR}/test/results/cell_api_set.out cell_api_set_cell_array_elements_1_output.txt)
set_tests_properties(cell_api_set_cell_array_elements_2 PROPERTIES LABELS "diff;api;cell;cell_api")
endif()

# Linearly index cell array
if(True)
add_test(NAME cell_api_linearly_index_cell_array_1
COMMAND $<TARGET_FILE:test_mat> cell_api_getlinear -o cell_api_linearly_index_cell_array_1_output.txt)
set_tests_properties(cell_api_linearly_index_cell_array_1 PROPERTIES LABELS "read;api;cell;cell_api")
add_test(NAME cell_api_linearly_index_cell_array_2
COMMAND ${CMAKE_COMMAND} -E compare_files --ignore-eol ${PROJECT_SOURCE_DIR}/test/results/cell_api_getlinear.out cell_api_linearly_index_cell_array_1_output.txt)
set_tests_properties(cell_api_linearly_index_cell_array_2 PROPERTIES LABELS "diff;api;cell;cell_api")
endif()

# Index cell array via dimension slices
if(True)
add_test(NAME cell_api_index_cell_array_via_dimension_slices_1
COMMAND $<TARGET_FILE:test_mat> cell_api_getcells -o cell_api_index_cell_array_via_dimension_slices_1_output.txt)
set_tests_properties(cell_api_index_cell_array_via_dimension_slices_1 PROPERTIES LABELS "read;api;cell;cell_api")
add_test(NAME cell_api_index_cell_array_via_dimension_slices_2
COMMAND ${CMAKE_COMMAND} -E compare_files --ignore-eol ${PROJECT_SOURCE_DIR}/test/results/cell_api_getcells.out cell_api_index_cell_array_via_dimension_slices_1_output.txt)
set_tests_properties(cell_api_index_cell_array_via_dimension_slices_2 PROPERTIES LABELS "diff;api;cell;cell_api")
endif()
Loading

0 comments on commit 5e95967

Please sign in to comment.