Skip to content

Commit a7a9b2d

Browse files
committed
Document requirement for coverage.list file, and allow it at the top of relativeTestRoot
1 parent 27b1acc commit a7a9b2d

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ For a workspace using client-side editing, test classes are by default sought in
6565
6666
> By setting this at the workspace level you can have different file layouts for different projects.
6767
68+
To gather test coverage data you will need at least one `coverage.list` file in your tree of test classes. See the Test Coverage Tool documentation for information about what this file should contain.
69+
70+
When using client-side editing your `coverage.list` file(s) must be in or below your `relativeTestRoot` client-side folder.
71+
72+
When using server-side editing, put a single `coverage.list` file in the server-side folder named in your ^UnitTestRoot global.
73+
74+
If no `coverage.list` file is found during a coverage run then the output in the Test Results tab of the VS Code Panel will include the line `No code coverage found (!)`.
75+
6876
## Running Tests
6977
7078
VS Code provides several different ways to run tests.

src/commonRunTestsHandler.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,8 @@ export async function commonRunTestsHandler(controller: vscode.TestController, r
204204
}
205205
}
206206

207-
// No longer rely on ISFS redirection of /.vscode because since ObjectScript v3.0 it no longer works for client-only workspaces.
207+
// Form the ISFS target folder uri and delete any existing content
208+
// Note that authority here is just server name, no :namespace
208209
const testRoot = vscode.Uri.from({ scheme: 'isfs', authority, path: `/_vscode/${namespace}/UnitTestRoot/${username}`, query: "csp&ns=%SYS" });
209210
try {
210211
// Limitation of the Atelier API means this can only delete the files, not the folders
@@ -214,7 +215,7 @@ export async function commonRunTestsHandler(controller: vscode.TestController, r
214215
console.log(error);
215216
}
216217

217-
// Map of uri strings checked for presence of a coverage.list file, recording the relative path of those that were found
218+
// Map of uri strings checked for presence of a coverage.list file, recording the absolute path of those that were found
218219
const mapCoverageLists = new Map<string, string>();
219220
for await (const mapInstance of mapTestClasses) {
220221
const key = mapInstance[0];
@@ -230,7 +231,7 @@ export async function commonRunTestsHandler(controller: vscode.TestController, r
230231
if (['isfs', 'isfs-readonly'].includes(sourceBaseUri.scheme)) {
231232
continue;
232233
}
233-
while (pathParts.length > 1) {
234+
while (pathParts.length > 0) {
234235
const currentPath = pathParts.join('/');
235236
// Check for coverage.list file here
236237
const coverageListUri = sourceBaseUri.with({ path: sourceBaseUri.path.concat(`${currentPath}/coverage.list`) });
@@ -240,7 +241,7 @@ export async function commonRunTestsHandler(controller: vscode.TestController, r
240241
}
241242
try {
242243
await vscode.workspace.fs.stat(coverageListUri);
243-
mapCoverageLists.set(coverageListUri.toString(), currentPath);
244+
mapCoverageLists.set(coverageListUri.toString(), testRoot.path.concat(currentPath));
244245
} catch (error) {
245246
if (error.code !== vscode.FileSystemError.FileNotFound().code) {
246247
console.log(`Error checking for ${coverageListUri.toString()}:`, error);
@@ -255,7 +256,7 @@ export async function commonRunTestsHandler(controller: vscode.TestController, r
255256
if (path.length > 0) {
256257
const coverageListUri = vscode.Uri.parse(uriString, true);
257258
try {
258-
await vscode.workspace.fs.copy(coverageListUri, testRoot.with({ path: testRoot.path.concat(`${path}/coverage.list`) }));
259+
await vscode.workspace.fs.copy(coverageListUri, testRoot.with({ path: `${path}/coverage.list` }));
259260
} catch (error) {
260261
console.log(`Error copying ${coverageListUri.path}:`, error);
261262
}

0 commit comments

Comments
 (0)