Skip to content

Commit f4998d9

Browse files
committed
Creates an empty .expected file when running test output compare
If the expected file does not already exists. This helps with test creation and allows users to create tests more quickly.
1 parent 245496c commit f4998d9

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

extensions/ql-vscode/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## [UNRELEASED]
44

55
- Editors opened by navigating from the results view are no longer opened in _preview mode_. Now they are opened as a persistent editor. [#630](https://github.com/github/vscode-codeql/pull/630)
6+
- When comparing the results of a failed QL test run and the `.expected` file does not exist, an empty `.expected` file is created and compared against the `.actual` file. [#669](https://github.com/github/vscode-codeql/pull/669)
67

78
## 1.3.6 - 4 November 2020
89

@@ -14,6 +15,7 @@
1415
## 1.3.5 - 27 October 2020
1516

1617
- Fix a bug where archived source folders for databases were not showing any contents.
18+
- Fix URI encoding for databases that were created with special characters in their paths.
1719

1820
## 1.3.4 - 22 October 2020
1921

extensions/ql-vscode/src/test-ui.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
import * as fs from 'fs-extra';
22
import * as path from 'path';
33
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';
415
import { TestTreeNode } from './test-tree-node';
516
import { DisposableObject } from './vscode-utils/disposable-object';
617
import { UIService } from './vscode-utils/ui-service';
7-
import { TestHub, TestController, TestAdapter, TestRunStartedEvent, TestRunFinishedEvent, TestEvent, TestSuiteEvent } from 'vscode-test-adapter-api';
818
import { QLTestAdapter, getExpectedFile, getActualFile } from './test-adapter';
919
import { logger } from './logging';
1020

@@ -78,12 +88,17 @@ export class TestUIService extends UIService implements TestController {
7888
preserveFocus: true,
7989
preview: true
8090
};
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+
8197
if (await fs.pathExists(actualPath)) {
8298
const actualUri = Uri.file(actualPath);
8399
await commands.executeCommand<void>('vscode.diff', expectedUri, actualUri,
84100
`Expected vs. Actual for ${path.basename(testId)}`, options);
85-
}
86-
else {
101+
} else {
87102
await window.showTextDocument(expectedUri, options);
88103
}
89104
}

0 commit comments

Comments
 (0)