mirror of
https://github.com/github/codeql-action.git
synced 2026-11-08 22:19:50 +00:00
Merge branch 'main' into mbg/diagnostics/failed-sarif
This commit is contained in:
@@ -30,7 +30,7 @@ import {
|
||||
featureConfig,
|
||||
FeatureEnablement,
|
||||
} from "./feature-flags";
|
||||
import { Logger } from "./logging";
|
||||
import { joinMessageStrings, Loggable, LoggableError, Logger } from "./logging";
|
||||
import { OverlayDatabaseMode } from "./overlay/overlay-database-mode";
|
||||
import { getBundlePlatform } from "./platform";
|
||||
import { ActionName } from "./status-report";
|
||||
@@ -658,12 +658,13 @@ export class RecordingLogger implements Logger {
|
||||
|
||||
constructor(private readonly logToConsole: boolean = true) {}
|
||||
|
||||
private addMessage(level: LogLevel, message: string | Error): void {
|
||||
this.messages.push({ type: level, message });
|
||||
private addMessage(level: LogLevel, message: LoggableError): void {
|
||||
const joinedMessage = joinMessageStrings(message);
|
||||
this.messages.push({ type: level, message: joinedMessage });
|
||||
|
||||
if (this.logToConsole) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.debug(message);
|
||||
console.debug(joinedMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -684,19 +685,19 @@ export class RecordingLogger implements Logger {
|
||||
return true;
|
||||
}
|
||||
|
||||
debug(message: string) {
|
||||
debug(message: Loggable) {
|
||||
this.addMessage("debug", message);
|
||||
}
|
||||
|
||||
info(message: string) {
|
||||
info(message: Loggable) {
|
||||
this.addMessage("info", message);
|
||||
}
|
||||
|
||||
warning(message: string | Error) {
|
||||
warning(message: LoggableError) {
|
||||
this.addMessage("warning", message);
|
||||
}
|
||||
|
||||
error(message: string | Error) {
|
||||
error(message: LoggableError) {
|
||||
this.addMessage("error", message);
|
||||
}
|
||||
|
||||
@@ -1042,3 +1043,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 = new RecordingLogger(),
|
||||
): Promise<codeql.CodeQL> {
|
||||
return codeql.getCodeQLForCmd(logger, cmd, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user