Skip to content
Snippets Groups Projects
Commit 0ee77a62 authored by Sebastian Ohlmann's avatar Sebastian Ohlmann
Browse files

Add CI, including compiling gtest

parent 651d5ac6
No related branches found
No related tags found
1 merge request!1Add CI
Pipeline #63106 passed
# use MPCDF module environment
image: gitlab-registry.mpcdf.mpg.de/mpcdf/module-image
default:
before_script:
- module load cmake git
test-gcc9:
script:
- module load gcc/9
- CC=gcc CXX=g++ CXXFLAGS="-std=c++11" ./get_gtest.sh
- make CC=gcc CXX=g++ CXXFLAGS="-std=c++11 -I$PWD/googletest/install/include" LDFLAGS="-L$PWD/googletest/install/lib64"
test-intel19:
script:
- module load intel/19.0.4
- CC=icc CXX=icpc CXXFLAGS="-std=c++11" ./get_gtest.sh
- make CC=icc CXX=icpc CXXFLAGS="-std=c++11 -I$PWD/googletest/install/include" LDFLAGS="-L$PWD/googletest/install/lib64"
SRC=src/main.cpp SRC=src/main.cpp
TESTS=tests
COV=coverage COV=coverage
OUT_T=test_output OUT_T=test_output
OUT_E=expected_output OUT_E=expected_output
APP=program APP=program
CXX=g++ CXX=g++
BROWSER=google-chrome BROWSER=google-chrome
TESTS=tests
TEST_APP=runTests
TEST_SRC=$(TESTS)/test_funcs.cpp
LDFLAGS_GTEST=-lgtest -lpthread
# Default # Default
all: distclean compile test all: distclean compile test
# Compiling section # Compiling section
compile: compile:
$(CXX) -o $(APP) $(SRC) $(CXX) $(CXXFLAGS) -o $(APP) $(SRC)
compile_coverage: compile_coverage:
$(CXX) -o $(APP) --coverage $(SRC) $(CXX) $(CXXFLAGS) -o $(APP) --coverage $(SRC)
# Testing section # Testing section
test: simple_tests regression_test unit_tests test: simple_tests regression_test unit_tests
...@@ -31,8 +34,9 @@ regression_test: ...@@ -31,8 +34,9 @@ regression_test:
diff $(OUT_T) $(OUT_E) diff $(OUT_T) $(OUT_E)
unit_tests: unit_tests:
cd $(TESTS) && cmake CMakeLists.txt && make $(CXX) $(CXXFLAGS) -o test_funcs.o -c $(TEST_SRC)
./$(TESTS)/runTests $(CXX) $(CXXFLAGS) test_funcs.o -o $(TEST_APP) $(LDFLAGS) $(LDFLAGS_GTEST)
./$(TEST_APP)
# Coverage section # Coverage section
coverage: clean clean_coverage compile_coverage simple_tests coverage: clean clean_coverage compile_coverage simple_tests
...@@ -50,7 +54,7 @@ clean: ...@@ -50,7 +54,7 @@ clean:
rm -f $(APP) rm -f $(APP)
clean_tests: clean_tests:
rm -rf $(TESTS)/CMakeFiles $(TESTS)/CMakeCache.txt $(TESTS)/cmake_install.cmake $(TESTS)/CMakeFiles $(TESTS)/runTests $(OUT_E) $(OUT_T) rm -rf $(TESTS)/CMakeFiles $(TESTS)/CMakeCache.txt $(TESTS)/cmake_install.cmake $(TESTS)/CMakeFiles $(TESTS)/runTests $(OUT_E) $(OUT_T) $(TEST_APP) *.o
clean_coverage: clean_coverage:
rm -rf *.gcno *.gcda $(APP).info $(COV) rm -rf *.gcno *.gcda $(APP).info $(COV)
......
#!/bin/bash
# already there
[[ -d googletest ]] && exit 0
# otherwise download and build
git clone https://github.com/google/googletest.git
mkdir -p googletest/build
cd googletest/build
cmake .. -DCMAKE_INSTALL_PREFIX=../install
make && make install
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment