Skip to content

Commit 913820c

Browse files
committed
More reliably notify of that a test couldn't be run
This might be super broken, but so is my brain right now. For mysterious and supposedly unrelated reasons, I'm incredibly tired! I'm trusting that this code is useful even if it needs improvements. A lot of it assumes that the `path` property of corresponding `TestFile`s will always match, but that might not happen if certain algorithm changes are made, the consequences of which would not be able to be anticipated.
1 parent 2c12805 commit 913820c

File tree

1 file changed

+19
-22
lines changed

1 file changed

+19
-22
lines changed

src/tests/TestsDataProvider.ts

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ export default class TestsDataProvider implements TreeDataProvider<Element> {
171171
throw new Error("This function requires a workspace path.");
172172
}
173173

174-
const ranAll = !tests;
175174
const paths = tests ?? this.files.map((file) => file.path);
176175
const args = ["test", "-A"];
177176

@@ -261,28 +260,26 @@ export default class TestsDataProvider implements TreeDataProvider<Element> {
261260
}
262261
}
263262

264-
if (ranAll) {
265-
const paths = output.map((file) => file.path);
266-
const missingFiles = this.files.filter(
267-
(file) => !paths.includes(file.path),
268-
);
269-
for (
270-
const file of missingFiles
271-
) {
272-
file.children = [new Header("Failed to run")];
273-
}
263+
const newPaths = output.map((file) => file.path);
264+
const missingFiles = this.files.filter(
265+
(file) =>
266+
paths.includes(file.path) && !newPaths.includes(file.path),
267+
);
268+
for (
269+
const file of missingFiles
270+
) {
271+
file.children = [new Header("Failed to run")];
272+
}
274273

275-
if (missingFiles.length) {
276-
const configurationErrorNotificationRequest =
277-
new NotificationRequest(
278-
"co.gwil.deno.notifications.unexpectedEmptiness",
279-
);
280-
configurationErrorNotificationRequest.title =
281-
"Check the console.";
282-
configurationErrorNotificationRequest.body =
283-
"Deno may be failing to run some tests. Check the extension console for logging.";
284-
nova.notifications.add(configurationErrorNotificationRequest);
285-
}
274+
if (missingFiles.length) {
275+
const configurationErrorNotificationRequest =
276+
new NotificationRequest(
277+
"co.gwil.deno.notifications.unexpectedEmptiness",
278+
);
279+
configurationErrorNotificationRequest.title = "Check the console.";
280+
configurationErrorNotificationRequest.body =
281+
"Deno may be failing to run some tests. Check the extension console for logging.";
282+
nova.notifications.add(configurationErrorNotificationRequest);
286283
}
287284

288285
resolve(output);

0 commit comments

Comments
 (0)