Skip to content

Commit 89b4f04

Browse files
author
Benjamin Pasero
committed
fix tests (microsoft#91859)
1 parent bc76005 commit 89b4f04

2 files changed

Lines changed: 18 additions & 35 deletions

File tree

src/vs/platform/files/test/electron-browser/diskFileService.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ suite('Disk File Service', function () {
463463
return testDeleteFile(false);
464464
});
465465

466-
test('deleteFile (useTrash)', async () => {
466+
(isLinux /* trash is unreliable on Linux */ ? test.skip : test)('deleteFile (useTrash)', async () => {
467467
return testDeleteFile(true);
468468
});
469469

@@ -543,7 +543,7 @@ suite('Disk File Service', function () {
543543
return testDeleteFolderRecursive(false);
544544
});
545545

546-
test('deleteFolder (recursive, useTrash)', async () => {
546+
(isLinux /* trash is unreliable on Linux */ ? test.skip : test)('deleteFolder (recursive, useTrash)', async () => {
547547
return testDeleteFolderRecursive(true);
548548
});
549549

src/vs/workbench/contrib/backup/test/electron-browser/backupTracker.test.ts

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ suite('BackupTracker', () => {
215215
tracker.dispose();
216216
});
217217

218-
test('confirm onWillShutdown - no veto', async function () {
218+
test('onWillShutdown - no veto if no dirty files', async function () {
219219
const [accessor, part, tracker] = await createTracker();
220220

221221
const resource = toResource.call(this, '/path/index.txt');
@@ -224,18 +224,14 @@ suite('BackupTracker', () => {
224224
const event = new BeforeShutdownEventImpl();
225225
accessor.lifecycleService.fireWillShutdown(event);
226226

227-
const veto = event.value;
228-
if (typeof veto === 'boolean') {
229-
assert.ok(!veto);
230-
} else {
231-
assert.ok(!(await veto));
232-
}
227+
const veto = await event.value;
228+
assert.ok(!veto);
233229

234230
part.dispose();
235231
tracker.dispose();
236232
});
237233

238-
test.skip('confirm onWillShutdown - veto if user cancels', async function () {
234+
test('onWillShutdown - veto if user cancels (hot.exit: off)', async function () {
239235
const [accessor, part, tracker] = await createTracker();
240236

241237
const resource = toResource.call(this, '/path/index.txt');
@@ -244,6 +240,7 @@ suite('BackupTracker', () => {
244240
const model = accessor.textFileService.files.get(resource);
245241

246242
accessor.fileDialogService.setConfirmResult(ConfirmResult.CANCEL);
243+
accessor.filesConfigurationService.onFilesConfigurationChange({ files: { hotExit: 'off' } });
247244

248245
await model?.load();
249246
model?.textEditorModel?.setValue('foo');
@@ -252,12 +249,8 @@ suite('BackupTracker', () => {
252249
const event = new BeforeShutdownEventImpl();
253250
accessor.lifecycleService.fireWillShutdown(event);
254251

255-
const veto = event.value;
256-
if (typeof veto === 'boolean') {
257-
assert.ok(veto);
258-
} else {
259-
assert.ok((await veto));
260-
}
252+
const veto = await event.value;
253+
assert.ok(veto);
261254

262255
part.dispose();
263256
tracker.dispose();
@@ -278,20 +271,16 @@ suite('BackupTracker', () => {
278271
const event = new BeforeShutdownEventImpl();
279272
accessor.lifecycleService.fireWillShutdown(event);
280273

281-
const veto = event.value;
282-
if (typeof veto === 'boolean') {
283-
assert.ok(!veto);
284-
} else {
285-
assert.ok(!(await veto));
286-
}
274+
const veto = await event.value;
275+
assert.ok(!veto);
287276

288277
assert.equal(accessor.workingCopyService.dirtyCount, 0);
289278

290279
part.dispose();
291280
tracker.dispose();
292281
});
293282

294-
test('confirm onWillShutdown - no veto and backups cleaned up if user does not want to save (hot.exit: off)', async function () {
283+
test('onWillShutdown - no veto and backups cleaned up if user does not want to save (hot.exit: off)', async function () {
295284
const [accessor, part, tracker] = await createTracker();
296285

297286
const resource = toResource.call(this, '/path/index.txt');
@@ -308,21 +297,15 @@ suite('BackupTracker', () => {
308297
const event = new BeforeShutdownEventImpl();
309298
accessor.lifecycleService.fireWillShutdown(event);
310299

311-
let veto = event.value;
312-
if (typeof veto === 'boolean') {
313-
assert.ok(accessor.backupFileService.discardedBackups.length > 0);
314-
assert.ok(!veto);
315-
} else {
316-
veto = await veto;
317-
assert.ok(accessor.backupFileService.discardedBackups.length > 0);
318-
assert.ok(!veto);
319-
}
300+
const veto = await event.value;
301+
assert.ok(!veto);
302+
assert.ok(accessor.backupFileService.discardedBackups.length > 0);
320303

321304
part.dispose();
322305
tracker.dispose();
323306
});
324307

325-
test('confirm onWillShutdown - save (hot.exit: off)', async function () {
308+
test('onWillShutdown - save (hot.exit: off)', async function () {
326309
const [accessor, part, tracker] = await createTracker();
327310

328311
const resource = toResource.call(this, '/path/index.txt');
@@ -339,7 +322,7 @@ suite('BackupTracker', () => {
339322
const event = new BeforeShutdownEventImpl();
340323
accessor.lifecycleService.fireWillShutdown(event);
341324

342-
const veto = await (<Promise<boolean>>event.value);
325+
const veto = await event.value;
343326
assert.ok(!veto);
344327
assert.ok(!model?.isDirty());
345328

@@ -482,7 +465,7 @@ suite('BackupTracker', () => {
482465
event.reason = shutdownReason;
483466
accessor.lifecycleService.fireWillShutdown(event);
484467

485-
const veto = await (<Promise<boolean>>event.value);
468+
const veto = await event.value;
486469
assert.equal(accessor.backupFileService.discardedBackups.length, 0); // When hot exit is set, backups should never be cleaned since the confirm result is cancel
487470
assert.equal(veto, shouldVeto);
488471

0 commit comments

Comments
 (0)