Files
mongo/jstests/libs/jstestfuzz/hook_utils.js
Zac 591928c619 SERVER-108478 JS formatted by prettier and remove clang-format (#39656)
GitOrigin-RevId: 6c8f6aded47f260aa4f7c231b17dae3302cb1e04
2025-08-21 17:27:09 +00:00

20 lines
879 B
JavaScript

// Utility for defining hooks that get run at various points the fuzzer generated files.
//
// before/afterServerInfo hooks run before and after the fuzzer preamble reaches out to the server
// for information. Use these hooks to prevent server commands in preamble.js from failing.
export function defineFuzzerHooks({
beforeServerInfo: beforeServerInfo = Function.prototype,
afterServerInfo: afterServerInfo = Function.prototype,
} = {}) {
if (typeof TestData === "undefined") {
throw new Error("jstestfuzz tests must be run through resmoke.py");
}
TestData.beforeFuzzerServerInfoHooks = TestData.beforeFuzzerServerInfoHooks || [];
TestData.afterFuzzerServerInfoHooks = TestData.afterFuzzerServerInfoHooks || [];
TestData.beforeFuzzerServerInfoHooks.push(beforeServerInfo);
TestData.afterFuzzerServerInfoHooks.push(afterServerInfo);
}