From 8526b5a79795fe821749ecd985dc26fcf30728f9 Mon Sep 17 00:00:00 2001 From: David Seifert Date: Fri, 26 Apr 2019 12:56:12 +0200 Subject: Fix regex in unittest for pre-releases and git checkouts --- CMakeLists.txt | 2 +- unittest/test_offline.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e583d30..6d59430 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -130,7 +130,7 @@ execute_process( ) ENDIF() IF((NOT ${ADD_GIT_INFO}) OR (${PROJECT_VERSION_GIT_RETURN_CODE})) - SET(PROJECT_VERSION_GIT "unknown") + SET(PROJECT_VERSION_GIT "v${PROJECT_VERSION}") ENDIF() MESSAGE(STATUS "Setting Git library version to: " ${PROJECT_VERSION_GIT} ) configure_file("version.cc.in" "version.cc" @ONLY) diff --git a/unittest/test_offline.cc b/unittest/test_offline.cc index 279c38f..320ad48 100644 --- a/unittest/test_offline.cc +++ b/unittest/test_offline.cc @@ -178,8 +178,8 @@ TEST_CASE("Test version getter", "[fast]") { // Optional field is allowed as well. INFO("This test will fail, if the full git commit version was not collected during library build."); std::string s = library_version; - std::string version("v[0-9]+\\.[0-9]+(\\.[0-9]+)?"); - std::string git_suffix("-[0-9]+-g[0-9a-z]+"); + std::string version("(pre-)?v[0-9]+\\.[0-9]+(\\.[0-9]+)?"); + std::string git_suffix("(-[0-9]+)+-g[0-9a-z]+"); std::regex pattern(version + "(" + git_suffix + ")?"); REQUIRE(std::regex_match(s, pattern)); } -- cgit v1.2.3