|
1 | 1 | import * as fs from 'fs-extra';
|
2 | 2 | import * as path from 'path';
|
3 | 3 | import { Uri, TextDocumentShowOptions, commands, window } from 'vscode';
|
| 4 | +import { |
| 5 | + TestHub, |
| 6 | + TestController, |
| 7 | + TestAdapter, |
| 8 | + TestRunStartedEvent, |
| 9 | + TestRunFinishedEvent, |
| 10 | + TestEvent, |
| 11 | + TestSuiteEvent |
| 12 | +} from 'vscode-test-adapter-api'; |
| 13 | + |
| 14 | +import { showAndLogWarningMessage } from './helpers'; |
4 | 15 | import { TestTreeNode } from './test-tree-node';
|
5 | 16 | import { DisposableObject } from './vscode-utils/disposable-object';
|
6 | 17 | import { UIService } from './vscode-utils/ui-service';
|
7 |
| -import { TestHub, TestController, TestAdapter, TestRunStartedEvent, TestRunFinishedEvent, TestEvent, TestSuiteEvent } from 'vscode-test-adapter-api'; |
8 | 18 | import { QLTestAdapter, getExpectedFile, getActualFile } from './test-adapter';
|
9 | 19 | import { logger } from './logging';
|
10 | 20 |
|
@@ -78,12 +88,17 @@ export class TestUIService extends UIService implements TestController {
|
78 | 88 | preserveFocus: true,
|
79 | 89 | preview: true
|
80 | 90 | };
|
| 91 | + |
| 92 | + if (!await fs.pathExists(expectedPath)) { |
| 93 | + showAndLogWarningMessage(`'${path.basename(expectedPath)}' does not exist. Creating an empty file.`); |
| 94 | + await fs.createFile(expectedPath); |
| 95 | + } |
| 96 | + |
81 | 97 | if (await fs.pathExists(actualPath)) {
|
82 | 98 | const actualUri = Uri.file(actualPath);
|
83 | 99 | await commands.executeCommand<void>('vscode.diff', expectedUri, actualUri,
|
84 | 100 | `Expected vs. Actual for ${path.basename(testId)}`, options);
|
85 |
| - } |
86 |
| - else { |
| 101 | + } else { |
87 | 102 | await window.showTextDocument(expectedUri, options);
|
88 | 103 | }
|
89 | 104 | }
|
|
0 commit comments