summaryrefslogtreecommitdiff
path: root/src/mongo/shell/mongo_main.cpp
diff options
context:
space:
mode:
authorDavid Percy <david.percy@mongodb.com>2022-07-12 20:24:57 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-08-17 15:37:04 +0000
commitb902366ad23713ed7493e121f0218fead287bc6d (patch)
tree762de8a4a020d82ff3cf43faf7a35ba736e37a30 /src/mongo/shell/mongo_main.cpp
parentaca57c0414496efbfaa914343e3b599366f15a14 (diff)
downloadmongo-b902366ad23713ed7493e121f0218fead287bc6d.tar.gz
SERVER-67415 Create golden-data JS suites
Adds two new suites: query_golden_classic and query_golden_cqf, which use the golden-data test framework (docs/golden_data_test_framework.md). These suites diff the expected and actual output instead of using assert.eq and similar functions. This change includes some refactoring of the golden-test classes to avoid pulling the unittest library into the mongo shell.
Diffstat (limited to 'src/mongo/shell/mongo_main.cpp')
-rw-r--r--src/mongo/shell/mongo_main.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/mongo/shell/mongo_main.cpp b/src/mongo/shell/mongo_main.cpp
index 0f5f45f1941..e87f4ee44e5 100644
--- a/src/mongo/shell/mongo_main.cpp
+++ b/src/mongo/shell/mongo_main.cpp
@@ -891,6 +891,19 @@ int mongo_main(int argc, char* argv[]) {
return kInputFileError;
}
+ // If the test began a GoldenTestContext, end it and compare actual/expected results.
+ // NOTE: putting this in ~MongoProgramScope would call it at the end of each load(),
+ // but we only want to call it once the original test file finishes.
+ try {
+ shell_utils::closeGoldenTestContext();
+ } catch (const shell_utils::GoldenTestContextShellFailure& exn) {
+ std::cout << "failed to load: " << shellGlobalParams.files[i] << std::endl;
+ std::cout << exn.toString() << std::endl;
+ exn.diff();
+ std::cout << "exiting with code " << static_cast<int>(kInputFileError) << std::endl;
+ return kInputFileError;
+ }
+
// Check if the process left any running child processes.
std::vector<ProcessId> pids = mongo::shell_utils::getRunningMongoChildProcessIds();