Improve documentation of some test utilities
This commit is contained in:
parent
5340a8b6ec
commit
3fe1ea64cf
|
@ -38,6 +38,7 @@ using namespace CppUtilities::EscapeCodes;
|
||||||
*/
|
*/
|
||||||
namespace CppUtilities {
|
namespace CppUtilities {
|
||||||
|
|
||||||
|
/// \cond
|
||||||
bool fileSystemItemExists(const string &path)
|
bool fileSystemItemExists(const string &path)
|
||||||
{
|
{
|
||||||
#ifdef PLATFORM_UNIX
|
#ifdef PLATFORM_UNIX
|
||||||
|
@ -95,6 +96,7 @@ bool makeDir(const string &path)
|
||||||
return CreateDirectoryW(widePath.first.get(), nullptr) || GetLastError() == ERROR_ALREADY_EXISTS;
|
return CreateDirectoryW(widePath.first.get(), nullptr) || GetLastError() == ERROR_ALREADY_EXISTS;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
/// \endcond
|
||||||
|
|
||||||
TestApplication *TestApplication::s_instance = nullptr;
|
TestApplication *TestApplication::s_instance = nullptr;
|
||||||
|
|
||||||
|
@ -106,6 +108,8 @@ TestApplication *TestApplication::s_instance = nullptr;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Constructs a TestApplication instance without further arguments.
|
* \brief Constructs a TestApplication instance without further arguments.
|
||||||
|
* \remarks This constructor skips parsing CLI arguments. Other initialization like reading environment variables
|
||||||
|
* for test file paths and working directories is still done.
|
||||||
* \throws Throws std::runtime_error if an instance has already been created.
|
* \throws Throws std::runtime_error if an instance has already been created.
|
||||||
*/
|
*/
|
||||||
TestApplication::TestApplication()
|
TestApplication::TestApplication()
|
||||||
|
@ -536,6 +540,9 @@ int execHelperApp(const char *appPath, const char *const *args, std::string &out
|
||||||
}
|
}
|
||||||
#endif // PLATFORM_UNIX
|
#endif // PLATFORM_UNIX
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Reads the path of the test file directory from the environment variable TEST_FILE_PATH.
|
||||||
|
*/
|
||||||
string TestApplication::readTestfilePathFromEnv()
|
string TestApplication::readTestfilePathFromEnv()
|
||||||
{
|
{
|
||||||
const char *const testFilesPathEnv = getenv("TEST_FILE_PATH");
|
const char *const testFilesPathEnv = getenv("TEST_FILE_PATH");
|
||||||
|
@ -545,8 +552,15 @@ string TestApplication::readTestfilePathFromEnv()
|
||||||
return argsToString(testFilesPathEnv, '/');
|
return argsToString(testFilesPathEnv, '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Reads the path of the test file directory from the "srcdirref" file.
|
||||||
|
* \remarks That file is supposed to contain the path the the source directory. It is supposed to be stored by the build system in the
|
||||||
|
* same directory as the test executable. The CMake modules contained of these utilities ensure that's the case.
|
||||||
|
*/
|
||||||
string TestApplication::readTestfilePathFromSrcRef()
|
string TestApplication::readTestfilePathFromSrcRef()
|
||||||
{
|
{
|
||||||
|
// find the path of the current executable on platforms supporting "/proc/self/exe"; otherwise assume the current working directory
|
||||||
|
// is the executable path
|
||||||
std::string binaryPath;
|
std::string binaryPath;
|
||||||
#if defined(CPP_UTILITIES_USE_STANDARD_FILESYSTEM) && defined(PLATFORM_UNIX)
|
#if defined(CPP_UTILITIES_USE_STANDARD_FILESYSTEM) && defined(PLATFORM_UNIX)
|
||||||
try {
|
try {
|
||||||
|
@ -557,8 +571,7 @@ string TestApplication::readTestfilePathFromSrcRef()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
try {
|
try {
|
||||||
// read "srcdirref" file which should contain the path of the source directory; this file should have been
|
// read "srcdirref" file which should contain the path of the source directory
|
||||||
// create by the CMake module "TestTarget.cmake"
|
|
||||||
auto srcDirContent(readFile(binaryPath + "srcdirref", 2 * 1024));
|
auto srcDirContent(readFile(binaryPath + "srcdirref", 2 * 1024));
|
||||||
if (srcDirContent.empty()) {
|
if (srcDirContent.empty()) {
|
||||||
cerr << Phrases::Warning << "The file \"srcdirref\" is empty." << Phrases::EndFlush;
|
cerr << Phrases::Warning << "The file \"srcdirref\" is empty." << Phrases::EndFlush;
|
||||||
|
|
Loading…
Reference in New Issue