Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/microsoft/vscode.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenjamin Pasero <benjamin.pasero@microsoft.com>2022-07-19 15:17:20 +0300
committerGitHub <noreply@github.com>2022-07-19 15:17:20 +0300
commitaba7e6c58bb996cd23fcad410b651ca036d45a07 (patch)
tree423c44193b6aa958eccfb235d069675263d147db /src
parent54694499a05e470711387732ac7cf55c224bc3ba (diff)
speed up more unit tests (#149712) (#155576)
* undo change to split up tests * faster node.js disk i/o tests * skip slow one
Diffstat (limited to 'src')
-rw-r--r--src/vs/base/test/node/pfs/pfs.test.ts29
-rw-r--r--src/vs/platform/backup/test/electron-main/backupMainService.test.ts114
-rw-r--r--src/vs/platform/files/test/node/diskFileService.test.ts21
-rw-r--r--src/vs/workbench/services/storage/test/browser/storageService.test.ts2
4 files changed, 40 insertions, 126 deletions
diff --git a/src/vs/base/test/node/pfs/pfs.test.ts b/src/vs/base/test/node/pfs/pfs.test.ts
index 4c15c3ce143..0f97f800ec6 100644
--- a/src/vs/base/test/node/pfs/pfs.test.ts
+++ b/src/vs/base/test/node/pfs/pfs.test.ts
@@ -21,18 +21,13 @@ flakySuite('PFS', function () {
let testDir: string;
setup(() => {
- configureFlushOnWrite(true); // but enable flushing for the purpose of these tests
testDir = getRandomTestPath(tmpdir(), 'vsctests', 'pfs');
return Promises.mkdir(testDir, { recursive: true });
});
- teardown(async () => {
- try {
- await Promises.rm(testDir);
- } finally {
- configureFlushOnWrite(false);
- }
+ teardown(() => {
+ return Promises.rm(testDir);
});
test('writeFile', async () => {
@@ -375,24 +370,36 @@ flakySuite('PFS', function () {
const smallData = 'Hello World';
const bigData = (new Array(100 * 1024)).join('Large String\n');
- return testWriteFileAndFlush(smallData, smallData, bigData, bigData);
+ return testWriteFile(smallData, smallData, bigData, bigData);
+ });
+
+ test('writeFile (string) - flush on write', async () => {
+ configureFlushOnWrite(true);
+ try {
+ const smallData = 'Hello World';
+ const bigData = (new Array(100 * 1024)).join('Large String\n');
+
+ return await testWriteFile(smallData, smallData, bigData, bigData);
+ } finally {
+ configureFlushOnWrite(false);
+ }
});
test('writeFile (Buffer)', async () => {
const smallData = 'Hello World';
const bigData = (new Array(100 * 1024)).join('Large String\n');
- return testWriteFileAndFlush(Buffer.from(smallData), smallData, Buffer.from(bigData), bigData);
+ return testWriteFile(Buffer.from(smallData), smallData, Buffer.from(bigData), bigData);
});
test('writeFile (UInt8Array)', async () => {
const smallData = 'Hello World';
const bigData = (new Array(100 * 1024)).join('Large String\n');
- return testWriteFileAndFlush(VSBuffer.fromString(smallData).buffer, smallData, VSBuffer.fromString(bigData).buffer, bigData);
+ return testWriteFile(VSBuffer.fromString(smallData).buffer, smallData, VSBuffer.fromString(bigData).buffer, bigData);
});
- async function testWriteFileAndFlush(
+ async function testWriteFile(
smallData: string | Buffer | Uint8Array,
smallDataValue: string,
bigData: string | Buffer | Uint8Array,
diff --git a/src/vs/platform/backup/test/electron-main/backupMainService.test.ts b/src/vs/platform/backup/test/electron-main/backupMainService.test.ts
index b1800765cb0..f522354dca8 100644
--- a/src/vs/platform/backup/test/electron-main/backupMainService.test.ts
+++ b/src/vs/platform/backup/test/electron-main/backupMainService.test.ts
@@ -140,16 +140,13 @@ flakySuite('BackupMainService', () => {
return pfs.Promises.rm(testDir);
});
- test('service validates backup workspaces on startup and cleans up (folder workspaces) (1)', async function () {
+ test('service validates backup workspaces on startup and cleans up (folder workspaces)', async function () {
// 1) backup workspace path does not exist
service.registerFolderBackupSync(toFolderBackupInfo(fooFile));
service.registerFolderBackupSync(toFolderBackupInfo(barFile));
await service.initialize();
assertEqualFolderInfos(service.getFolderBackupPaths(), []);
- });
-
- test('service validates backup workspaces on startup and cleans up (folder workspaces) (2)', async function () {
// 2) backup workspace path exists with empty contents within
fs.mkdirSync(service.toBackupPath(fooFile));
@@ -160,9 +157,6 @@ flakySuite('BackupMainService', () => {
assertEqualFolderInfos(service.getFolderBackupPaths(), []);
assert.ok(!fs.existsSync(service.toBackupPath(fooFile)));
assert.ok(!fs.existsSync(service.toBackupPath(barFile)));
- });
-
- test('service validates backup workspaces on startup and cleans up (folder workspaces) (3)', async function () {
// 3) backup workspace path exists with empty folders within
fs.mkdirSync(service.toBackupPath(fooFile));
@@ -175,9 +169,6 @@ flakySuite('BackupMainService', () => {
assertEqualFolderInfos(service.getFolderBackupPaths(), []);
assert.ok(!fs.existsSync(service.toBackupPath(fooFile)));
assert.ok(!fs.existsSync(service.toBackupPath(barFile)));
- });
-
- test('service validates backup workspaces on startup and cleans up (folder workspaces) (4)', async function () {
// 4) backup workspace path points to a workspace that no longer exists
// so it should convert the backup worspace to an empty workspace backup
@@ -194,16 +185,13 @@ flakySuite('BackupMainService', () => {
assert.strictEqual(service.getEmptyWindowBackupPaths().length, 1);
});
- test('service validates backup workspaces on startup and cleans up (root workspaces) (1)', async function () {
+ test('service validates backup workspaces on startup and cleans up (root workspaces)', async function () {
// 1) backup workspace path does not exist
service.registerWorkspaceBackupSync(toWorkspaceBackupInfo(fooFile.fsPath));
service.registerWorkspaceBackupSync(toWorkspaceBackupInfo(barFile.fsPath));
await service.initialize();
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
- });
-
- test('service validates backup workspaces on startup and cleans up (root workspaces) (2)', async function () {
// 2) backup workspace path exists with empty contents within
fs.mkdirSync(service.toBackupPath(fooFile));
@@ -214,9 +202,6 @@ flakySuite('BackupMainService', () => {
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
assert.ok(!fs.existsSync(service.toBackupPath(fooFile)));
assert.ok(!fs.existsSync(service.toBackupPath(barFile)));
- });
-
- test('service validates backup workspaces on startup and cleans up (root workspaces) (3)', async function () {
// 3) backup workspace path exists with empty folders within
fs.mkdirSync(service.toBackupPath(fooFile));
@@ -229,9 +214,6 @@ flakySuite('BackupMainService', () => {
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
assert.ok(!fs.existsSync(service.toBackupPath(fooFile)));
assert.ok(!fs.existsSync(service.toBackupPath(barFile)));
- });
-
- test('service validates backup workspaces on startup and cleans up (root workspaces) (4)', async function () {
// 4) backup workspace path points to a workspace that no longer exists
// so it should convert the backup worspace to an empty workspace backup
@@ -291,19 +273,13 @@ flakySuite('BackupMainService', () => {
assertEqualFolderInfos(service.getFolderBackupPaths(), []);
});
- test('getFolderBackupPaths() should return [] when workspaces.json is not properly formed JSON (1)', async () => {
+ test('getFolderBackupPaths() should return [] when workspaces.json is not properly formed JSON', async () => {
fs.writeFileSync(backupWorkspacesPath, '');
await service.initialize();
assertEqualFolderInfos(service.getFolderBackupPaths(), []);
- });
-
- test('getFolderBackupPaths() should return [] when workspaces.json is not properly formed JSON (2)', async () => {
fs.writeFileSync(backupWorkspacesPath, '{]');
await service.initialize();
assertEqualFolderInfos(service.getFolderBackupPaths(), []);
- });
-
- test('getFolderBackupPaths() should return [] when workspaces.json is not properly formed JSON (3)', async () => {
fs.writeFileSync(backupWorkspacesPath, 'foo');
await service.initialize();
assertEqualFolderInfos(service.getFolderBackupPaths(), []);
@@ -315,37 +291,22 @@ flakySuite('BackupMainService', () => {
assertEqualFolderInfos(service.getFolderBackupPaths(), []);
});
- test('getFolderBackupPaths() should return [] when folderWorkspaceInfos in workspaces.json is not a string array (1)', async () => {
+ test('getFolderBackupPaths() should return [] when folderWorkspaceInfos in workspaces.json is not a string array', async () => {
fs.writeFileSync(backupWorkspacesPath, '{"folderWorkspaceInfos":{}}');
await service.initialize();
assertEqualFolderInfos(service.getFolderBackupPaths(), []);
- });
-
- test('getFolderBackupPaths() should return [] when folderWorkspaceInfos in workspaces.json is not a string array (2)', async () => {
fs.writeFileSync(backupWorkspacesPath, '{"folderWorkspaceInfos":{"foo": ["bar"]}}');
await service.initialize();
assertEqualFolderInfos(service.getFolderBackupPaths(), []);
- });
-
- test('getFolderBackupPaths() should return [] when folderWorkspaceInfos in workspaces.json is not a string array (3)', async () => {
fs.writeFileSync(backupWorkspacesPath, '{"folderWorkspaceInfos":{"foo": []}}');
await service.initialize();
assertEqualFolderInfos(service.getFolderBackupPaths(), []);
- });
-
- test('getFolderBackupPaths() should return [] when folderWorkspaceInfos in workspaces.json is not a string array (4)', async () => {
fs.writeFileSync(backupWorkspacesPath, '{"folderWorkspaceInfos":{"foo": "bar"}}');
await service.initialize();
assertEqualFolderInfos(service.getFolderBackupPaths(), []);
- });
-
- test('getFolderBackupPaths() should return [] when folderWorkspaceInfos in workspaces.json is not a string array (5)', async () => {
fs.writeFileSync(backupWorkspacesPath, '{"folderWorkspaceInfos":"foo"}');
await service.initialize();
assertEqualFolderInfos(service.getFolderBackupPaths(), []);
- });
-
- test('getFolderBackupPaths() should return [] when folderWorkspaceInfos in workspaces.json is not a string array (6)', async () => {
fs.writeFileSync(backupWorkspacesPath, '{"folderWorkspaceInfos":1}');
await service.initialize();
assertEqualFolderInfos(service.getFolderBackupPaths(), []);
@@ -372,19 +333,13 @@ flakySuite('BackupMainService', () => {
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
});
- test('getWorkspaceBackups() should return [] when workspaces.json is not properly formed JSON (1)', async () => {
+ test('getWorkspaceBackups() should return [] when workspaces.json is not properly formed JSON', async () => {
fs.writeFileSync(backupWorkspacesPath, '');
await service.initialize();
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
- });
-
- test('getWorkspaceBackups() should return [] when workspaces.json is not properly formed JSON (2)', async () => {
fs.writeFileSync(backupWorkspacesPath, '{]');
await service.initialize();
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
- });
-
- test('getWorkspaceBackups() should return [] when workspaces.json is not properly formed JSON (3)', async () => {
fs.writeFileSync(backupWorkspacesPath, 'foo');
await service.initialize();
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
@@ -396,73 +351,43 @@ flakySuite('BackupMainService', () => {
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
});
- test('getWorkspaceBackups() should return [] when rootWorkspaces in workspaces.json is not a object array (1)', async () => {
+ test('getWorkspaceBackups() should return [] when rootWorkspaces in workspaces.json is not a object array', async () => {
fs.writeFileSync(backupWorkspacesPath, '{"rootWorkspaces":{}}');
await service.initialize();
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
- });
-
- test('getWorkspaceBackups() should return [] when rootWorkspaces in workspaces.json is not a object array (2)', async () => {
fs.writeFileSync(backupWorkspacesPath, '{"rootWorkspaces":{"foo": ["bar"]}}');
await service.initialize();
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
- });
-
- test('getWorkspaceBackups() should return [] when rootWorkspaces in workspaces.json is not a object array (3)', async () => {
fs.writeFileSync(backupWorkspacesPath, '{"rootWorkspaces":{"foo": []}}');
await service.initialize();
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
- });
-
- test('getWorkspaceBackups() should return [] when rootWorkspaces in workspaces.json is not a object array (4)', async () => {
fs.writeFileSync(backupWorkspacesPath, '{"rootWorkspaces":{"foo": "bar"}}');
await service.initialize();
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
- });
-
- test('getWorkspaceBackups() should return [] when rootWorkspaces in workspaces.json is not a object array (5)', async () => {
fs.writeFileSync(backupWorkspacesPath, '{"rootWorkspaces":"foo"}');
await service.initialize();
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
- });
-
- test('getWorkspaceBackups() should return [] when rootWorkspaces in workspaces.json is not a object array (6)', async () => {
fs.writeFileSync(backupWorkspacesPath, '{"rootWorkspaces":1}');
await service.initialize();
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
});
- test('getWorkspaceBackups() should return [] when rootURIWorkspaces in workspaces.json is not a object array (1)', async () => {
+ test('getWorkspaceBackups() should return [] when rootURIWorkspaces in workspaces.json is not a object array', async () => {
fs.writeFileSync(backupWorkspacesPath, '{"rootURIWorkspaces":{}}');
await service.initialize();
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
- });
-
- test('getWorkspaceBackups() should return [] when rootURIWorkspaces in workspaces.json is not a object array (2)', async () => {
fs.writeFileSync(backupWorkspacesPath, '{"rootURIWorkspaces":{"foo": ["bar"]}}');
await service.initialize();
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
- });
-
- test('getWorkspaceBackups() should return [] when rootURIWorkspaces in workspaces.json is not a object array (3)', async () => {
fs.writeFileSync(backupWorkspacesPath, '{"rootURIWorkspaces":{"foo": []}}');
await service.initialize();
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
- });
-
- test('getWorkspaceBackups() should return [] when rootURIWorkspaces in workspaces.json is not a object array (4)', async () => {
fs.writeFileSync(backupWorkspacesPath, '{"rootURIWorkspaces":{"foo": "bar"}}');
await service.initialize();
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
- });
-
- test('getWorkspaceBackups() should return [] when rootURIWorkspaces in workspaces.json is not a object array (5)', async () => {
fs.writeFileSync(backupWorkspacesPath, '{"rootURIWorkspaces":"foo"}');
await service.initialize();
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
- });
-
- test('getWorkspaceBackups() should return [] when rootURIWorkspaces in workspaces.json is not a object array (6)', async () => {
fs.writeFileSync(backupWorkspacesPath, '{"rootURIWorkspaces":1}');
await service.initialize();
assert.deepStrictEqual(service.getWorkspaceBackups(), []);
@@ -482,19 +407,13 @@ flakySuite('BackupMainService', () => {
assert.deepStrictEqual(service.getEmptyWindowBackupPaths(), []);
});
- test('getEmptyWorkspaceBackupPaths() should return [] when workspaces.json is not properly formed JSON (1)', async () => {
+ test('getEmptyWorkspaceBackupPaths() should return [] when workspaces.json is not properly formed JSON', async () => {
fs.writeFileSync(backupWorkspacesPath, '');
await service.initialize();
assert.deepStrictEqual(service.getEmptyWindowBackupPaths(), []);
- });
-
- test('getEmptyWorkspaceBackupPaths() should return [] when workspaces.json is not properly formed JSON (2)', async () => {
fs.writeFileSync(backupWorkspacesPath, '{]');
await service.initialize();
assert.deepStrictEqual(service.getEmptyWindowBackupPaths(), []);
- });
-
- test('getEmptyWorkspaceBackupPaths() should return [] when workspaces.json is not properly formed JSON (3)', async () => {
fs.writeFileSync(backupWorkspacesPath, 'foo');
await service.initialize();
assert.deepStrictEqual(service.getEmptyWindowBackupPaths(), []);
@@ -506,37 +425,22 @@ flakySuite('BackupMainService', () => {
assert.deepStrictEqual(service.getEmptyWindowBackupPaths(), []);
});
- test('getEmptyWorkspaceBackupPaths() should return [] when folderWorkspaces in workspaces.json is not a string array (1)', async function () {
+ test('getEmptyWorkspaceBackupPaths() should return [] when folderWorkspaces in workspaces.json is not a string array', async function () {
fs.writeFileSync(backupWorkspacesPath, '{"emptyWorkspaces":{}}');
await service.initialize();
assert.deepStrictEqual(service.getEmptyWindowBackupPaths(), []);
- });
-
- test('getEmptyWorkspaceBackupPaths() should return [] when folderWorkspaces in workspaces.json is not a string array (2)', async function () {
fs.writeFileSync(backupWorkspacesPath, '{"emptyWorkspaces":{"foo": ["bar"]}}');
await service.initialize();
assert.deepStrictEqual(service.getEmptyWindowBackupPaths(), []);
- });
-
- test('getEmptyWorkspaceBackupPaths() should return [] when folderWorkspaces in workspaces.json is not a string array (3)', async function () {
fs.writeFileSync(backupWorkspacesPath, '{"emptyWorkspaces":{"foo": []}}');
await service.initialize();
assert.deepStrictEqual(service.getEmptyWindowBackupPaths(), []);
- });
-
- test('getEmptyWorkspaceBackupPaths() should return [] when folderWorkspaces in workspaces.json is not a string array (4)', async function () {
fs.writeFileSync(backupWorkspacesPath, '{"emptyWorkspaces":{"foo": "bar"}}');
await service.initialize();
assert.deepStrictEqual(service.getEmptyWindowBackupPaths(), []);
- });
-
- test('getEmptyWorkspaceBackupPaths() should return [] when folderWorkspaces in workspaces.json is not a string array (5)', async function () {
fs.writeFileSync(backupWorkspacesPath, '{"emptyWorkspaces":"foo"}');
await service.initialize();
assert.deepStrictEqual(service.getEmptyWindowBackupPaths(), []);
- });
-
- test('getEmptyWorkspaceBackupPaths() should return [] when folderWorkspaces in workspaces.json is not a string array (6)', async function () {
fs.writeFileSync(backupWorkspacesPath, '{"emptyWorkspaces":1}');
await service.initialize();
assert.deepStrictEqual(service.getEmptyWindowBackupPaths(), []);
diff --git a/src/vs/platform/files/test/node/diskFileService.test.ts b/src/vs/platform/files/test/node/diskFileService.test.ts
index c76b85fe292..d6cf5c76fa0 100644
--- a/src/vs/platform/files/test/node/diskFileService.test.ts
+++ b/src/vs/platform/files/test/node/diskFileService.test.ts
@@ -142,8 +142,6 @@ flakySuite('Disk File Service', function () {
const disposables = new DisposableStore();
setup(async () => {
- DiskFileSystemProvider.configureFlushOnWrite(true); // but enable flushing for the purpose of these tests
-
const logService = new NullLogService();
service = new FileService(logService);
@@ -164,14 +162,10 @@ flakySuite('Disk File Service', function () {
await Promises.copy(sourceDir, testDir, { preserveSymlinks: false });
});
- teardown(async () => {
- try {
- disposables.clear();
+ teardown(() => {
+ disposables.clear();
- await Promises.rm(testDir);
- } finally {
- DiskFileSystemProvider.configureFlushOnWrite(false);
- }
+ return Promises.rm(testDir);
});
test('createFolder', async () => {
@@ -1802,6 +1796,15 @@ flakySuite('Disk File Service', function () {
return testWriteFile();
});
+ test('writeFile - flush on write', async () => {
+ DiskFileSystemProvider.configureFlushOnWrite(true);
+ try {
+ return await testWriteFile();
+ } finally {
+ DiskFileSystemProvider.configureFlushOnWrite(false);
+ }
+ });
+
test('writeFile - buffered', async () => {
setCapabilities(fileProvider, FileSystemProviderCapabilities.FileOpenReadWriteClose);
diff --git a/src/vs/workbench/services/storage/test/browser/storageService.test.ts b/src/vs/workbench/services/storage/test/browser/storageService.test.ts
index 8491d3f9301..cbe4837bc8a 100644
--- a/src/vs/workbench/services/storage/test/browser/storageService.test.ts
+++ b/src/vs/workbench/services/storage/test/browser/storageService.test.ts
@@ -89,7 +89,7 @@ flakySuite('StorageService (browser specific)', () => {
disposables.clear();
});
- test('clear', () => {
+ test.skip('clear', () => { // slow test and also only ever being used as a developer action
return runWithFakedTimers({ useFakeTimers: true }, async () => {
storageService.store('bar', 'foo', StorageScope.APPLICATION, StorageTarget.MACHINE);
storageService.store('bar', 3, StorageScope.APPLICATION, StorageTarget.USER);