Skip to content

Commit

Permalink
Adjust test-adapter to display diffs only for failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eysk-io committed Aug 17, 2021
1 parent 0093af8 commit 90513ad
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions extensions/ql-vscode/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export interface TestCompleted {
expected: string;
diff: string[] | undefined;
failureDescription?: string;
failureStage?: string;
}

/**
Expand Down
4 changes: 3 additions & 1 deletion extensions/ql-vscode/src/test-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,9 @@ export class QLTestAdapter extends DisposableObject implements TestAdapter {
: 'failed';
let message: string | undefined;
if (event.failureDescription || event.diff?.length) {
message = ['', `${state}: ${event.test}`, event.failureDescription || event.diff?.join('\n'), ''].join('\n');
message = event.failureStage === 'RESULT'
? ['', `${state}: ${event.test}`, event.failureDescription || event.diff?.join('\n'), ''].join('\n')
: ['', `${event.failureStage?.toLowerCase()} error: ${event.test}`, event.failureDescription || `${event.messages[0].severity}: ${event.messages[0].message}`, ''].join('\n');
void testLogger.log(message);
}
this._testStates.fire({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ describe('test-adapter', () => {
type: 'test',
state: 'errored',
test: gPath,
message: `\nerrored: ${gPath}\npqr\nxyz\n`,
message: `\ncompilation error: ${gPath}\nERROR: abc\n`,
decorations: [
{ line: 1, message: 'abc' }
]
Expand Down Expand Up @@ -149,14 +149,16 @@ describe('test-adapter', () => {
pass: false,
diff: ['pqr', 'xyz'],
// a compile error
failureStage: 'COMPILATION',
messages: [
{ position: { line: 1 }, message: 'abc' }
{ position: { line: 1 }, message: 'abc', severity: 'ERROR' }
]
});
yield Promise.resolve({
test: Uri.parse('file:/ab/c/e/f/h.ql').fsPath,
pass: false,
diff: ['jkh', 'tuv'],
failureStage: 'RESULT',
messages: []
});
})()
Expand Down

0 comments on commit 90513ad

Please sign in to comment.