Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Added test names to VS Code console logs for ruleTestRunner #3458

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"request": "launch",
"program": "${workspaceRoot}/test/ruleTestRunner.ts",
"stopOnEntry": false,
"args": ["run", "test"],
"args": ["--verboseResultHandler"],
"cwd": "${workspaceRoot}",
"preLaunchTask": "tsc",
"runtimeExecutable": null,
Expand Down
9 changes: 6 additions & 3 deletions src/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export function consoleTestResultsHandler(testResults: TestResult[]): boolean {
return didAllTestsPass;
}

export function consoleTestResultHandler(testResult: TestResult): boolean {
export function consoleTestResultHandler(testResult: TestResult, rootTestDirectory?: string): boolean {
// needed to get colors to show up when passing through Grunt
(chalk as any).enabled = true;

Expand All @@ -225,11 +225,14 @@ export function consoleTestResultHandler(testResult: TestResult): boolean {
const fixesDiffResults = diff.diffLines(results.fixesFromLinter, results.fixesFromMarkup);
const didMarkupTestPass = !markupDiffResults.some((hunk) => hunk.added === true || hunk.removed === true);
const didFixesTestPass = !fixesDiffResults.some((hunk) => hunk.added === true || hunk.removed === true);
const testDescriptor = rootTestDirectory === undefined
? ""
: ` ${testResult.directory.substring(rootTestDirectory.length).replace(/\//g, " > ")}`;

if (didMarkupTestPass && didFixesTestPass) {
console.log(chalk.green(" Passed"));
console.log(chalk.green(` Passed${testDescriptor}`));
} else {
console.log(chalk.red(" Failed!"));
console.log(chalk.red(` Failed${testDescriptor}!`));
didAllTestsPass = false;
if (!didMarkupTestPass) {
displayDiffResults(markupDiffResults, MARKUP_FILE_EXTENSION);
Expand Down
8 changes: 6 additions & 2 deletions test/ruleTestRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@ console.log();
console.log(chalk.underline("Testing Lint Rules:"));
/* tslint:enable:no-console */

const testDirectories = glob.sync("test/rules/**/tslint.json").map(path.dirname);
const verboseResultHandler = process.argv.indexOf("--verboseResultHandler") !== -1;
const rootTestDirectory = "test/rules/";
const testDirectories = glob.sync(`${rootTestDirectory}**/tslint.json`).map(path.dirname);

for (const testDirectory of testDirectories) {
const results = runTest(testDirectory);
const didAllTestsPass = consoleTestResultHandler(results);
const didAllTestsPass = verboseResultHandler
? consoleTestResultHandler(results, rootTestDirectory)
: consoleTestResultHandler(results);
if (!didAllTestsPass) {
process.exit(1);
}
Expand Down