From 3adbde9e3b90e458564b128949e25916fc8f52c4 Mon Sep 17 00:00:00 2001 From: Timothy Hobbs Date: Wed, 5 Jan 2022 12:36:19 +0100 Subject: [PATCH 1/2] Include configured coverage file file names in error This makes it easier to debug "Could not find a Coverage file! --- src/files/filesloader.ts | 2 +- test/files/filesloader.test.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/files/filesloader.ts b/src/files/filesloader.ts index c6d1f3a..5a83c21 100644 --- a/src/files/filesloader.ts +++ b/src/files/filesloader.ts @@ -22,7 +22,7 @@ export class FilesLoader { const fileNames = this.configStore.coverageFileNames; const files = await this.findCoverageInWorkspace(fileNames); if (!files.size) { - window.showWarningMessage("Could not find a Coverage file!"); + window.showWarningMessage("Could not find a Coverage file! Searched for " + fileNames.join(", ")); return new Set(); } return files; diff --git a/test/files/filesloader.test.ts b/test/files/filesloader.test.ts index cfa6897..8c599e0 100644 --- a/test/files/filesloader.test.ts +++ b/test/files/filesloader.test.ts @@ -27,13 +27,14 @@ suite("FilesLoader Tests", () => { test("findCoverageFiles returns an error if no coverage file @unit", async () => { stubConfig.manualCoverageFilePaths = []; + stubConfig.coverageFileNames = ["lcov.info"]; const filesLoader = new FilesLoader(stubConfig); sinon.stub(filesLoader as any, "findCoverageInWorkspace").resolves(new Map()); const stubShowWarningMessage = sinon.spy(vscode.window, "showWarningMessage"); await filesLoader.findCoverageFiles(); - expect(stubShowWarningMessage).to.be.calledWith("Could not find a Coverage file!"); + expect(stubShowWarningMessage).to.be.calledWith("Could not find a Coverage file! Searched for lcov.info"); }); test("findCoverageFiles returns manual coverage paths if set @unit", async () => { From 4e31325f1f8c7b61c0498457ae8be5a5c7060e40 Mon Sep 17 00:00:00 2001 From: Timothy Hobbs Date: Wed, 5 Jan 2022 22:08:43 +0100 Subject: [PATCH 2/2] Run glob in non strict mode, fixes #334 --- src/files/filesloader.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/files/filesloader.ts b/src/files/filesloader.ts index 5a83c21..9696107 100644 --- a/src/files/filesloader.ts +++ b/src/files/filesloader.ts @@ -92,9 +92,16 @@ export class FilesLoader { dot: true, ignore: this.configStore.ignoredPathGlobs, realpath: true, + strict: false, }, (err, files) => { - if (!files || !files.length) { return resolve(new Set()); } + if (!files || !files.length) { + // Show any errors if no file was found. + if (err) { + window.showWarningMessage(`An error occured while looking for the coverage file ${err}`); + } + return resolve(new Set()); + } const setFiles = new Set(); files.forEach((file) => setFiles.add(file)); return resolve(setFiles);