Skip to content

Commit 139f435

Browse files
Move CI to doctest instead of gtest
1 parent 122f282 commit 139f435

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1979
-2215
lines changed

.github/workflows/benchmark.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: benchmark & examples
22
on: [push, pull_request]
3-
concurrency:
3+
concurrency:
44
group: ${{ github.workflow }}-${{ github.job }}-${{ github.ref }}
55
cancel-in-progress: true
66
jobs:

.github/workflows/clang-format-check.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: clang-format
22
on: [push, pull_request]
3-
concurrency:
3+
concurrency:
44
group: ${{ github.workflow }}-${{ github.job }}-${{ github.ref }}
55
cancel-in-progress: true
66
jobs:
@@ -13,3 +13,4 @@ jobs:
1313
uses: jidicula/[email protected]
1414
with:
1515
clang-format-version: '13'
16+
exclude-regex: 'doctest.h'

.github/workflows/cross-sve.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- name: Setup
3232
run: |
3333
mkdir _build
34-
cd _build && cmake .. -GNinja -DDOWNLOAD_GTEST=ON -DBUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Release -DTARGET_ARCH=generic -DCMAKE_C_FLAGS="-march=armv8-a+sve -msve-vector-bits=${{ matrix.vector_bits }}" -DCMAKE_CXX_FLAGS="-march=armv8-a+sve -msve-vector-bits=${{ matrix.vector_bits }}" -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/.github/toolchains/gcc-aarch64-linux-gnu.cmake
34+
cd _build && cmake .. -GNinja -DBUILD_TESTS=ON -DDOWNLOAD_DOCTEST=ON -DCMAKE_BUILD_TYPE=Release -DTARGET_ARCH=generic -DCMAKE_C_FLAGS="-march=armv8-a+sve -msve-vector-bits=${{ matrix.vector_bits }}" -DCMAKE_CXX_FLAGS="-march=armv8-a+sve -msve-vector-bits=${{ matrix.vector_bits }}" -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/.github/toolchains/gcc-aarch64-linux-gnu.cmake
3535
- name: Build
3636
run: cmake --build _build
3737
- name: Testing xsimd

.github/workflows/cross.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Arm cross-compilation build
22
on: [push, pull_request]
3-
concurrency:
3+
concurrency:
44
group: ${{ github.workflow }}-${{ github.job }}-${{ github.ref }}
55
cancel-in-progress: true
66
jobs:
@@ -53,7 +53,7 @@ jobs:
5353
- name: Setup
5454
run: |
5555
mkdir _build
56-
cd _build && cmake .. -DDOWNLOAD_GTEST=ON -DBUILD_TESTS=ON -DBUILD_BENCHMARK=ON -DBUILD_EXAMPLES=ON -DCMAKE_BUILD_TYPE=Release -DTARGET_ARCH=generic -DCMAKE_C_FLAGS="-march=${{ matrix.target.arch }} ${{ matrix.target.flags }}" -DCMAKE_CXX_FLAGS="-march=${{ matrix.target.arch }} ${{ matrix.target.flags }}" -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/.github/toolchains/${{ matrix.sys.compiler }}-${{ matrix.target.dir }}.cmake
56+
cd _build && cmake .. -DBUILD_TESTS=ON -DDOWNLOAD_DOCTEST=ON -DBUILD_BENCHMARK=ON -DBUILD_EXAMPLES=ON -DCMAKE_BUILD_TYPE=Release -DTARGET_ARCH=generic -DCMAKE_C_FLAGS="-march=${{ matrix.target.arch }} ${{ matrix.target.flags }}" -DCMAKE_CXX_FLAGS="-march=${{ matrix.target.arch }} ${{ matrix.target.flags }}" -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/.github/toolchains/${{ matrix.sys.compiler }}-${{ matrix.target.dir }}.cmake
5757
- name: Build
5858
run: cmake --build _build
5959
- name: Testing xsimd

.github/workflows/cxx-versions.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: C++ compatibility build
22
on: [push, pull_request]
3-
concurrency:
3+
concurrency:
44
group: ${{ github.workflow }}-${{ github.job }}-${{ github.ref }}
55
cancel-in-progress: true
66
jobs:
@@ -13,11 +13,11 @@ jobs:
1313
- uses: actions/checkout@v2
1414
- name: Install dependencies
1515
run: |
16-
sudo apt install g++ cmake
16+
sudo apt install g++ cmake
1717
- name: Setup
1818
run: |
1919
mkdir _build
20-
cd _build && cmake .. -DDOWNLOAD_GTEST=ON -DBUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=${{matrix.cxx-version}}
20+
cd _build && cmake .. -DBUILD_TESTS=ON -DDOWNLOAD_DOCTEST=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=${{matrix.cxx-version}}
2121
- name: Build
2222
run: cmake --build _build
2323

.github/workflows/linux.yml

+4-8
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ jobs:
3939
sudo apt-get --no-install-suggests --no-install-recommends install gcc-$GCC_VERSION-multilib g++-$GCC_VERSION-multilib linux-libc-dev:i386
4040
fi
4141
CC=gcc-$GCC_VERSION
42-
echo "CC=$CC" >> $GITHUB_ENV
42+
echo "CC=$CC" >> $GITHUB_ENV
4343
CXX=g++-$GCC_VERSION
44-
echo "CXX=$CXX" >> $GITHUB_ENV
44+
echo "CXX=$CXX" >> $GITHUB_ENV
4545
- name: Setup compiler
4646
if: ${{ matrix.sys.compiler == 'clang' }}
4747
run: |
@@ -61,10 +61,7 @@ jobs:
6161
CC=clang-$LLVM_VERSION
6262
echo "CC=$CC" >> $GITHUB_ENV
6363
CXX=clang++-$LLVM_VERSION
64-
echo "CXX=$CXX" >> $GITHUB_ENV
65-
- name: Setup Ninja
66-
run: |
67-
sudo apt-get install ninja-build
64+
echo "CXX=$CXX" >> $GITHUB_ENV
6865
- name: Checkout xsimd
6966
uses: actions/checkout@v2
7067
- name: Install mamba
@@ -97,8 +94,7 @@ jobs:
9794
9895
mkdir _build
9996
cd _build
100-
cmake .. -DDOWNLOAD_GTEST=ON \
101-
-DBUILD_TESTS=ON \
97+
cmake .. -DBUILD_TESTS=ON \
10298
-DBUILD_BENCHMARK=ON \
10399
-DBUILD_EXAMPLES=ON \
104100
-DCMAKE_BUILD_TYPE=Release \

.github/workflows/macos.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: macOS build
22
on: [push, pull_request]
3-
concurrency:
3+
concurrency:
44
group: ${{ github.workflow }}-${{ github.job }}-${{ github.ref }}
55
cancel-in-progress: true
66
jobs:
@@ -17,7 +17,7 @@ jobs:
1717
- name: Setup
1818
run: |
1919
mkdir _build
20-
cd _build && cmake .. -DDOWNLOAD_GTEST=ON -DBUILD_TESTS=ON -DBUILD_BENCHMARK=ON -DBUILD_EXAMPLES=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"
20+
cd _build && cmake .. -DBUILD_TESTS=ON -DDOWNLOAD_DOCTEST=ON -DBUILD_BENCHMARK=ON -DBUILD_EXAMPLES=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"
2121
- name: Build
2222
run: cmake --build _build
2323
- name: Testing sequential

.github/workflows/windows.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Windows build
22
on: [push, pull_request]
3-
concurrency:
3+
concurrency:
44
group: ${{ github.workflow }}-${{ github.job }}-${{ github.ref }}
55
cancel-in-progress: true
66
jobs:
@@ -27,7 +27,7 @@ jobs:
2727
# On 2019 in _mm256_rsqrt_ps, on 2022 in _mm256_blend_p*
2828
- { sys: { set: AVX } }
2929
# On both platforms x86 + AVX512 triggers a compiler crash
30-
- { target: x86, sys: { set: AVX512 } }
30+
- { target: x86, sys: { set: AVX512 } }
3131
runs-on: windows-${{ matrix.os }}
3232
steps:
3333
- name: Setup compiler
@@ -43,7 +43,7 @@ jobs:
4343
- name: Setup
4444
run: |
4545
mkdir _build
46-
cd _build && cmake .. -DDOWNLOAD_GTEST=ON -DBUILD_TESTS=ON -DBUILD_BENCHMARK=ON -DBUILD_EXAMPLES=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="${{ matrix.sys.flags }}" -G Ninja
46+
cd _build && cmake .. -DBUILD_TESTS=ON -DDOWNLOAD_DOCTEST=ON -DBUILD_BENCHMARK=ON -DBUILD_EXAMPLES=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="${{ matrix.sys.flags }}" -G Ninja
4747
- name: Build
4848
run: |
4949
cd _build && cmake --build .
@@ -73,13 +73,14 @@ jobs:
7373
cc:p
7474
cmake:p
7575
ninja:p
76+
doctest:p
7677
- name: Checkout xsimd
7778
uses: actions/checkout@v2
7879
- name: Configure
7980
run: |
8081
mkdir _build
8182
cd _build
82-
cmake .. -DDOWNLOAD_GTEST=ON -DBUILD_TESTS=ON -DBUILD_BENCHMARK=ON -DBUILD_EXAMPLES=ON -DCMAKE_BUILD_TYPE=Release -G Ninja
83+
cmake .. -DBUILD_TESTS=ON -DBUILD_BENCHMARK=ON -DBUILD_EXAMPLES=ON -DCMAKE_BUILD_TYPE=Release -G Ninja
8384
- name: Build
8485
run: ninja -C _build
8586
- name: Test

CMakeLists.txt

-5
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,6 @@ endif()
9494

9595
OPTION(ENABLE_XTL_COMPLEX "enables support for xcomplex defined in xtl" OFF)
9696
OPTION(BUILD_TESTS "xsimd test suite" OFF)
97-
OPTION(DOWNLOAD_GTEST "build gtest from downloaded sources" OFF)
98-
99-
if(DOWNLOAD_GTEST OR GTEST_SRC_DIR)
100-
set(BUILD_TESTS ON)
101-
endif()
10297

10398
if(ENABLE_XTL_COMPLEX)
10499
add_definitions(-DXSIMD_ENABLE_XTL_COMPLEX=1)

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -179,15 +179,15 @@ void mean(const vector_type& a, const vector_type& b, vector_type& res)
179179

180180
## Building and Running the Tests
181181

182-
Building the tests requires the [GTest](https://github.com/google/googletest) testing framework and [cmake](https://cmake.org).
182+
Building the tests requires [cmake](https://cmake.org).
183183

184-
gtest and cmake are available as a packages for most linux distributions. Besides, they can also be installed with the `conda` package manager (even on windows):
184+
`cmake` is available as a package for most linux distributions. Besides, they can also be installed with the `conda` package manager (even on windows):
185185

186186
```bash
187-
conda install -c conda-forge gtest cmake
187+
conda install -c conda-forge cmake
188188
```
189189

190-
Once `gtest` and `cmake` are installed, you can build and run the tests:
190+
Once `cmake` is installed, you can build and run the tests:
191191

192192
```bash
193193
mkdir build

environment.yml

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ channels:
44
dependencies:
55
- ninja
66
- xtl
7+
- doctest

test/CMakeLists.txt

+31-44
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ string(TOUPPER "${CMAKE_BUILD_TYPE}" U_CMAKE_BUILD_TYPE)
3333

3434
OPTION(XSIMD_ENABLE_WERROR "Turn on -Werror" OFF)
3535

36+
37+
3638
################
3739
# ARM SETTINGS #
3840
################
@@ -65,10 +67,10 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU"
6567
endif()
6668

6769
if (NOT CROSS_COMPILE_ARM)
68-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fPIC")
70+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fPIC")
6971
endif()
7072
endif()
71-
73+
7274
if (ANDROID)
7375
# Nothing to do here, we assume the cmake Android NDK toolchain sets the
7476
# correct options for arm and neon.
@@ -120,47 +122,6 @@ if(CMAKE_CXX_COMPILER_ID MATCHES Clang AND MSVC AND WIN32) # We are using clang-
120122
set(CMAKE_EXE_LINKER_FLAGS /MANIFEST:NO)
121123
endif()
122124

123-
if(DOWNLOAD_GTEST OR GTEST_SRC_DIR)
124-
if(DOWNLOAD_GTEST)
125-
# Download and unpack googletest at configure time
126-
configure_file(downloadGTest.cmake.in googletest-download/CMakeLists.txt)
127-
else()
128-
# Copy local source of googletest at configure time
129-
configure_file(copyGTest.cmake.in googletest-download/CMakeLists.txt)
130-
endif()
131-
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
132-
RESULT_VARIABLE result
133-
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
134-
if(result)
135-
message(FATAL_ERROR "CMake step for googletest failed: ${result}")
136-
endif()
137-
execute_process(COMMAND ${CMAKE_COMMAND} --build .
138-
RESULT_VARIABLE result
139-
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
140-
if(result)
141-
message(FATAL_ERROR "Build step for googletest failed: ${result}")
142-
endif()
143-
144-
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
145-
146-
# Add googletest directly to our build. This defines
147-
# the gtest and gtest_main targets.
148-
add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src
149-
${CMAKE_CURRENT_BINARY_DIR}/googletest-build EXCLUDE_FROM_ALL)
150-
151-
set(GTEST_INCLUDE_DIRS "${gtest_SOURCE_DIR}/include")
152-
add_library(GTest::GTest INTERFACE IMPORTED)
153-
target_link_libraries(GTest::GTest INTERFACE gtest)
154-
add_library(GTest::Main INTERFACE IMPORTED)
155-
target_link_libraries(GTest::Main INTERFACE gtest_main)
156-
else()
157-
find_package(GTest REQUIRED)
158-
endif()
159-
160-
find_package(Threads)
161-
162-
include_directories(${GTEST_INCLUDE_DIRS})
163-
164125
set(XSIMD_TESTS
165126
main.cpp
166127
test_api.cpp
@@ -204,8 +165,32 @@ if(NOT MSVC)
204165
endif()
205166

206167
add_executable(test_xsimd ${XSIMD_TESTS} ${XSIMD_HEADERS})
207-
target_link_libraries(test_xsimd xsimd GTest::GTest GTest::Main ${CMAKE_THREAD_LIBS_INIT})
208168
target_include_directories(test_xsimd PRIVATE ${XSIMD_INCLUDE_DIR})
169+
170+
option(XSIMD_DOWNLOAD_DOCTEST OFF)
171+
find_package(doctest QUIET)
172+
if (doctest_FOUND)
173+
set(DOCTEST_MINIMAL_VERSION 2.4.9)
174+
if (doctest_VERSION VERSION_LESS DOCTEST_MINIMAL_VERSION)
175+
message(FATAL_ERROR "Requires doctest >= ${DOCTEST_MINIMAL_VERSION}")
176+
endif()
177+
target_link_libraries(test_xsimd PRIVATE doctest::doctest)
178+
elseif(DOWNLOAD_DOCTEST)
179+
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/doctest")
180+
file(DOWNLOAD
181+
"https://github.com/doctest/doctest/releases/download/v2.4.9/doctest.h"
182+
"${CMAKE_CURRENT_BINARY_DIR}/doctest/doctest.h")
183+
target_include_directories(test_xsimd PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
184+
else()
185+
message(FATAL_ERROR "
186+
Cannot find required doctest component.
187+
Please either set CMAKE_PREFIX_PATH to the location of doctestConfig.cmake,
188+
or set DOWNLOAD_DOCTEST=ON")
189+
endif()
190+
191+
if(ENABLE_XTL_COMPLEX)
192+
target_include_directories(test_xsimd PRIVATE ${xtl_INCLUDE_DIRS})
193+
endif()
209194
add_test(NAME test_xsimd COMMAND test_xsimd)
210195

211196
if(DEFINED XSIMD_FORCE_X86_INSTR_SET)
@@ -237,3 +222,5 @@ endif()
237222
if (XSIMD_ENABLE_WERROR)
238223
target_compile_options(test_xsimd PRIVATE -Werror -Wall -DXSIMD_SKIP_ON_WERROR)
239224
endif()
225+
226+

test/copyGTest.cmake.in

-25
This file was deleted.

test/downloadGTest.cmake.in

-26
This file was deleted.

test/main.cpp

+2-7
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,5 @@
99
* The full license is in the file LICENSE, distributed with this software. *
1010
****************************************************************************/
1111

12-
#include "gtest/gtest.h"
13-
14-
int main(int argc, char* argv[])
15-
{
16-
::testing::InitGoogleTest(&argc, argv);
17-
return RUN_ALL_TESTS();
18-
}
12+
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
13+
#include "doctest/doctest.h"

0 commit comments

Comments
 (0)