Move getCodeQLForTesting to testing-utils.ts

This commit is contained in:
Michael B. Gale
2026-10-14 14:38:12 +01:00
parent 4a2ca5c068
commit 924990a9c7
6 changed files with 32 additions and 22 deletions

View File

@@ -30,7 +30,13 @@ import {
featureConfig,
FeatureEnablement,
} from "./feature-flags";
import { joinMessageStrings, Loggable, LoggableError, Logger } from "./logging";
import {
getRunnerLogger,
joinMessageStrings,
Loggable,
LoggableError,
Logger,
} from "./logging";
import { OverlayDatabaseMode } from "./overlay/overlay-database-mode";
import { getBundlePlatform } from "./platform";
import { ActionName } from "./status-report";
@@ -1000,3 +1006,15 @@ export function makeTestToken(length: number = 36) {
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
return chars.repeat(Math.ceil(length / chars.length)).slice(0, length);
}
/**
* Get a real, newly created CodeQL instance for testing. The instance refers to
* a non-existent placeholder codeql command, so tests that use this function
* should also stub the toolrunner.ToolRunner constructor.
*/
export async function getCodeQLForTesting(
cmd = "codeql-for-testing",
logger: Logger = getRunnerLogger(true),
): Promise<codeql.CodeQL> {
return codeql.getCodeQLForCmd(logger, cmd, false);
}