Skip to content

Commit da9e76e

Browse files
authored
✅ test single-header cib.hpp in addition to multi-header (#24)
resolves #16 generated single header cib.hpp is now tested in addition to the regular multi-header cib.hpp
1 parent 266512c commit da9e76e

File tree

3 files changed

+94
-71
lines changed

3 files changed

+94
-71
lines changed

.github/workflows/unit_tests.yml

Lines changed: 59 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -15,71 +15,73 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
include:
19-
- compiler: clang-14
20-
install: wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 14
21-
cc: " /usr/lib/llvm-14/bin/clang"
22-
cxx: "/usr/lib/llvm-14/bin/clang++"
23-
- compiler: clang-13
24-
install: wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 13
25-
cc: " /usr/lib/llvm-13/bin/clang"
26-
cxx: "/usr/lib/llvm-13/bin/clang++"
27-
- compiler: clang-12
28-
install: sudo apt update && sudo apt-get install -y clang-12
29-
cc: " /usr/lib/llvm-12/bin/clang"
30-
cxx: "/usr/lib/llvm-12/bin/clang++"
31-
- compiler: clang-11
32-
install: sudo apt update && sudo apt-get install -y clang-11
33-
cc: " /usr/lib/llvm-11/bin/clang"
34-
cxx: "/usr/lib/llvm-11/bin/clang++"
35-
- compiler: clang-10
36-
install: sudo apt update && sudo apt-get install -y clang-10
37-
cc: " /usr/lib/llvm-10/bin/clang"
38-
cxx: "/usr/lib/llvm-10/bin/clang++"
39-
- compiler: clang-9
40-
install: sudo apt update && sudo apt-get install -y clang-9
41-
cc: " /usr/lib/llvm-9/bin/clang"
42-
cxx: "/usr/lib/llvm-9/bin/clang++"
43-
- compiler: clang-8
44-
install: sudo apt update && sudo apt-get install -y clang-8
45-
cc: " /usr/lib/llvm-8/bin/clang"
46-
cxx: "/usr/lib/llvm-8/bin/clang++"
47-
- compiler: clang-7
48-
install: sudo apt update && sudo apt-get install -y clang-7
49-
cc: " /usr/lib/llvm-7/bin/clang"
50-
cxx: "/usr/lib/llvm-7/bin/clang++"
51-
- compiler: gcc-11
52-
install: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && sudo apt update && sudo apt-get install -y gcc-11 g++-11
53-
cc: "/usr/bin/gcc-11"
54-
cxx: "/usr/bin/g++-11"
55-
- compiler: gcc-10
56-
install: sudo apt update && sudo apt-get install -y gcc-10
57-
cc: "/usr/bin/gcc-10"
58-
cxx: "/usr/bin/g++-10"
59-
- compiler: gcc-9
60-
install: sudo apt update && sudo apt-get install -y gcc-9
61-
cc: "/usr/bin/gcc-9"
62-
cxx: "/usr/bin/g++-9"
63-
- compiler: gcc-8
64-
install: sudo apt update && sudo apt-get install -y gcc-8 g++-8
65-
cc: "/usr/bin/gcc-8"
66-
cxx: "/usr/bin/g++-8"
18+
single_header: [0, 1]
19+
compiler:
20+
- name: clang-14
21+
install: wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 14
22+
cc: " /usr/lib/llvm-14/bin/clang"
23+
cxx: "/usr/lib/llvm-14/bin/clang++"
24+
- name: clang-13
25+
install: wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 13
26+
cc: " /usr/lib/llvm-13/bin/clang"
27+
cxx: "/usr/lib/llvm-13/bin/clang++"
28+
- name: clang-12
29+
install: sudo apt update && sudo apt-get install -y clang-12
30+
cc: " /usr/lib/llvm-12/bin/clang"
31+
cxx: "/usr/lib/llvm-12/bin/clang++"
32+
- name: clang-11
33+
install: sudo apt update && sudo apt-get install -y clang-11
34+
cc: " /usr/lib/llvm-11/bin/clang"
35+
cxx: "/usr/lib/llvm-11/bin/clang++"
36+
- name: clang-10
37+
install: sudo apt update && sudo apt-get install -y clang-10
38+
cc: " /usr/lib/llvm-10/bin/clang"
39+
cxx: "/usr/lib/llvm-10/bin/clang++"
40+
- name: clang-9
41+
install: sudo apt update && sudo apt-get install -y clang-9
42+
cc: " /usr/lib/llvm-9/bin/clang"
43+
cxx: "/usr/lib/llvm-9/bin/clang++"
44+
- name: clang-8
45+
install: sudo apt update && sudo apt-get install -y clang-8
46+
cc: " /usr/lib/llvm-8/bin/clang"
47+
cxx: "/usr/lib/llvm-8/bin/clang++"
48+
- name: clang-7
49+
install: sudo apt update && sudo apt-get install -y clang-7
50+
cc: " /usr/lib/llvm-7/bin/clang"
51+
cxx: "/usr/lib/llvm-7/bin/clang++"
52+
- name: gcc-11
53+
install: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && sudo apt update && sudo apt-get install -y gcc-11 g++-11
54+
cc: "/usr/bin/gcc-11"
55+
cxx: "/usr/bin/g++-11"
56+
- name: gcc-10
57+
install: sudo apt update && sudo apt-get install -y gcc-10
58+
cc: "/usr/bin/gcc-10"
59+
cxx: "/usr/bin/g++-10"
60+
- name: gcc-9
61+
install: sudo apt update && sudo apt-get install -y gcc-9
62+
cc: "/usr/bin/gcc-9"
63+
cxx: "/usr/bin/g++-9"
64+
- name: gcc-8
65+
install: sudo apt update && sudo apt-get install -y gcc-8 g++-8
66+
cc: "/usr/bin/gcc-8"
67+
cxx: "/usr/bin/g++-8"
6768

6869
steps:
6970
- uses: actions/checkout@v3
7071
with:
7172
submodules: recursive
7273

7374
- name: install compiler
74-
run: ${{ matrix.install }}
75+
run: ${{ matrix.compiler.install }}
7576

7677
- name: Configure CMake
7778
env:
78-
CC: ${{ matrix.cc }}
79-
CXX: ${{ matrix.cxx }}
79+
CC: ${{ matrix.compiler.cc }}
80+
CXX: ${{ matrix.compiler.cxx }}
81+
SINGLE_HEADER: ${{ matrix.single_header }}
8082
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
8183

82-
- name: Build
84+
- name: Build Unit Tests
8385
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -t tests
8486

8587
- name: Test
@@ -99,13 +101,15 @@ jobs:
99101

100102
- name: Build
101103
# Build your program with the given configuration
102-
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target release
104+
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target release_header
103105

104106
- name: 'Upload Artifact'
105107
uses: actions/upload-artifact@v3
106108
with:
107109
name: cib.hpp
108-
path: build/cib.hpp
110+
path: ${{github.workspace}}/build/include/cib/cib.hpp
111+
112+
109113

110114
performance_test:
111115
runs-on: ubuntu-latest

CMakeLists.txt

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,46 @@ add_subdirectory(lib/Catch2)
99
add_subdirectory(test)
1010
add_subdirectory(benchmark)
1111

12-
add_library(Cib INTERFACE)
13-
14-
target_include_directories(Cib
15-
INTERFACE
16-
${CMAKE_CURRENT_SOURCE_DIR}/include)
17-
18-
target_sources(Cib
19-
INTERFACE
20-
${CMAKE_CURRENT_SOURCE_DIR}/include/cib/cib.hpp)
21-
22-
2312
add_custom_command(
2413
DEPENDS
2514
${CMAKE_SOURCE_DIR}/tools/gen_release_header.py
2615
${CMAKE_SOURCE_DIR}/include/cib/*
2716
${CMAKE_SOURCE_DIR}/include/cib/detail/*
2817
COMMAND
29-
python3 ${CMAKE_SOURCE_DIR}/tools/gen_release_header.py ${CMAKE_SOURCE_DIR}/include/cib/cib.hpp > ${CMAKE_BINARY_DIR}/cib.hpp
18+
mkdir ${CMAKE_BINARY_DIR}/include/
19+
COMMAND
20+
mkdir ${CMAKE_BINARY_DIR}/include/cib/
21+
COMMAND
22+
python3 ${CMAKE_SOURCE_DIR}/tools/gen_release_header.py ${CMAKE_SOURCE_DIR}/include/cib/cib.hpp > ${CMAKE_BINARY_DIR}/include/cib/cib.hpp
3023
OUTPUT
31-
${CMAKE_BINARY_DIR}/cib.hpp
24+
${CMAKE_BINARY_DIR}/include/cib/cib.hpp
3225
)
3326

34-
add_custom_target(release
27+
add_custom_target(release_header
3528
DEPENDS
36-
${CMAKE_BINARY_DIR}/cib.hpp)
29+
${CMAKE_BINARY_DIR}/include/cib/cib.hpp)
30+
31+
32+
33+
add_library(Cib INTERFACE)
34+
35+
if ($ENV{SINGLE_HEADER})
36+
message("Using single-header version of cib.hpp.")
37+
38+
add_dependencies(Cib release_header)
39+
40+
target_include_directories(Cib
41+
INTERFACE
42+
${CMAKE_BINARY_DIR}/include/)
43+
44+
else()
45+
message("Using multi-header version of cib.hpp.")
46+
47+
target_include_directories(Cib
48+
INTERFACE
49+
${CMAKE_CURRENT_SOURCE_DIR}/include)
50+
51+
target_sources(Cib
52+
INTERFACE
53+
${CMAKE_CURRENT_SOURCE_DIR}/include/cib/cib.hpp)
54+
endif()

test/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ add_executable(tests
99
builder_meta.cpp
1010
callback.cpp
1111
nexus.cpp
12-
detail/ordered_set.cpp)
12+
detail/ordered_set.cpp
13+
)
1314

1415
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
1516
target_compile_options(tests

0 commit comments

Comments
 (0)