Show test results for tests with warnings
This commit is contained in:
@@ -156,9 +156,17 @@ type ResolvedQueries = string[];
|
|||||||
type ResolvedTests = string[];
|
type ResolvedTests = string[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A compilation message for a test message (either an error or a warning)
|
* The severity of a compilation message for a test message.
|
||||||
*/
|
*/
|
||||||
interface CompilationMessage {
|
export enum CompilationMessageSeverity {
|
||||||
|
Error = "ERROR",
|
||||||
|
Warning = "WARNING",
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A compilation message for a test message (either an error or a warning).
|
||||||
|
*/
|
||||||
|
export interface CompilationMessage {
|
||||||
/**
|
/**
|
||||||
* The text of the message
|
* The text of the message
|
||||||
*/
|
*/
|
||||||
@@ -170,7 +178,7 @@ interface CompilationMessage {
|
|||||||
/**
|
/**
|
||||||
* The severity of the message
|
* The severity of the message
|
||||||
*/
|
*/
|
||||||
severity: number;
|
severity: CompilationMessageSeverity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ import {
|
|||||||
} from "vscode";
|
} from "vscode";
|
||||||
import { DisposableObject } from "../common/disposable-object";
|
import { DisposableObject } from "../common/disposable-object";
|
||||||
import { QLTestDiscovery } from "./qltest-discovery";
|
import { QLTestDiscovery } from "./qltest-discovery";
|
||||||
import type { CodeQLCliServer } from "../codeql-cli/cli";
|
import type { CodeQLCliServer, CompilationMessage } from "../codeql-cli/cli";
|
||||||
|
import { CompilationMessageSeverity } from "../codeql-cli/cli";
|
||||||
import { getErrorMessage } from "../common/helpers-pure";
|
import { getErrorMessage } from "../common/helpers-pure";
|
||||||
import type { BaseLogger, LogOptions } from "../common/logging";
|
import type { BaseLogger, LogOptions } from "../common/logging";
|
||||||
import type { TestRunner } from "./test-runner";
|
import type { TestRunner } from "./test-runner";
|
||||||
@@ -66,6 +67,23 @@ function changeExtension(p: string, ext: string): string {
|
|||||||
return p.slice(0, -extname(p).length) + ext;
|
return p.slice(0, -extname(p).length) + ext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function compilationMessageToTestMessage(
|
||||||
|
compilationMessage: CompilationMessage,
|
||||||
|
): TestMessage {
|
||||||
|
const location = new Location(
|
||||||
|
Uri.file(compilationMessage.position.fileName),
|
||||||
|
new Range(
|
||||||
|
compilationMessage.position.line - 1,
|
||||||
|
compilationMessage.position.column - 1,
|
||||||
|
compilationMessage.position.endLine - 1,
|
||||||
|
compilationMessage.position.endColumn - 1,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const testMessage = new TestMessage(compilationMessage.message);
|
||||||
|
testMessage.location = location;
|
||||||
|
return testMessage;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the complete text content of the specified file. If there is an error reading the file,
|
* Returns the complete text content of the specified file. If there is an error reading the file,
|
||||||
* an error message is added to `testMessages` and this function returns undefined.
|
* an error message is added to `testMessages` and this function returns undefined.
|
||||||
@@ -398,23 +416,15 @@ export class TestManager extends DisposableObject {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (event.messages?.length > 0) {
|
const errorMessages = event.messages.filter(
|
||||||
|
(m) => m.severity === CompilationMessageSeverity.Error,
|
||||||
|
);
|
||||||
|
if (errorMessages.length > 0) {
|
||||||
// The test didn't make it far enough to produce results. Transform any error messages
|
// The test didn't make it far enough to produce results. Transform any error messages
|
||||||
// into `TestMessage`s and report the test as "errored".
|
// into `TestMessage`s and report the test as "errored".
|
||||||
const testMessages = event.messages.map((m) => {
|
const testMessages = event.messages.map(
|
||||||
const location = new Location(
|
compilationMessageToTestMessage,
|
||||||
Uri.file(m.position.fileName),
|
);
|
||||||
new Range(
|
|
||||||
m.position.line - 1,
|
|
||||||
m.position.column - 1,
|
|
||||||
m.position.endLine - 1,
|
|
||||||
m.position.endColumn - 1,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
const testMessage = new TestMessage(m.message);
|
|
||||||
testMessage.location = location;
|
|
||||||
return testMessage;
|
|
||||||
});
|
|
||||||
testRun.errored(testItem, testMessages, duration);
|
testRun.errored(testItem, testMessages, duration);
|
||||||
} else {
|
} else {
|
||||||
// Results didn't match expectations. Report the test as "failed".
|
// Results didn't match expectations. Report the test as "failed".
|
||||||
@@ -423,6 +433,12 @@ export class TestManager extends DisposableObject {
|
|||||||
// here. Any failed test needs at least one message.
|
// here. Any failed test needs at least one message.
|
||||||
testMessages.push(new TestMessage("Test failed"));
|
testMessages.push(new TestMessage("Test failed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add any warnings produced by the test to the test messages.
|
||||||
|
testMessages.push(
|
||||||
|
...event.messages.map(compilationMessageToTestMessage),
|
||||||
|
);
|
||||||
|
|
||||||
testRun.failed(testItem, testMessages, duration);
|
testRun.failed(testItem, testMessages, duration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user