Skip to content

Commit

Permalink
🎉 Add initial doctest support
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasGilg authored and Schneegans committed Dec 18, 2019
1 parent c538aa6 commit 32f1d7e
Show file tree
Hide file tree
Showing 29 changed files with 485 additions and 77 deletions.
139 changes: 80 additions & 59 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,29 @@ name: Build
on:
push:
branches:
- '**'
- '**'
pull_request:
branches:
- '**'
- '**'

jobs:
clang_format:
name: Check Clang-Format
runs-on: ubuntu-18.04
steps:
- name: Checkout Repository
uses: actions/checkout@v1
- name: Download Clang-Format
run: |
sudo apt-get update -y
sudo apt-get remove -y clang-6.0 libclang-common-6.0-dev libclang1-6.0 libllvm6.0
sudo apt-get install -y clang-format
- name: Run Clang-Format
run: ./clang-format.sh
- name: Compare Results
run: |
DIFF=$(git diff)
if [ ! -z "$DIFF" ]; then echo $DIFF && exit 1; fi
- name: Checkout Repository
uses: actions/checkout@v1
- name: Download Clang-Format
run: |
sudo apt-get update -y
sudo apt-get remove -y clang-6.0 libclang-common-6.0-dev libclang1-6.0 libllvm6.0
sudo apt-get install -y clang-format
- name: Run Clang-Format
run: ./clang-format.sh
- name: Compare Results
run: |
DIFF=$(git diff)
if [ ! -z "$DIFF" ]; then echo $DIFF && exit 1; fi
build_linux_gcc:
name: Linux Build (gcc 7.4.0)
Expand All @@ -35,21 +35,35 @@ jobs:
( contains(github.ref, 'master') && !contains(github.event.head_commit.message, '[no-ci]') ) ||
( contains(github.ref, 'develop') && !contains(github.event.head_commit.message, '[no-ci]') ) ||
contains(github.event.head_commit.message, '[run-ci]')
env:
COSMOSCOUT_CODE_COVERAGE: true
steps:
- name: Checkout Repository
uses: actions/checkout@v1
- name: Checkout Submodules
run: git submodule update --init
- name: Download Dependencies
run: |
sudo add-apt-repository ppa:mhier/libboost-latest
sudo apt-get update -q
sudo apt-get install libc++-dev libgl1-mesa-dev libglu1-mesa-dev libx11-dev
sudo apt-get install libxi-dev libgconf-2-4 libboost1.70-dev
- name: Build Externals
run: ./make_externals.sh
- name: Build CosmoScout VR
run: ./make.sh
- name: Checkout Repository
uses: actions/checkout@v1
- name: Checkout Submodules
run: git submodule update --init
- name: Install CMake
run: sudo pip install cmake
- name: Download Dependencies
run: |
sudo add-apt-repository ppa:mhier/libboost-latest
sudo apt-get update -q
sudo apt-get install libc++-dev libgl1-mesa-dev libglu1-mesa-dev libx11-dev
sudo apt-get install libxi-dev libgconf-2-4 libboost1.70-dev
sudo apt-get install -y lcov
- name: Build Externals
run: ./make_externals.sh
- name: Build CosmoScout VR
run: ./make.sh
- name: Run Tests
run: ./install/linux-release/bin/run_all_tests.sh
- name: Calculate Test Coverage
run: ./lcov.sh
- name: Upload Coverage Info
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./build/linux-release/coverage.info

build_linux_clang:
name: Linux Build (clang 6.0)
Expand All @@ -60,26 +74,30 @@ jobs:
( contains(github.ref, 'develop') && !contains(github.event.head_commit.message, '[no-ci]') ) ||
contains(github.event.head_commit.message, '[run-ci]')
steps:
- name: Checkout Repository
uses: actions/checkout@v1
- name: Checkout Submodules
run: git submodule update --init
- name: Download Dependencies
run: |
sudo add-apt-repository ppa:mhier/libboost-latest
sudo apt-get update -q
sudo apt-get install libc++-dev libgl1-mesa-dev libglu1-mesa-dev libx11-dev
sudo apt-get install libxi-dev libgconf-2-4 libboost1.70-dev
- name: Build Externals
env:
CC: clang
CXX: clang++
run: ./make_externals.sh
- name: Build CosmoScout VR
env:
CC: clang
CXX: clang++
run: ./make.sh
- name: Checkout Repository
uses: actions/checkout@v1
- name: Checkout Submodules
run: git submodule update --init
- name: Install CMake
run: sudo pip install cmake
- name: Download Dependencies
run: |
sudo add-apt-repository ppa:mhier/libboost-latest
sudo apt-get update -q
sudo apt-get install libc++-dev libgl1-mesa-dev libglu1-mesa-dev libx11-dev
sudo apt-get install libxi-dev libgconf-2-4 libboost1.70-dev
- name: Build Externals
env:
CC: clang
CXX: clang++
run: ./make_externals.sh
- name: Build CosmoScout VR
env:
CC: clang
CXX: clang++
run: ./make.sh
- name: Run Tests
run: ./install/linux-release/bin/run_all_tests.sh

build_windows:
name: Windows Build (msvc 19.16.27032.1)
Expand All @@ -90,13 +108,16 @@ jobs:
( contains(github.ref, 'develop') && !contains(github.event.head_commit.message, '[no-ci]') ) ||
contains(github.event.head_commit.message, '[run-ci]')
steps:
- name: Checkout Repository
uses: actions/checkout@v1
- name: Checkout Submodules
run: git submodule update --init
- name: Build Externals
shell: cmd
run: make_externals.bat
- name: Build CosmoScout VR
shell: cmd
run: make.bat
- name: Checkout Repository
uses: actions/checkout@v1
- name: Checkout Submodules
run: git submodule update --init
- name: Build Externals
shell: cmd
run: make_externals.bat
- name: Build CosmoScout VR
shell: cmd
run: make.bat
- name: Run Tests
shell: cmd
run: install\\windows-release\\bin\\run_all_tests.bat
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
[submodule "externals/git-archive-all.sh"]
path = externals/git-archive-all.sh
url = https://github.com/cosmoscout/git-archive-all.sh
[submodule "externals/doctest"]
path = externals/doctest
url = https://github.com/onqtam/doctest.git
[submodule "plugins/csp-trajectories"]
path = plugins/csp-trajectories
url = ../../cosmoscout/csp-trajectories.git
Expand Down
17 changes: 16 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Copyright: (c) 2019 German Aerospace Center (DLR) #
# ------------------------------------------------------------------------------------------------ #

cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.13)
project(cosmoscout-vr VERSION 1.1.1)

# Use cmake 3.12's <PACKAGE>_ROOT variabled for searching.
Expand Down Expand Up @@ -73,6 +73,12 @@ else()
SET(GLI_ROOT_DIR ${COSMOSCOUT_EXTERNALS_DIR})
endif()

if (DEFINED ENV{DOCTEST_ROOT_DIR})
SET(DOCTEST_ROOT_DIR "$ENV{DOCTEST_ROOT_DIR}")
else()
SET(DOCTEST_ROOT_DIR ${COSMOSCOUT_EXTERNALS_DIR})
endif()

if (DEFINED ENV{TINYGLTF_ROOT_DIR})
SET(TINYGLTF_ROOT_DIR "$ENV{TINYGLTF_ROOT_DIR}")
else()
Expand Down Expand Up @@ -123,6 +129,7 @@ endif()

find_package(GLM REQUIRED)
find_package(GLI REQUIRED)
find_package(DOCTEST REQUIRED)
find_package(TINYGLTF REQUIRED)
find_package(CSPICE REQUIRED)
find_package(CARES REQUIRED)
Expand Down Expand Up @@ -219,6 +226,14 @@ add_compile_options($<$<CXX_COMPILER_ID:MSVC>:/EHsc>)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Enable code coverage measurements
option(COSMOSCOUT_COVERAGE_INFO "Run code coverage analytics" OFF)

if(COSMOSCOUT_COVERAGE_INFO AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_definitions(--coverage)
add_link_options(--coverage)
endif()

# subdirectories -----------------------------------------------------------------------------------

include_directories(
Expand Down
27 changes: 27 additions & 0 deletions cmake/FindDOCTEST.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# ------------------------------------------------------------------------------------------------ #
# This file is part of CosmoScout VR #
# and may be used under the terms of the MIT license. See the LICENSE file for details. #
# Copyright: (c) 2019 German Aerospace Center (DLR) #
# ------------------------------------------------------------------------------------------------ #

# Locate header.
find_path(DOCTEST_INCLUDE_DIR doctest/doctest.h
HINTS ${DOCTEST_ROOT_DIR}/include)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(DOCTEST DEFAULT_MSG DOCTEST_INCLUDE_DIR)

# Add imported target.
if(DOCTEST_FOUND)
set(DOCTEST_INCLUDE_DIRS "${DOCTEST_INCLUDE_DIR}")

if(NOT DOCTEST_FIND_QUIETLY)
message(STATUS "DOCTEST_INCLUDE_DIRS .......... ${DOCTEST_INCLUDE_DIR}")
endif()

if(NOT TARGET doctest::doctest)
add_library(doctest::doctest INTERFACE IMPORTED)
set_target_properties(doctest::doctest PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${DOCTEST_INCLUDE_DIRS}")
endif()
endif()
9 changes: 6 additions & 3 deletions config/base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@

# install platform dependent files -----------------------------------------------------------------
if (WIN32)
install(FILES "spice/simple-windows.txt" DESTINATION "share/config/spice" RENAME "simple.txt")
install(FILES "scene/simple_vive.json" DESTINATION "share/config")
install(FILES "scripts/start.bat" DESTINATION "bin")
install(FILES "spice/simple-windows.txt" DESTINATION "share/config/spice" RENAME "simple.txt")
install(FILES "scene/simple_vive.json" DESTINATION "share/config")
install(FILES "scripts/start.bat" DESTINATION "bin")
install(FILES "scripts/run_all_tests.bat" DESTINATION "bin")
endif()

if (UNIX)
install(FILES "spice/simple-linux.txt" DESTINATION "share/config/spice" RENAME "simple.txt")
install(FILES "scripts/start.sh" DESTINATION "bin"
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ)
install(FILES "scripts/run_all_tests.sh" DESTINATION "bin"
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ)
endif()

# install files for all platforms ------------------------------------------------------------------
Expand Down
22 changes: 22 additions & 0 deletions config/base/scripts/run_all_tests.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@echo off

rem ---------------------------------------------------------------------------------------------- #
rem This file is part of CosmoScout VR #
rem and may be used under the terms of the MIT license. See the LICENSE file for details. #
rem Copyright: (c) 2019 German Aerospace Center (DLR) #
rem ---------------------------------------------------------------------------------------------- #

rem Change working directory to the location of this script.
set SCRIPT_DIR=%~dp0
set CURRENT_DIR=%cd%
cd "%SCRIPT_DIR%"

rem Set paths so that all libraries are found.
set PATH=%SCRIPT_DIR%\..\lib;%PATH%

cosmoscout.exe --run-tests

rem Go back to where we came from
cd "%CURRENT_DIR%"

@echo on
16 changes: 16 additions & 0 deletions config/base/scripts/run_all_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# ------------------------------------------------------------------------------------------------ #
# This file is part of CosmoScout VR #
# and may be used under the terms of the MIT license. See the LICENSE file for details. #
# Copyright: (c) 2019 German Aerospace Center (DLR) #
# ------------------------------------------------------------------------------------------------ #

# Change working directory to the location of this script.
SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
cd "$SCRIPT_DIR"

# Set paths so that all libraries are found.
export LD_LIBRARY_PATH=../lib:../lib/DriverPlugins:$LD_LIBRARY_PATH

./cosmoscout --run-tests
1 change: 1 addition & 0 deletions externals/doctest
Submodule doctest added at 7ac22c
64 changes: 64 additions & 0 deletions lcov.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/bash

# ------------------------------------------------------------------------------------------------ #
# This file is part of CosmoScout VR #
# and may be used under the terms of the MIT license. See the LICENSE file for details. #
# Copyright: (c) 2019 German Aerospace Center (DLR) #
# ------------------------------------------------------------------------------------------------ #

# Exit on error.
set -e

# ------------------------------------------------------------------------------------------------ #
# This script uses lcov to capture the source coverage of the test executed with run_all_tests.sh. #
# The environment variable COSMOSCOUT_DEBUG_BUILD is checked in order to use the data in #
# build/linux-$BUILD_TYPE and install/linux-$BUILD_TYPE. #
# If you pass any argument to the script (say ./lcov.sh foo) then it will create also an html #
# report and open this report in your web browser. #
# ------------------------------------------------------------------------------------------------ #

# create some required variables -------------------------------------------------------------------

# Get the location of this script.
SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
cd $SCRIPT_DIR

# Check if ComoScout VR debug build is enabled with "export COSMOSCOUT_DEBUG_BUILD=true".
BUILD_TYPE=release
case "$COSMOSCOUT_DEBUG_BUILD" in
(true) echo "CosmoScout VR debug build is enabled!"; BUILD_TYPE=debug;
esac

# Get the current directory - this should contain the build and install directory.
CURRENT_DIR="$(pwd)"

# The build directory.
BUILD_DIR="$CURRENT_DIR/build/linux-$BUILD_TYPE"

# The install directory.
INSTALL_DIR="$CURRENT_DIR/install/linux-$BUILD_TYPE"

# create zero-coverage info ------------------------------------------------------------------------

lcov -q --zerocounters --directory .
lcov -q --capture --no-external --initial --directory . --output-file $BUILD_DIR/zero_coverage.info

# run the tests ------------------------------------------------------------------------------------

$INSTALL_DIR/bin/run_all_tests.sh

# capture the coverage of the test -----------------------------------------------------------------

lcov -q --capture --no-external --directory . --output-file $BUILD_DIR/test_coverage.info
lcov -q -a $BUILD_DIR/zero_coverage.info -a $BUILD_DIR/test_coverage.info --o $BUILD_DIR/coverage.info

# Remove any coverage from externals, examples and test directories.
lcov -q --remove $BUILD_DIR/coverage.info \*externals\* --output-file $BUILD_DIR/coverage.info
lcov -q --remove $BUILD_DIR/coverage.info \*test\* --output-file $BUILD_DIR/coverage.info

# Generate html report and open it in a web browser when an argument was passed to the script.
if [ $# != 0 ]
then
genhtml $BUILD_DIR/coverage.info --output-directory $BUILD_DIR/coverage
xdg-open $BUILD_DIR/coverage/index.html
fi
Loading

0 comments on commit 32f1d7e

Please sign in to comment.