Skip to content

Commit 8dc9ed0

Browse files
committed
refs #14111 - testrunner: enforce unique filename in ScopedFile to prevent conflicts in parallel execution [skip ci]
1 parent e6e045f commit 8dc9ed0

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

test/helpers.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,22 @@ class SuppressionList;
5050

5151
const Settings SimpleTokenizer::s_settings;
5252

53+
std::set<std::string> ScopedFile::s_scopedfiles;
54+
5355
// TODO: better path-only usage
5456
ScopedFile::ScopedFile(std::string name, const std::string &content, std::string path)
5557
: mName(std::move(name))
5658
, mPath(Path::toNativeSeparators(std::move(path)))
5759
, mFullPath(Path::join(mPath, mName))
5860
{
61+
if (mPath.empty() && mName.empty()) {
62+
throw std::runtime_error("ScopedFile(" + mFullPath + ") - no file specified");
63+
}
64+
65+
if (!s_scopedfiles.emplace(mFullPath).second) {
66+
throw std::runtime_error("ScopedFile(" + mFullPath + ") - file not unique");
67+
}
68+
5969
if (!mPath.empty() && mPath != Path::getCurrentPath()) {
6070
if (Path::isDirectory(mPath))
6171
throw std::runtime_error("ScopedFile(" + mFullPath + ") - directory already exists");

test/helpers.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ class ScopedFile {
157157
const std::string mName;
158158
const std::string mPath;
159159
const std::string mFullPath;
160+
161+
static std::set<std::string> s_scopedfiles;
160162
};
161163

162164
class PreprocessorHelper

0 commit comments

Comments
 (0)