Commit a1945447 authored by Sebastian Wolf's avatar Sebastian Wolf

Print version in Unit-tests and CI

parent c861ce32
Pipeline #1167 failed with stages
in 13 minutes and 19 seconds
......@@ -32,7 +32,7 @@ job_make_gcc:
job_test_gcc:
stage: test_gcc
script: "./XerusTest all"
script: "make version; ./XerusTest all"
job_make_gcc_nocheck:
stage: build_gcc_nocheck
......@@ -40,7 +40,7 @@ job_make_gcc_nocheck:
job_test_gcc_nocheck:
stage: test_gcc_nocheck
script: "./XerusTest all"
script: "make version; ./XerusTest all"
job_build_python2:
stage: build_python2
......@@ -69,5 +69,5 @@ job_make_clang:
job_test_clang:
stage: test_clang
script: "./XerusTest all"
script: "make version; ./XerusTest all"
.PHONY: help shared static python doc install test clean opt warn printBoostVersion
.PHONY: help shared static python doc install test clean version opt warn printBoostVersion
# ------------------------------------------------------------------------------------------------------
# Default rule should be the help message
......@@ -22,26 +22,30 @@ help:
# Name of the test executable
TEST_NAME = XerusTest
# xerus version from VERSION file
XERUS_VERSION = $(shell git describe --tags --always 2>/dev/null || cat VERSION)
DEBUG += -D XERUS_VERSION="$(XERUS_VERSION)"
XERUS_MAJOR_V = $(word 1, $(subst ., ,$(XERUS_VERSION)) )
# ------------------------------------------------------------------------------------------------------
# Extract Xerus version from VERSION file
# ------------------------------------------------------------------------------------------------------
VERSION_STRING = $(shell git describe --tags --always 2>/dev/null || cat VERSION)
VERSION = -D XERUS_VERSION="$(VERSION_STRING)"
XERUS_MAJOR_V = $(word 1, $(subst ., ,$(VERSION_STRING)) )
ifneq (,$(findstring v, $(XERUS_MAJOR_V)))
XERUS_MAJOR_V := $(strip $(subst v, ,$(XERUS_MAJOR_V)) )
endif
DEBUG += -DXERUS_VERSION_MAJOR=$(XERUS_MAJOR_V)
XERUS_MINOR_V = $(word 2, $(subst ., ,$(XERUS_VERSION)) )
DEBUG += -DXERUS_VERSION_MINOR=$(XERUS_MINOR_V)
XERUS_REVISION_V = $(word 3, $(subst ., ,$(XERUS_VERSION)) )
VERSION += -D XERUS_VERSION_MAJOR=$(XERUS_MAJOR_V)
XERUS_MINOR_V = $(word 2, $(subst ., ,$(VERSION_STRING)) )
VERSION += -D XERUS_VERSION_MINOR=$(XERUS_MINOR_V)
XERUS_REVISION_V = $(word 3, $(subst ., ,$(VERSION_STRING)) )
ifneq (,$(findstring -, $(XERUS_REVISION_V)))
XERUS_COMMIT_V := $(word 2, $(subst -, ,$(XERUS_REVISION_V)) )
XERUS_REVISION_V := $(word 1, $(subst -, ,$(XERUS_REVISION_V)) )
else
XERUS_COMMIT_V = 0
endif
DEBUG += -DXERUS_VERSION_REVISION=$(XERUS_REVISION_V)
DEBUG += -DXERUS_VERSION_COMMIT=$(XERUS_COMMIT_V)
VERSION += -D XERUS_VERSION_REVISION=$(XERUS_REVISION_V)
VERSION += -D XERUS_VERSION_COMMIT=$(XERUS_COMMIT_V)
# ------------------------------------------------------------------------------------------------------
......@@ -111,8 +115,8 @@ define \n
endef
FLAGS = $(strip $(COMPATIBILITY) $(WARNINGS) $(OPTIMIZE) $(LOGGING) $(DEBUG) $(ADDITIONAL_INCLUDE) $(OTHER))
PYTHON_FLAGS = $(strip $(COMPATIBILITY) $(WARNINGS) $(LOGGING) $(DEBUG) $(ADDITIONAL_INCLUDE) $(OTHER) -fno-var-tracking-assignments)
FLAGS = $(strip $(COMPATIBILITY) $(WARNINGS) $(OPTIMIZE) $(VERSION) $(LOGGING) $(DEBUG) $(ADDITIONAL_INCLUDE) $(OTHER))
PYTHON_FLAGS = $(strip $(COMPATIBILITY) $(WARNINGS) $(VERSION) $(LOGGING) $(DEBUG) $(ADDITIONAL_INCLUDE) $(OTHER) -fno-var-tracking-assignments)
MINIMAL_DEPS = Makefile config.mk makeIncludes/general.mk makeIncludes/warnings.mk makeIncludes/optimization.mk
......@@ -255,6 +259,9 @@ clean:
-rm -f include/xerus.h.gch
make -C doc clean
version:
@echo $(VERSION)
# Build rule for normal misc objects
......
......@@ -27,6 +27,7 @@
#include <stddef.h>
#include <cstdint>
#include <cstddef>
#include <string>
namespace xerus {
/**
......@@ -40,6 +41,7 @@ namespace xerus {
/**
* The version of the compiled xerus library
*/
extern const std::string VERSION_FULL;
extern const int VERSION_MAJOR;
extern const int VERSION_MINOR;
extern const int VERSION_REVISION;
......
......@@ -24,7 +24,12 @@
#include <xerus/misc/standard.h>
#define STR_EXPAND(tok) #tok
#define STR(tok) STR_EXPAND(tok)
namespace xerus {
const std::string VERSION_FULL = STR(XERUS_VERSION);
const int VERSION_MAJOR = XERUS_VERSION_MAJOR;
const int VERSION_MINOR = XERUS_VERSION_MINOR;
const int VERSION_REVISION = XERUS_VERSION_REVISION;
......
......@@ -40,6 +40,7 @@
#include <xerus/misc/random.h>
#include <xerus/misc/internal.h>
namespace xerus { namespace misc {
std::map<std::string, std::map<std::string, std::function<void()>>> *xerus::misc::UnitTest::tests;
......@@ -193,9 +194,10 @@ int main(int argc, char* argv[]) {
std::chrono::high_resolution_clock::time_point startTime = std::chrono::high_resolution_clock::now();
std::cout << "###############################################################################\n";
std::cout << "# unit-testing #\n";
std::cout << "# Unit Tests #\n";
std::cout << "# Xerus version: " << std::setw(42) << std::left << xerus::VERSION_FULL << " #\n";
std::cout << "###############################################################################" << std::endl;
// no unittests defined (ie. the map tests does not exist!)
// No unittests defined (ie. the map tests does not exist!)
if (!xerus::misc::UnitTest::tests) {
std::cout << "no unittests defined.\n";
std::cout << "use the macro UNIT_TEST(group, testname, ...) to define unittests inside the sourcecode." << std::endl;
......@@ -215,6 +217,7 @@ int main(int argc, char* argv[]) {
return 0;
}
unsigned passCount=0;
unsigned totalPassCount=0;
unsigned totalCount=0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment