vscode-tmgrammar-test
Version:
Test runner for VSCode textmate grammars
89 lines (88 loc) • 3.98 kB
TypeScript
import { GrammarTestCase, LineAssertion, TestFailure } from "./model";
export interface Reporter {
reportTestResult(filename: string, testCase: GrammarTestCase, failures: TestFailure[]): void;
reportParseError(filename: string, error: any): void;
reportGrammarTestError(filename: string, testCase: GrammarTestCase, reason: any): void;
reportSuiteResult(): void;
}
export declare class CompositeReporter implements Reporter {
private reporters;
constructor(...reporters: Reporter[]);
reportTestResult(filename: string, testCase: GrammarTestCase, failures: TestFailure[]): void;
reportGrammarTestError(filename: string, testCase: GrammarTestCase, reason: any): void;
reportParseError(filename: string, error: any): void;
reportSuiteResult(): void;
}
interface XunitSuite {
readonly file: string;
readonly name: string;
readonly cases: XunitCase[];
}
interface XunitCase {
readonly name: string;
readonly classname?: string;
readonly failures: XunitFailure[];
}
interface XunitFailure {
readonly type: 'error' | 'failure';
readonly message: string;
readonly body: string;
}
declare abstract class XunitReportPerTestReporter implements Reporter, Colorizer {
private reportPath;
private suites;
constructor(reportPath: string);
abstract reportTestResult(filename: string, parsedFile: GrammarTestCase, failures: TestFailure[]): void;
protected abstract caseClassname(filename: string): string | undefined;
protected abstract suiteFailuresCount(suite: XunitSuite): number;
protected abstract suiteErrorsCount(suite: XunitSuite): number;
reportParseError(filename: string, error: any): void;
reportGrammarTestError(filename: string, parsedFile: GrammarTestCase, reason: any): void;
red(text: string): string;
gray(text: string): string;
whiteBright(text: string): string;
protected getSuite(filename: string, parsedFile?: GrammarTestCase): XunitSuite;
protected getCase(suite: XunitSuite, filename: string, assertion: LineAssertion): XunitCase;
reportSuiteResult(): void;
private renderSuite;
private renderCase;
private classnameAttr;
private renderFailure;
private newlineIfHasItems;
private escapedXml;
}
export declare class XunitGenericReporter extends XunitReportPerTestReporter {
constructor(reportPath: string);
reportTestResult(filename: string, parsedFile: GrammarTestCase, failures: TestFailure[]): void;
protected caseClassname(filename: string): undefined;
protected suiteFailuresCount(s: XunitSuite): number;
protected suiteErrorsCount(s: XunitSuite): number;
}
export declare class XunitGitlabReporter extends XunitReportPerTestReporter {
constructor(reportPath: string);
reportTestResult(filename: string, parsedFile: GrammarTestCase, failures: TestFailure[]): void;
protected caseClassname(filename: string): string;
protected suiteFailuresCount(s: XunitSuite): number;
protected suiteErrorsCount(s: XunitSuite): number;
}
declare function handleGrammarTestError(filename: string, testCase: GrammarTestCase, reason: any): void;
declare function handleParseError(filename: string, error: any): void;
export declare class ConsoleCompactReporter implements Reporter {
reportTestResult(filename: string, testCase: GrammarTestCase, failures: TestFailure[]): void;
private renderCompactErrorMsg;
reportParseError: typeof handleParseError;
reportGrammarTestError: typeof handleGrammarTestError;
reportSuiteResult(): void;
}
export declare class ConsoleFullReporter implements Reporter {
reportTestResult(filename: string, testCase: GrammarTestCase, failures: TestFailure[]): void;
reportParseError: typeof handleParseError;
reportGrammarTestError: typeof handleGrammarTestError;
reportSuiteResult(): void;
}
interface Colorizer {
red(text: string): string;
gray(text: string): string;
whiteBright(text: string): string;
}
export {};