Support custom temp and tests directories (#1268) (#1270)

The following user-settable values for CMake are supported:

- TESTS_DIR: Tests directory, is path to unit test data when 'data' is
  appended. Can be used to run the unit tests on a target.
- TESTS_TMPDIR: Directory for temporary files created during unit tests,
  system tmpdir is used if undefined. Has to be defined on systems
  without global temporary directory.
This commit is contained in:
Urs Fleisch
2025-05-01 19:55:46 +02:00
committed by GitHub
parent ee1931b811
commit fbbead3efd
4 changed files with 63 additions and 3 deletions

View File

@ -54,12 +54,14 @@ inline string copyFile(const string &filename, const string &ext)
{
char testFileName[1024];
#ifdef _WIN32
#ifdef TESTS_TMPDIR
snprintf(testFileName, sizeof(testFileName), "%s/taglib-test%s", TESTS_TMPDIR, ext.c_str());
#elif defined _WIN32
char tempDir[MAX_PATH + 1];
GetTempPathA(sizeof(tempDir), tempDir);
wsprintfA(testFileName, "%s\\taglib-test%s", tempDir, ext.c_str());
#else
snprintf(testFileName, sizeof(testFileName), "/%s/taglib-test%s", P_tmpdir, ext.c_str());
snprintf(testFileName, sizeof(testFileName), "%s/taglib-test%s", P_tmpdir, ext.c_str());
#endif
string sourceFileName = testFilePath(filename) + ext;