Skip to content

Commit

Permalink
Bump verbosity of database finalize in debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Mercer committed Mar 13, 2024
1 parent 649f3e8 commit 070b051
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lib/analyze.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/analyze.js.map

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion lib/codeql.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/codeql.js.map

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions lib/codeql.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/codeql.test.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/analyze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ async function finalizeDatabaseCreation(
util.getCodeQLDatabasePath(config, language),
threadsFlag,
memoryFlag,
config.debugMode,
);
logger.endGroup();
}
Expand Down
25 changes: 20 additions & 5 deletions src/codeql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ test("database finalize recognises JavaScript no code found error on CodeQL 2.11
sinon.stub(safeWhich, "safeWhich").resolves("");

await t.throwsAsync(
async () => await codeqlObject.finalizeDatabase("", "", ""),
async () => await codeqlObject.finalizeDatabase("", "", "", false),
{
instanceOf: util.ConfigurationError,
message: new RegExp(
Expand All @@ -892,7 +892,7 @@ test("database finalize overrides no code found error on CodeQL 2.11.6", async (
sinon.stub(safeWhich, "safeWhich").resolves("");

await t.throwsAsync(
async () => await codeqlObject.finalizeDatabase("", "", ""),
async () => await codeqlObject.finalizeDatabase("", "", "", false),
{
instanceOf: util.ConfigurationError,
message: new RegExp(
Expand All @@ -915,7 +915,12 @@ test("database finalize does not override no code found error on CodeQL 2.12.4",

await t.throwsAsync(
async () =>
await codeqlObject.finalizeDatabase("db", "--threads=2", "--ram=2048"),
await codeqlObject.finalizeDatabase(
"db",
"--threads=2",
"--ram=2048",
false,
),
{
message:
'Encountered a fatal error while running "codeql-for-testing database finalize --finalize-dataset --threads=2 --ram=2048 db". ' +
Expand All @@ -940,7 +945,12 @@ test("runTool summarizes several fatal errors", async (t) => {

await t.throwsAsync(
async () =>
await codeqlObject.finalizeDatabase("db", "--threads=2", "--ram=2048"),
await codeqlObject.finalizeDatabase(
"db",
"--threads=2",
"--ram=2048",
false,
),
{
instanceOf: util.ConfigurationError,
message: new RegExp(
Expand All @@ -967,7 +977,12 @@ test("runTool outputs last line of stderr if fatal error could not be found", as

await t.throwsAsync(
async () =>
await codeqlObject.finalizeDatabase("db", "--threads=2", "--ram=2048"),
await codeqlObject.finalizeDatabase(
"db",
"--threads=2",
"--ram=2048",
false,
),
{
instanceOf: util.ConfigurationError,
message: new RegExp(
Expand Down
5 changes: 5 additions & 0 deletions src/codeql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export interface CodeQL {
databasePath: string,
threadsFlag: string,
memoryFlag: string,
enableDebugLogging: boolean,
): Promise<void>;
/**
* Run 'codeql resolve languages'.
Expand Down Expand Up @@ -715,13 +716,17 @@ export async function getCodeQLForCmd(
databasePath: string,
threadsFlag: string,
memoryFlag: string,
enableDebugLogging: boolean,
) {
const args = [
"database",
"finalize",
"--finalize-dataset",
threadsFlag,
memoryFlag,
...(enableDebugLogging
? [`--verbosity=${EXTRACTION_DEBUG_MODE_VERBOSITY}`]
: []),
...getExtraOptionsFromEnv(["database", "finalize"]),
databasePath,
];
Expand Down

0 comments on commit 070b051

Please sign in to comment.