From 71541b3dd1521c6212310e0332b68cd950ed6286 Mon Sep 17 00:00:00 2001 From: marcosbento Date: Thu, 27 Feb 2025 08:31:12 +0000 Subject: [PATCH 1/2] Enable project version with suffix --- CMakeLists.txt | 9 +- Viewer/ecflowUI/src/AboutDialog.cpp | 2 +- Viewer/ecflowUI/src/MainWindow.cpp | 2 +- Viewer/ecflowUI/src/VConfig.cpp | 2 +- Viewer/ecflowUI/src/ViewerMain.cpp | 2 +- cmake/Dependencies.cmake | 27 +++--- libs/CMakeLists.txt | 4 +- .../ecflow/base/cts/user/ServerVersionCmd.cpp | 2 +- libs/client/test/TestServer.cpp | 22 +++-- libs/core/src/ecflow/core/Version.cpp | 88 ++++++++----------- libs/core/src/ecflow/core/Version.hpp | 55 ++++++++---- libs/core/src/ecflow/core/ecflow_version.h.in | 1 + libs/core/test/TestVersion.cpp | 83 ++++++++++------- libs/node/src/ecflow/node/Defs.cpp | 2 +- libs/node/src/ecflow/node/ServerState.cpp | 2 +- libs/node/test/TestVariableSubstitution.cpp | 4 +- .../test/TestVariableSubstitutionDefs.cpp | 2 +- libs/pyext/src/ecflow/python/ExportClient.cpp | 2 +- .../src/ecflow/server/ServerEnvironment.cpp | 4 +- .../src/ecflow/server/TcpBaseServer.cpp | 2 +- libs/test/TestTime.cpp | 8 +- libs/test/harness/TestFixture.cpp | 13 +-- libs/test/harness/TestFixture.hpp | 10 ++- libs/udp/src/ecflow/udp/UDPServerMain.cpp | 4 +- 24 files changed, 194 insertions(+), 158 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d4ed0832..13150ee1f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,7 +43,14 @@ include( ecbuild_system NO_POLICY_SCOPE ) ecbuild_requires_macro_version( 1.6 ) ecbuild_declare_project() -ecbuild_info( "CMAKE_MODULE_PATH : ${CMAKE_MODULE_PATH}") +# +# Set the version suffix (for alpha/beta/rc releases) +# + +set(ecflow_VERSION_SUFFIX "") +set(ecflow_VERSION "${ecflow_VERSION}${ecflow_VERSION_SUFFIX}") + +ecbuild_info( "CMAKE_MODULE_PATH : ${CMAKE_MODULE_PATH}" ) ecbuild_info( "CMAKE_INSTALL_PREFIX : ${CMAKE_INSTALL_PREFIX}" ) ecbuild_info( "ecflow_BINARY_DIR : ${ecflow_BINARY_DIR}" ) ecbuild_info( "ecflow_SOURCE_DIR : ${ecflow_SOURCE_DIR}" ) diff --git a/Viewer/ecflowUI/src/AboutDialog.cpp b/Viewer/ecflowUI/src/AboutDialog.cpp index 97dcaf276..824532279 100644 --- a/Viewer/ecflowUI/src/AboutDialog.cpp +++ b/Viewer/ecflowUI/src/AboutDialog.cpp @@ -28,7 +28,7 @@ AboutDialog::AboutDialog(QWidget* parent) : QDialog(parent) { setupUi(this); QString title = "EcflowUI"; - QString ecfVersionTxt = QString::fromStdString(ecf::Version::raw()); + QString ecfVersionTxt = QString::fromStdString(ecf::Version::full()); QString desc = QString::fromStdString(ecf::Version::description()); QString descTxt = "ecflow version: " + ecfVersionTxt; diff --git a/Viewer/ecflowUI/src/MainWindow.cpp b/Viewer/ecflowUI/src/MainWindow.cpp index af9d503c2..bb8d07123 100644 --- a/Viewer/ecflowUI/src/MainWindow.cpp +++ b/Viewer/ecflowUI/src/MainWindow.cpp @@ -806,7 +806,7 @@ void MainWindowTitleHandler::update() { Q_ASSERT(win_); char* userTitle = getenv("ECFLOWUI_TITLE"); - std::string mainTitle = (userTitle != nullptr) ? std::string(userTitle) + " (" + ecf::Version::raw() + ")" + std::string mainTitle = (userTitle != nullptr) ? std::string(userTitle) + " (" + ecf::Version::full() + ")" : VConfig::instance()->appLongName(); QString title = QString::fromStdString(mainTitle); diff --git a/Viewer/ecflowUI/src/VConfig.cpp b/Viewer/ecflowUI/src/VConfig.cpp index e9d5afc3b..40172ee2c 100644 --- a/Viewer/ecflowUI/src/VConfig.cpp +++ b/Viewer/ecflowUI/src/VConfig.cpp @@ -29,7 +29,7 @@ VConfig* VConfig::instance_ = nullptr; // #define _UI_CONFIG_LOAD_DEBUG VConfig::VConfig() { - appLongName_ = appName_ + " (" + ecf::Version::raw() + ")"; + appLongName_ = appName_ + " (" + ecf::Version::full() + ")"; // detect if the ui is to run via proxichains if (char* variable = getenv("ECFLOWUI_USE_PROXYCHAINS"); variable) { diff --git a/Viewer/ecflowUI/src/ViewerMain.cpp b/Viewer/ecflowUI/src/ViewerMain.cpp index be39863df..72d6cfa98 100644 --- a/Viewer/ecflowUI/src/ViewerMain.cpp +++ b/Viewer/ecflowUI/src/ViewerMain.cpp @@ -45,7 +45,7 @@ int main(int argc, char** argv) { if (argc == 2) { if (strcmp(argv[1], "--version") == 0) { - std::cout << ecf::Version::raw() << std::endl; + std::cout << ecf::Version::full() << std::endl; return 0; } } diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake index e41540f16..75d773988 100644 --- a/cmake/Dependencies.cmake +++ b/cmake/Dependencies.cmake @@ -223,6 +223,21 @@ if (ENABLE_SSL) endif() +# ========================================================================================= +# Crypt +# ========================================================================================= +ecbuild_info( "Locating Crypt" ) + +find_package(Crypt) + +ecbuild_info( "Crypt details:" ) +ecbuild_info( " * Crypt_FOUND : ${Crypt_FOUND}" ) +ecbuild_info( " * Crypt_INCLUDE_DIRS : ${Crypt_INCLUDE_DIRS}" ) +ecbuild_info( " * Crypt_LIBRARIES : ${Crypt_LIBRARIES}" ) + +ecbuild_info( "Found Crypt at ${Crypt_INCLUDE_DIRS}" ) + + # ========================================================================================= # Dependency: Qt # ========================================================================================= @@ -362,15 +377,3 @@ else() ecbuild_info("Clang-Format not found") ecbuild_info(" WARNING: No formatting targets will be defined!") endif () - -# ========================================================================================= -# Crypt -# ========================================================================================= -ecbuild_info( "Locating Crypt" ) - -find_package(Crypt) - -ecbuild_info( "Crypt details:" ) -ecbuild_info( " * Crypt_FOUND : ${Crypt_FOUND}" ) -ecbuild_info( " * Crypt_INCLUDE_DIRS : ${Crypt_INCLUDE_DIRS}" ) -ecbuild_info( " * Crypt_LIBRARIES : ${Crypt_LIBRARIES}" ) diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt index 08a671e77..554dabace 100644 --- a/libs/CMakeLists.txt +++ b/libs/CMakeLists.txt @@ -545,11 +545,11 @@ set(srcs ecbuild_add_library( TARGET - ecflow_all + ecflow_all NOINSTALL TYPE STATIC SOURCES - ${srcs} + ${srcs} PUBLIC_INCLUDES attribute/src base/src diff --git a/libs/base/src/ecflow/base/cts/user/ServerVersionCmd.cpp b/libs/base/src/ecflow/base/cts/user/ServerVersionCmd.cpp index 134543f5d..1a4dc2ba9 100644 --- a/libs/base/src/ecflow/base/cts/user/ServerVersionCmd.cpp +++ b/libs/base/src/ecflow/base/cts/user/ServerVersionCmd.cpp @@ -41,7 +41,7 @@ const char* ServerVersionCmd::theArg() const { STC_Cmd_ptr ServerVersionCmd::doHandleRequest(AbstractServer* as) const { as->update_stats().server_version_++; - return PreAllocatedReply::string_cmd(Version::raw()); + return PreAllocatedReply::string_cmd(Version::full()); } static const char* arg_desc() { diff --git a/libs/client/test/TestServer.cpp b/libs/client/test/TestServer.cpp index 852477078..598474ae2 100644 --- a/libs/client/test/TestServer.cpp +++ b/libs/client/test/TestServer.cpp @@ -49,17 +49,23 @@ BOOST_AUTO_TEST_CASE(test_server_version) { ClientInvoker theClient(invokeServer.host(), invokeServer.port()); BOOST_REQUIRE_MESSAGE(theClient.server_version() == 0, "server version\n" << theClient.errorMsg()); + + auto client_version = theClient.get_string(); + auto server_version = Version::full(); + + // Important: + // The test only requires a specific server version when both client and server are local. + // When contacting a remote server, only a warning is issued if the versions do not match. + if (ClientEnvironment::hostSpecified().empty()) { - // This check only valid if server was invoked locally. Ignore for remote servers - BOOST_REQUIRE_MESSAGE(theClient.get_string() == Version::raw(), - "Expected client version(" << Version::raw() << ") to match server version(" - << theClient.get_string() << ")"); + BOOST_REQUIRE_MESSAGE(client_version == server_version, + "Client version (" << client_version << ") does not match server version (" + << server_version << ")"); } else { - // remote server, version may be different - BOOST_WARN_MESSAGE(theClient.get_string() == Version::raw(), - "Client version(" << Version::raw() << ") does not match server version(" - << theClient.get_string() << ")"); + BOOST_WARN_MESSAGE(client_version == server_version, + "Client version (" << client_version << ") does not match server version (" << server_version + << ")"); } } diff --git a/libs/core/src/ecflow/core/Version.cpp b/libs/core/src/ecflow/core/Version.cpp index 10e4dc047..504a6e0e2 100644 --- a/libs/core/src/ecflow/core/Version.cpp +++ b/libs/core/src/ecflow/core/Version.cpp @@ -20,58 +20,21 @@ namespace ecf { -// ******************************************************************** -// IMPORTANT: -// The version number is extracted externally. -// see libs/core/doc/extracting_version_number.ddoc -// -// See libs/core/src/ecflow_version.h -// This file is generated when cmake is run, i.e. -// `sh -x $WK/cmake.sh debug` -// -// When changing the version change remember to: -// - re-login into remote system to update ECFLOW_INSTALL_DIR & ECFLOW_PYTHON_INSTALL_DIR -// required for interactive install -// -// To Install a new version on all the different platforms: -// . build_scripts/nightly/quick_install_.sh -// This is because the definition hold's the last version. -// Hence, we must rerun to update the version. -// -// ************************************************************************************ -// Use rc for release candidates, Once release we revert back: -// 0rc1 -> 0 -// 10rc3 -> 10 -// ************************************************************************************ -// -// **Please update file history.ddoc with the changed made for each release *** -// ******************************************************************** -#ifdef DEBUG -const std::string Version::TAG = " (debug)"; // Old tag: beta(debug) -#else -const std::string Version::TAG = ""; // Old tag: beta -#endif - -// See: http://www.cmake.org/cmake/help/cmake_tutorial.html -// For defining version numbers. This is done is a separate file -// that is then included std::string Version::description() { std::stringstream ss; - ss << "Ecflow" << Version::TAG << " version(" << ECFLOW_RELEASE << "." << ECFLOW_MAJOR << "." << ECFLOW_MINOR; - - ss << ") boost(" << Version::boost() << ")"; - std::string the_comp = compiler(); - if (!the_comp.empty()) - ss << " compiler(" << the_comp << ")"; - - ss << " protocol(JSON cereal " << CEREAL_VERSION_MAJOR << "." << CEREAL_VERSION_MINOR << "." << CEREAL_VERSION_PATCH - << ")"; + ss << "Ecflow "; +#ifdef DEBUG + ss << "(debug) "; +#endif + ss << "version(" << Version::full() << ") "; + ss << "boost(" << Version::boost() << ") "; + ss << "compiler(" << Version::compiler() << ") "; + ss << "protocol(JSON cereal " << Version::cereal() << ") "; #ifdef ECF_OPENSSL - ss << " openssl(enabled)"; + ss << "openssl(enabled) "; #endif - - ss << " Compiled on " << __DATE__ << " " << __TIME__; + ss << "Compiled on " << __DATE__ << " " << __TIME__; return ss.str(); } @@ -94,6 +57,23 @@ std::string Version::raw() { return ret; } +std::string Version::full() { + return Version::raw() + Version::suffix(); +} + +std::string Version::major() { + return ecf::convert_to(ECFLOW_RELEASE); +} +std::string Version::minor() { + return ecf::convert_to(ECFLOW_MAJOR); +} +std::string Version::patch() { + return ecf::convert_to(ECFLOW_MINOR); +} +std::string Version::suffix() { + return ecf::convert_to(ECFLOW_SUFFIX); +}; + std::string Version::boost() { std::stringstream ss; ss << BOOST_VERSION / 100000 << "." // major version @@ -102,6 +82,14 @@ std::string Version::boost() { return ss.str(); } +std::string Version::cereal() { + std::stringstream ss; + ss << CEREAL_VERSION_MAJOR // major version + << "." << CEREAL_VERSION_MINOR // minor version + << "." << CEREAL_VERSION_PATCH; // patch level + return ss.str(); +} + std::string Version::compiler() { std::stringstream ss; #if defined(_AIX) @@ -112,7 +100,7 @@ std::string Version::compiler() { #if defined(__clang__) // To find the list of defines for clang use: // echo | /usr/local/apps/clang/current/bin/clang++ -dM -E - - ss << "clang " << __clang_major__ << "." << __clang_minor__; + ss << "clang " << __clang_major__ << "." << __clang_minor__ << "." << __clang_patchlevel__; #elif defined(__INTEL_COMPILER) ss << "intel " << __INTEL_COMPILER; #elif defined(_CRAYC) @@ -121,7 +109,9 @@ std::string Version::compiler() { ss << "gcc " << __GNUC__ << "." << __GNUC_MINOR__ << "." << __GNUC_PATCHLEVEL__; #endif #endif - return ss.str(); + auto version = ss.str(); + + return version.empty() ? "unknown" : version; } } // namespace ecf diff --git a/libs/core/src/ecflow/core/Version.hpp b/libs/core/src/ecflow/core/Version.hpp index 1dc0b1afe..b61d2cd3f 100644 --- a/libs/core/src/ecflow/core/Version.hpp +++ b/libs/core/src/ecflow/core/Version.hpp @@ -11,20 +11,18 @@ #ifndef ecflow_core_Version_HPP #define ecflow_core_Version_HPP -/// -/// \brief Holds the version of ECFlow. Checked against definition file. -/// For each major release the major number should be incremented. -/// -/// If the parsing comes across a construct it does not recognize, then -/// an exception is thrown. i.e if a construct added in release 2.0 of ECF -/// is read in by version 1.0 of ECF. The exception should indicate the -/// current release -/// - #include namespace ecf { +/// +/// \brief Provides information regarding the version of ecFlow. +/// +/// The ecFlow version format is of the form `..[]`, +/// following the semantic versioning scheme. +/// +/// The version is defined in the CMakeLists.txt file. +/// class Version { public: // Disable default construction @@ -33,24 +31,43 @@ class Version { Version(const Version&) = delete; const Version& operator=(const Version&) = delete; - /// Outputs a string of the form: - /// ECF version release_.major_.minor_ + /// + /// Creates a string with a descriptive version information, + /// including the version of ecFlow and relevant dependencies. + /// + /// This provides user facing version information + /// (shown by ecflow_client --help, and in the server info panel on ecflow_ui). + /// static std::string description(); - /// Outputs string of form: ecflow___ - /// This could be used by install + /// + /// Creates the ecFlow version, following the template: `ecflow___` + /// static std::string version(); - /// Outputs string of form: .. + /// + /// Creates the ecFlow version, following the template: `..` + /// static std::string raw(); -private: - static const std::string TAG; // alpha, beta, release + /// + /// Creates the ecFlow version, following the template: `..[]` + /// + static std::string full(); - /// return version of the boost library + static std::string major(); + static std::string minor(); + static std::string patch(); + static std::string suffix(); + +private: + /// Create a string containing the version of the Boost library static std::string boost(); - // Return the version of the compiler. Can return empty string + /// Create a string containing the version of the Cereal library + static std::string cereal(); + + /// Create a string containing the version of the Compiler used to build ecFlow static std::string compiler(); }; diff --git a/libs/core/src/ecflow/core/ecflow_version.h.in b/libs/core/src/ecflow/core/ecflow_version.h.in index fc317288b..df75df5e6 100644 --- a/libs/core/src/ecflow/core/ecflow_version.h.in +++ b/libs/core/src/ecflow/core/ecflow_version.h.in @@ -16,6 +16,7 @@ #define ECFLOW_RELEASE "@ecflow_VERSION_MAJOR@" #define ECFLOW_MAJOR "@ecflow_VERSION_MINOR@" #define ECFLOW_MINOR "@ecflow_VERSION_PATCH@" +#define ECFLOW_SUFFIX "@ecflow_VERSION_SUFFIX@" // available but not used // PROJECT_VERSION=@PROJECT_VERSION@ diff --git a/libs/core/test/TestVersion.cpp b/libs/core/test/TestVersion.cpp index f5be88dc9..871768a1a 100644 --- a/libs/core/test/TestVersion.cpp +++ b/libs/core/test/TestVersion.cpp @@ -21,6 +21,34 @@ using namespace ecf; using namespace boost; +template +bool contains(std::string_view value, T&&... pattern) { + return ((value.find(pattern) != std::string::npos) && ...); +} + +std::string find_cmake_version(const std::vector& cmake_content) { + // Assume a lines like the following: + // project( ecflow LANGUAGES CXX VERSION X.Y.Z ) + // + // Find token `VERSION` and return the next token + + for (auto& line : cmake_content) { + if (contains(line, "project", "ecflow", "LANGUAGES", "CXX", "VERSION")) { + std::vector tokens; + Str::split(line, tokens); + + auto version_arg = std::find(tokens.begin(), tokens.end(), "VERSION"); + auto version_val = version_arg + 1; + if (version_val != tokens.end()) { + return *version_val; + break; + } + } + } + + return ""; +} + BOOST_AUTO_TEST_SUITE(U_Core) BOOST_AUTO_TEST_SUITE(T_Version) @@ -31,47 +59,38 @@ BOOST_AUTO_TEST_CASE(test_version) { ECF_NAME_THIS_TEST(<< ", found version: " << desc); } +BOOST_AUTO_TEST_CASE(test_version_raw_components) { + ECF_NAME_THIS_TEST(); + + auto actual = Version::raw(); + auto expected = Version::major() + "." + Version::minor() + "." + Version::patch(); + BOOST_CHECK_EQUAL(actual, expected); +} + +BOOST_AUTO_TEST_CASE(test_version_full_components) { + ECF_NAME_THIS_TEST(); + + auto actual = Version::full(); + auto expected = Version::major() + "." + Version::minor() + "." + Version::patch() + Version::suffix(); + BOOST_CHECK_EQUAL(actual, expected); +} + BOOST_AUTO_TEST_CASE(test_version_against_cmake) { ECF_NAME_THIS_TEST(); - // Open the file CMakeList.txt + // Load CMakeList.txt std::string version_cmake_file = File::root_source_dir() + "/CMakeLists.txt"; std::vector lines; - BOOST_REQUIRE_MESSAGE(File::splitFileIntoLines(version_cmake_file, lines, true /* impore empty lines */), + BOOST_REQUIRE_MESSAGE(File::splitFileIntoLines(version_cmake_file, lines, true /* ignore empty lines */), "Failed to open file " << version_cmake_file << " (" << strerror(errno) << ")"); BOOST_REQUIRE_MESSAGE(!lines.empty(), "File " << version_cmake_file << " does not contain version info ??"); - // Expecting lines like: - // project( ecflow LANGUAGES CXX VERSION 5.3.1 ) - // Compare against VERSION - std::string cmake_version; - for (auto& line : lines) { - std::vector tokens; - Str::split(line, tokens); - - if (line.find("project") != std::string::npos && line.find("ecflow") != std::string::npos && - line.find("LANGUAGES") != std::string::npos && line.find("CXX") != std::string::npos && - line.find("VERSION") != std::string::npos) { - for (size_t i = 0; i < tokens.size(); i++) { - if (tokens[i] == "VERSION") { - if (i + 1 < tokens.size()) { - cmake_version = tokens[i + 1]; - break; - } - } - } - } - } + // Find CMake project version + auto actual_version = find_cmake_version(lines); + BOOST_CHECK_MESSAGE(!actual_version.empty(), "Unable to find CMake version in file " << version_cmake_file); - // The if they don't match, we have failed to regenrate and check in ecflow_version.h - BOOST_REQUIRE_MESSAGE(!cmake_version.empty(), - "Expected to find 'project( ecflow LANGUAGES CXX VERSION N.N.N )' in file " - << version_cmake_file); - BOOST_REQUIRE_MESSAGE( - Version::raw() == cmake_version, - "\n Expected " - << cmake_version << " but found " << Version::raw() - << ", Please regenerate file $WK/libs/core/src/ecflow_version.h by calling 'sh -x $WK/cmake.sh'"); + auto expected_version = Version::raw(); + BOOST_CHECK_EQUAL(actual_version, expected_version); } BOOST_AUTO_TEST_SUITE_END() diff --git a/libs/node/src/ecflow/node/Defs.cpp b/libs/node/src/ecflow/node/Defs.cpp index 6df6d5a5a..9bd2bbcb1 100644 --- a/libs/node/src/ecflow/node/Defs.cpp +++ b/libs/node/src/ecflow/node/Defs.cpp @@ -693,7 +693,7 @@ void Defs::print(std::string& os) const { else os.reserve(4096); os += "#"; - os += ecf::Version::raw(); + os += ecf::Version::full(); os += "\n"; if (!PrintStyle::defsStyle()) diff --git a/libs/node/src/ecflow/node/ServerState.cpp b/libs/node/src/ecflow/node/ServerState.cpp index 6fc99f0f0..7e529c863 100644 --- a/libs/node/src/ecflow/node/ServerState.cpp +++ b/libs/node/src/ecflow/node/ServerState.cpp @@ -449,7 +449,7 @@ void ServerState::setup_default_server_variables(std::vector& server_v // in a job can fail easily, but re-running the job will often work server_variables.emplace_back(ecf::environment::ECF_TRIES, string("2")); - server_variables.emplace_back(string("ECF_VERSION"), Version::raw()); // server version + server_variables.emplace_back(string("ECF_VERSION"), Version::full()); // server version // Needed to setup client environment. // The server sets these variable for use by the client. i.e when creating the jobs diff --git a/libs/node/test/TestVariableSubstitution.cpp b/libs/node/test/TestVariableSubstitution.cpp index 088074f6f..60d43f24b 100644 --- a/libs/node/test/TestVariableSubstitution.cpp +++ b/libs/node/test/TestVariableSubstitution.cpp @@ -55,7 +55,7 @@ BOOST_AUTO_TEST_CASE(test_variable_substitution) { BOOST_CHECK_MESSAGE(cmd == expected, "expected '" << expected << "' but found '" << cmd << "'"); cmd = "%ECF_VERSION%"; - expected = Version::raw(); + expected = Version::full(); BOOST_CHECK_MESSAGE(s->variableSubstitution(cmd), "substitution failed"); BOOST_CHECK_MESSAGE(cmd == expected, "expected '" << expected << "' but found '" << cmd << "'"); @@ -438,7 +438,7 @@ BOOST_AUTO_TEST_CASE(test_server_variable_substitution) { cmd += "%"; BOOST_CHECK_MESSAGE(s->variableSubstitution(cmd), " substitution failed for " << i << " : " << cmd); if (i == "ECF_VERSION") { - BOOST_CHECK_MESSAGE(cmd == Version::raw(), "expected '" << Version::raw() << "' but found '" << cmd << "'"); + BOOST_CHECK_MESSAGE(cmd == Version::full(), "expected '" << Version::full() << "' but found '" << cmd << "'"); } } } diff --git a/libs/node/test/TestVariableSubstitutionDefs.cpp b/libs/node/test/TestVariableSubstitutionDefs.cpp index 64d862ecf..d00023f37 100644 --- a/libs/node/test/TestVariableSubstitutionDefs.cpp +++ b/libs/node/test/TestVariableSubstitutionDefs.cpp @@ -50,7 +50,7 @@ BOOST_AUTO_TEST_CASE(test_defs_variable_substitution) { BOOST_CHECK_MESSAGE(cmd == expected, "expected '" << expected << "' but found '" << cmd << "'"); cmd = "%ECF_VERSION%"; - expected = Version::raw(); + expected = Version::full(); BOOST_CHECK_MESSAGE(defs.variableSubsitution(cmd), "substitution failed"); BOOST_CHECK_MESSAGE(cmd == expected, "expected '" << expected << "' but found '" << cmd << "'"); diff --git a/libs/pyext/src/ecflow/python/ExportClient.cpp b/libs/pyext/src/ecflow/python/ExportClient.cpp index 9dbb11070..e0c28ed37 100644 --- a/libs/pyext/src/ecflow/python/ExportClient.cpp +++ b/libs/pyext/src/ecflow/python/ExportClient.cpp @@ -37,7 +37,7 @@ void set_host_port(ClientInvoker* self, const std::string& host, int port) { } std::string version(ClientInvoker* self) { - return ecf::Version::raw(); + return ecf::Version::full(); } std::string server_version(ClientInvoker* self) { self->server_version(); diff --git a/libs/server/src/ecflow/server/ServerEnvironment.cpp b/libs/server/src/ecflow/server/ServerEnvironment.cpp index 4ece70ef6..eaae3f1de 100644 --- a/libs/server/src/ecflow/server/ServerEnvironment.cpp +++ b/libs/server/src/ecflow/server/ServerEnvironment.cpp @@ -389,8 +389,8 @@ void ServerEnvironment::variables(std::vector(the_server_version_str); - return the_server_version; + return TestFixture::client().get_string(); } diff --git a/libs/test/harness/TestFixture.hpp b/libs/test/harness/TestFixture.hpp index e7a53f368..1ff33185f 100644 --- a/libs/test/harness/TestFixture.hpp +++ b/libs/test/harness/TestFixture.hpp @@ -74,16 +74,18 @@ struct TestFixture /// When local just returns ecf.log, when remote return path to log file static std::string pathToLogFile(); - /// Given a task name like "a" find the find the first task matching that name + /// Given a task name like "a" find the first task matching that name /// and returns is abs node path static std::string taskAbsNodePath(const Defs& theDefs, const std::string& taskName); /// Location of the includes used in the ecf file static std::string includes(); - /// returns the server version as an integer. - /// This allows as to ignore some tests, when testing old servers.(with new clients). - static int server_version(); + /// Retrieve the server version + /// + /// This allows to ignore some tests, which is useful when testing old servers using new clients + /// + static const std::string& server_version(); // Use for all comms with server static ClientInvoker& client(); diff --git a/libs/udp/src/ecflow/udp/UDPServerMain.cpp b/libs/udp/src/ecflow/udp/UDPServerMain.cpp index 171d934dd..43c059212 100644 --- a/libs/udp/src/ecflow/udp/UDPServerMain.cpp +++ b/libs/udp/src/ecflow/udp/UDPServerMain.cpp @@ -11,7 +11,7 @@ #include #include -#include "ecflow/core/ecflow_version.h" +#include "ecflow/core/Version.hpp" #include "ecflow/udp/RequestHandler.hpp" #include "ecflow/udp/Trace.hpp" #include "ecflow/udp/UDPServer.hpp" @@ -25,7 +25,7 @@ static std::string ecflow_udp_server_version() { #endif std::ostringstream oss; - oss << "Ecflow UDP" << TAG << "version(" << ECFLOW_RELEASE << "." << ECFLOW_MAJOR << "." << ECFLOW_MINOR << ")"; + oss << "Ecflow UDP" << TAG << "version(" << ecf::Version::full() << ")"; return oss.str(); } From 2e7b4af8bf8f79a9b66e0e12d0c5ee0d9f6d007b Mon Sep 17 00:00:00 2001 From: Marcos Bento Date: Thu, 27 Feb 2025 14:45:17 +0000 Subject: [PATCH 2/2] Rename Version to ..[] --- libs/core/src/ecflow/core/Version.cpp | 50 ++++++++----------- libs/core/src/ecflow/core/Version.hpp | 21 +++----- libs/core/src/ecflow/core/ecflow_version.h.in | 10 ++-- libs/core/test/TestVersion.cpp | 4 +- 4 files changed, 36 insertions(+), 49 deletions(-) diff --git a/libs/core/src/ecflow/core/Version.cpp b/libs/core/src/ecflow/core/Version.cpp index 504a6e0e2..0d9db401a 100644 --- a/libs/core/src/ecflow/core/Version.cpp +++ b/libs/core/src/ecflow/core/Version.cpp @@ -20,9 +20,24 @@ namespace ecf { +std::string Version::major() { + return ECFLOW_VERSION_MAJOR; +} + +std::string Version::minor() { + return ECFLOW_VERSION_MINOR; +} + +std::string Version::patch() { + return ECFLOW_VERSION_PATCH; +} + +std::string Version::suffix() { + return ECFLOW_VERSION_SUFFIX; +}; + std::string Version::description() { std::stringstream ss; - ss << "Ecflow "; #ifdef DEBUG ss << "(debug) "; @@ -38,41 +53,18 @@ std::string Version::description() { return ss.str(); } -std::string Version::version() { - std::string ret = "ecflow_"; - ret += ecf::convert_to(ECFLOW_RELEASE); - ret += "_"; - ret += ecf::convert_to(ECFLOW_MAJOR); - ret += "_"; - ret += ecf::convert_to(ECFLOW_MINOR); - return ret; -} - -std::string Version::raw() { - std::string ret = ecf::convert_to(ECFLOW_RELEASE); +std::string Version::base() { + std::string ret = major(); ret += "."; - ret += ecf::convert_to(ECFLOW_MAJOR); + ret += minor(); ret += "."; - ret += ecf::convert_to(ECFLOW_MINOR); + ret += patch(); return ret; } std::string Version::full() { - return Version::raw() + Version::suffix(); -} - -std::string Version::major() { - return ecf::convert_to(ECFLOW_RELEASE); + return Version::base() + Version::suffix(); } -std::string Version::minor() { - return ecf::convert_to(ECFLOW_MAJOR); -} -std::string Version::patch() { - return ecf::convert_to(ECFLOW_MINOR); -} -std::string Version::suffix() { - return ecf::convert_to(ECFLOW_SUFFIX); -}; std::string Version::boost() { std::stringstream ss; diff --git a/libs/core/src/ecflow/core/Version.hpp b/libs/core/src/ecflow/core/Version.hpp index b61d2cd3f..a645fa3ea 100644 --- a/libs/core/src/ecflow/core/Version.hpp +++ b/libs/core/src/ecflow/core/Version.hpp @@ -31,6 +31,11 @@ class Version { Version(const Version&) = delete; const Version& operator=(const Version&) = delete; + static std::string major(); + static std::string minor(); + static std::string patch(); + static std::string suffix(); + /// /// Creates a string with a descriptive version information, /// including the version of ecFlow and relevant dependencies. @@ -41,25 +46,15 @@ class Version { static std::string description(); /// - /// Creates the ecFlow version, following the template: `ecflow___` + /// Creates the ecFlow version, following the template: `..` /// - static std::string version(); + static std::string base(); /// - /// Creates the ecFlow version, following the template: `..` - /// - static std::string raw(); - - /// - /// Creates the ecFlow version, following the template: `..[]` + /// Creates the ecFlow version, following the template: `..[]` /// static std::string full(); - static std::string major(); - static std::string minor(); - static std::string patch(); - static std::string suffix(); - private: /// Create a string containing the version of the Boost library static std::string boost(); diff --git a/libs/core/src/ecflow/core/ecflow_version.h.in b/libs/core/src/ecflow/core/ecflow_version.h.in index df75df5e6..5d3e6df3a 100644 --- a/libs/core/src/ecflow/core/ecflow_version.h.in +++ b/libs/core/src/ecflow/core/ecflow_version.h.in @@ -12,11 +12,11 @@ #define ecflow_core_ecflow_version_config_H // clang-format off -#define ECFLOW_VERSION "@ecflow_VERSION@" -#define ECFLOW_RELEASE "@ecflow_VERSION_MAJOR@" -#define ECFLOW_MAJOR "@ecflow_VERSION_MINOR@" -#define ECFLOW_MINOR "@ecflow_VERSION_PATCH@" -#define ECFLOW_SUFFIX "@ecflow_VERSION_SUFFIX@" +#define ECFLOW_VERSION "@ecflow_VERSION@" +#define ECFLOW_VERSION_MAJOR "@ecflow_VERSION_MAJOR@" +#define ECFLOW_VERSION_MINOR "@ecflow_VERSION_MINOR@" +#define ECFLOW_VERSION_PATCH "@ecflow_VERSION_PATCH@" +#define ECFLOW_VERSION_SUFFIX "@ecflow_VERSION_SUFFIX@" // available but not used // PROJECT_VERSION=@PROJECT_VERSION@ diff --git a/libs/core/test/TestVersion.cpp b/libs/core/test/TestVersion.cpp index 871768a1a..afd415100 100644 --- a/libs/core/test/TestVersion.cpp +++ b/libs/core/test/TestVersion.cpp @@ -62,7 +62,7 @@ BOOST_AUTO_TEST_CASE(test_version) { BOOST_AUTO_TEST_CASE(test_version_raw_components) { ECF_NAME_THIS_TEST(); - auto actual = Version::raw(); + auto actual = Version::base(); auto expected = Version::major() + "." + Version::minor() + "." + Version::patch(); BOOST_CHECK_EQUAL(actual, expected); } @@ -89,7 +89,7 @@ BOOST_AUTO_TEST_CASE(test_version_against_cmake) { auto actual_version = find_cmake_version(lines); BOOST_CHECK_MESSAGE(!actual_version.empty(), "Unable to find CMake version in file " << version_cmake_file); - auto expected_version = Version::raw(); + auto expected_version = Version::base(); BOOST_CHECK_EQUAL(actual_version, expected_version); }