Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Catch2 for testing shared code, GeoJSON parser fixes #674

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: test

on:
pull_request:
branches: [ main, develop, release/** ]
push:
branches: [ main, develop, release/** ]

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Install build tools and dependencies
run: sudo apt-get update && sudo apt-get install cmake ninja-build clang libgl-dev libgles-dev catch2
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: test-ccache-${{ runner.os }}-${{ runner.arch }}

- name: Build
run: |
cmake -G Ninja -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Debug -DBUILD_JVM=OFF -DBUILD_STANDALONE=OFF -B build-debug
cmake --build build-debug -- tests
- name: Test
run: |
mkdir test-results
cd shared/test # for access to data/ directory
../../build-debug/shared/test/tests \
--skip-benchmarks \
-r JUnit::out=../../test-results/catch2-junit.xml \
-r console::colour-mode=ansi

- name: Postprocess Junit XML
if: always()
run: |
# cursed XML fixup to add proper file and line number attributes
sed -i -e '
/<testcase.*[^/]>/,/<\/testcase>/{
/<testcase/ {h;d;}
/<\/\?testcase/! {H;d;}
/<\/testcase>/ {H;x;s/<testcase \(.*\)at \([^:]*\):\([0-9]\+\)/<testcase file="\2" line="\3" \1at \2:\3/;}
}' test-results/catch2-junit.xml
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: |
test-results/catch2-junit.xml
test_file_prefix: -/home/runner/work/maps-core/maps-core/
comment_mode: off
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ dist/

# Unit test reports
TEST*.xml
test-results/

# Generated by MacOS
.DS_Store
Expand Down
15 changes: 12 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ project(mapscore
# mapscore OpenGL "proper", i.e. the C++ implementation without language bindings
####
file(GLOB_RECURSE mapscore_SRC
"shared/*.cpp"
"shared/public/*.cpp"
"shared/src/*.cpp"
"android/src/main/cpp/graphics/*.cpp"
)

Expand Down Expand Up @@ -79,5 +80,13 @@ target_compile_features(mapscore PRIVATE cxx_std_20)
target_compile_options(mapscore PRIVATE -Werror -Wno-deprecated -Wno-reorder -fPIC) # fPIC so we can "embed" into shared mapscore_jni
target_link_libraries(mapscore ${OPENGL_LIBRARIES})

add_subdirectory(standalone)
add_subdirectory(jvm)
add_subdirectory(shared/test)

option(BUILD_STANDALONE "Build standalone test application with GL offscreen rendering via OSMesa" ON)
if(BUILD_STANDALONE)
add_subdirectory(standalone)
endif()
option(BUILD_JVM "Build JNI based Java bindings with GL offscreen rendering via OSMesa" ON)
if(BUILD_JVM)
add_subdirectory(jvm)
endif()
15 changes: 2 additions & 13 deletions android/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,12 @@ if (CCACHE_FOUND)
endif (CCACHE_FOUND)

file(GLOB_RECURSE cpp_SRC
"../bridging/android/jni/*.h"
"../bridging/android/jni/*.hpp"
"../bridging/android/jni/*.cpp"
"../shared/*.h"
"../shared/*.cpp"
"../shared/*.hpp"
"src/main/cpp/*.h"
"../shared/public/*.cpp"
"../shared/src/*.cpp"
"src/main/cpp/*.cpp"
"../external/djinni/support-lib/cpp/*.h"
"../external/djinni/support-lib/cpp/*.hpp"
"../external/djinni/support-lib/cpp/*.cpp"
"../external/djinni/support-lib/jni/*.h"
"../external/djinni/support-lib/jni/*.hpp"
"../external/djinni/support-lib/jni/*.cpp"
"../external/protozero/protozero/include/*.hpp"
"../external/vtzero/vtzero/include/*.hpp"
"../external/earcut/earcut/include/*.hpp"
)

add_library( # Sets the name of the library.
Expand Down
Loading
Loading