diff --git a/CMakeLists.txt b/CMakeLists.txt index 200c12f..b325771 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -112,8 +112,8 @@ set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}") set(META_APP_DESCRIPTION "Useful C++ classes and routines such as argument parser, IO and conversion utilities") set(META_FEATURES_FOR_COMPILER_DETECTION_HEADER cxx_thread_local) set(META_VERSION_MAJOR 5) -set(META_VERSION_MINOR 4) -set(META_VERSION_PATCH 1) +set(META_VERSION_MINOR 5) +set(META_VERSION_PATCH 0) # find required 3rd party libraries include(3rdParty) diff --git a/tests/testutils.cpp b/tests/testutils.cpp index 8a74f39..f41e1dd 100644 --- a/tests/testutils.cpp +++ b/tests/testutils.cpp @@ -361,8 +361,8 @@ string TestApplication::workingCopyPathAs( * \brief Executes an application with the specified \a args. * \remarks Provides internal implementation of execApp() and execHelperApp(). */ -int execAppInternal(const char *appPath, const char *const *args, std::string &output, std::string &errors, bool suppressLogging, int timeout, - const std::string &newProfilingPath) +static int execAppInternal(const char *appPath, const char *const *args, std::string &output, std::string &errors, bool suppressLogging, int timeout, + const std::string &newProfilingPath, bool enableSearchPath = false) { // print log message if (!suppressLogging) { @@ -460,7 +460,12 @@ int execAppInternal(const char *appPath, const char *const *args, std::string &o } // -> execute application - execv(appPath, const_cast(args)); + if (enableSearchPath) { + execvp(appPath, const_cast(args)); + + } else { + execv(appPath, const_cast(args)); + } cerr << Phrases::Error << "Unable to execute \"" << appPath << "\": execv() failed" << Phrases::EndFlush; exit(-101); } @@ -538,6 +543,22 @@ int execHelperApp(const char *appPath, const char *const *args, std::string &out { return execAppInternal(appPath, args, output, errors, suppressLogging, timeout, string()); } + +/*! + * \brief Executes an application with the specified \a args. + * + * Searches for the location of \a appName among the directories specified by the PATH environment variable. + * + * \remarks + * - Intended to invoke helper applications (eg. to setup test files). Use execApp() and TestApplication::execApp() to + * invoke the application to be tested itself. + * - Currently only supported under UNIX. + */ +int execHelperAppInSearchPath( + const char *appName, const char *const *args, std::string &output, std::string &errors, bool suppressLogging, int timeout) +{ + return execAppInternal(appName, args, output, errors, suppressLogging, timeout, string(), true); +} #endif // PLATFORM_UNIX /*! diff --git a/tests/testutils.h b/tests/testutils.h index 638eff3..4d16901 100644 --- a/tests/testutils.h +++ b/tests/testutils.h @@ -181,6 +181,8 @@ inline CPP_UTILITIES_EXPORT int execApp(const char *const *args, std::string &ou CPP_UTILITIES_EXPORT int execHelperApp( const char *appPath, const char *const *args, std::string &output, std::string &errors, bool suppressLogging = false, int timeout = -1); +CPP_UTILITIES_EXPORT int execHelperAppInSearchPath( + const char *appName, const char *const *args, std::string &output, std::string &errors, bool suppressLogging = false, int timeout = -1); #endif // PLATFORM_UNIX /*!