summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Wawrzyniak <anna.wawrzyniak@mongodb.com>2022-11-15 17:06:39 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-11-15 17:35:27 +0000
commitd9c4ec0cec878db9d785ef4ff58d69c34247b9ed (patch)
treeb45a958c322fe7b14de390108e37aa1eedb3c345
parent493b63c41b1f5c143d24470e21ae6c0714f3f650 (diff)
downloadmongo-d9c4ec0cec878db9d785ef4ff58d69c34247b9ed.tar.gz
SERVER-71330 Golden test framework should produce empty expected output files
-rw-r--r--src/mongo/unittest/golden_test_base.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/mongo/unittest/golden_test_base.cpp b/src/mongo/unittest/golden_test_base.cpp
index e8b6a9b298c..a8c8acd140d 100644
--- a/src/mongo/unittest/golden_test_base.cpp
+++ b/src/mongo/unittest/golden_test_base.cpp
@@ -178,9 +178,11 @@ void GoldenTestContextBase::failResultMismatch(const std::string& actualStr,
fs::path expectedOutputFilePath = getExpectedOutputPath();
writeFile(actualOutputFilePath, actualStr);
- if (expectedStr != boost::none) {
- writeFile(expectedOutputFilePath, *expectedStr);
- }
+
+ // Write empty expected file even if the expected result was not set.
+ // This improves interaction with diff tools that fail or don't show contents if
+ // one of the file is missing.
+ writeFile(expectedOutputFilePath, expectedStr.get_value_or(""));
_onError(message, actualStr, expectedStr);
}