diff --git a/src/vs/base/node/pfs.ts b/src/vs/base/node/pfs.ts index ace8ab95710..d1f1ca1474f 100644 --- a/src/vs/base/node/pfs.ts +++ b/src/vs/base/node/pfs.ts @@ -509,15 +509,15 @@ export async function move(source: string, target: string): Promise { } } -export async function copy(source: string, target: string, copiedSourcesIn?: { [path: string]: boolean }): Promise { +export async function copy(source: string, target: string, handledSourcesIn?: { [path: string]: boolean }): Promise { // Keep track of paths already copied to prevent // cycles from symbolic links to cause issues - const copiedSources = copiedSourcesIn ?? Object.create(null); - if (copiedSources[source]) { + const handledSources = handledSourcesIn ?? Object.create(null); + if (handledSources[source]) { return; } else { - copiedSources[source] = true; + handledSources[source] = true; } const { stat, symbolicLink } = await statLink(source); @@ -536,7 +536,7 @@ export async function copy(source: string, target: string, copiedSourcesIn?: { [ const files = await readdir(source); for (let i = 0; i < files.length; i++) { const file = files[i]; - await copy(join(source, file), join(target, file), copiedSources); + await copy(join(source, file), join(target, file), handledSources); } } diff --git a/src/vs/base/parts/storage/test/node/storage.test.ts b/src/vs/base/parts/storage/test/node/storage.test.ts index 00ffc9799da..ecf8e467996 100644 --- a/src/vs/base/parts/storage/test/node/storage.test.ts +++ b/src/vs/base/parts/storage/test/node/storage.test.ts @@ -17,20 +17,20 @@ import { generateUuid } from 'vs/base/common/uuid'; flakySuite('Storage Library', function () { - let storageDir: string; + let testDir: string; setup(function () { - storageDir = getRandomTestPath(tmpdir(), 'vsctests', 'storagelibrary'); + testDir = getRandomTestPath(tmpdir(), 'vsctests', 'storagelibrary'); - return mkdirp(storageDir); + return mkdirp(testDir); }); teardown(function () { - return rimraf(storageDir); + return rimraf(testDir); }); test('basics', async () => { - const storage = new Storage(new SQLiteStorageDatabase(join(storageDir, 'storage.db'))); + const storage = new Storage(new SQLiteStorageDatabase(join(testDir, 'storage.db'))); await storage.init(); @@ -116,7 +116,7 @@ flakySuite('Storage Library', function () { } } - const database = new TestSQLiteStorageDatabase(join(storageDir, 'storage.db')); + const database = new TestSQLiteStorageDatabase(join(testDir, 'storage.db')); const storage = new Storage(database); let changes = new Set(); @@ -158,7 +158,7 @@ flakySuite('Storage Library', function () { }); test('close flushes data', async () => { - let storage = new Storage(new SQLiteStorageDatabase(join(storageDir, 'storage.db'))); + let storage = new Storage(new SQLiteStorageDatabase(join(testDir, 'storage.db'))); await storage.init(); const set1Promise = storage.set('foo', 'bar'); @@ -178,7 +178,7 @@ flakySuite('Storage Library', function () { strictEqual(setPromiseResolved, true); strictEqual(flushPromiseResolved, true); - storage = new Storage(new SQLiteStorageDatabase(join(storageDir, 'storage.db'))); + storage = new Storage(new SQLiteStorageDatabase(join(testDir, 'storage.db'))); await storage.init(); strictEqual(storage.get('foo'), 'bar'); @@ -186,7 +186,7 @@ flakySuite('Storage Library', function () { await storage.close(); - storage = new Storage(new SQLiteStorageDatabase(join(storageDir, 'storage.db'))); + storage = new Storage(new SQLiteStorageDatabase(join(testDir, 'storage.db'))); await storage.init(); const delete1Promise = storage.delete('foo'); @@ -202,7 +202,7 @@ flakySuite('Storage Library', function () { strictEqual(deletePromiseResolved, true); - storage = new Storage(new SQLiteStorageDatabase(join(storageDir, 'storage.db'))); + storage = new Storage(new SQLiteStorageDatabase(join(testDir, 'storage.db'))); await storage.init(); ok(!storage.get('foo')); @@ -212,7 +212,7 @@ flakySuite('Storage Library', function () { }); test('conflicting updates', async () => { - let storage = new Storage(new SQLiteStorageDatabase(join(storageDir, 'storage.db'))); + let storage = new Storage(new SQLiteStorageDatabase(join(testDir, 'storage.db'))); await storage.init(); let changes = new Set(); @@ -254,7 +254,7 @@ flakySuite('Storage Library', function () { }); test('corrupt DB recovers', async () => { - const storageFile = join(storageDir, 'storage.db'); + const storageFile = join(testDir, 'storage.db'); let storage = new Storage(new SQLiteStorageDatabase(storageFile)); await storage.init(); diff --git a/src/vs/base/test/node/extpath.test.ts b/src/vs/base/test/node/extpath.test.ts index 4ca7b3c61a5..056110be8f8 100644 --- a/src/vs/base/test/node/extpath.test.ts +++ b/src/vs/base/test/node/extpath.test.ts @@ -48,12 +48,8 @@ flakySuite('Extpath', () => { assert.ok(realpathVal); }); - test('realpathSync', async () => { - try { - const realpath = realpathSync(testDir); - assert.ok(realpath); - } catch (error) { - assert.fail(error); - } + test('realpathSync', () => { + const realpath = realpathSync(testDir); + assert.ok(realpath); }); }); diff --git a/src/vs/base/test/node/keytar.test.ts b/src/vs/base/test/node/keytar.test.ts index 1a5a7b41529..4e187264b29 100644 --- a/src/vs/base/test/node/keytar.test.ts +++ b/src/vs/base/test/node/keytar.test.ts @@ -13,11 +13,11 @@ suite('Keytar', () => { const name = `VSCode Test ${Math.floor(Math.random() * 1e9)}`; try { await keytar.setPassword(name, 'foo', 'bar'); - assert.equal(await keytar.findPassword(name), 'bar'); - assert.equal((await keytar.findCredentials(name)).length, 1); - assert.equal(await keytar.getPassword(name, 'foo'), 'bar'); + assert.strictEqual(await keytar.findPassword(name), 'bar'); + assert.strictEqual((await keytar.findCredentials(name)).length, 1); + assert.strictEqual(await keytar.getPassword(name, 'foo'), 'bar'); await keytar.deletePassword(name, 'foo'); - assert.equal(await keytar.getPassword(name, 'foo'), undefined); + assert.strictEqual(await keytar.getPassword(name, 'foo'), null); } catch (err) { // try to clean up try { diff --git a/src/vs/base/test/node/pfs/pfs.test.ts b/src/vs/base/test/node/pfs/pfs.test.ts index 342e2f11da1..06a0dc608a4 100644 --- a/src/vs/base/test/node/pfs/pfs.test.ts +++ b/src/vs/base/test/node/pfs/pfs.test.ts @@ -8,7 +8,7 @@ import * as fs from 'fs'; import { tmpdir } from 'os'; import { join, sep } from 'vs/base/common/path'; import { generateUuid } from 'vs/base/common/uuid'; -import { copy, mkdirp, move, readdir, readDirsInDir, readdirWithFileTypes, renameIgnoreError, rimraf, RimRafMode, rimrafSync, statLink, writeFile, writeFileSync } from 'vs/base/node/pfs'; +import { copy, exists, mkdirp, move, readdir, readDirsInDir, readdirWithFileTypes, readFile, renameIgnoreError, rimraf, RimRafMode, rimrafSync, statLink, writeFile, writeFileSync } from 'vs/base/node/pfs'; import { timeout } from 'vs/base/common/async'; import { getPathFromAmdModule } from 'vs/base/common/amd'; import { isWindows } from 'vs/base/common/platform'; @@ -18,33 +18,34 @@ import { flakySuite, getRandomTestPath } from 'vs/base/test/node/testUtils'; flakySuite('PFS', function () { - test('writeFile', async () => { - const parentDir = getRandomTestPath(tmpdir(), 'vsctests', 'pfs'); - const id = generateUuid(); - const newDir = join(parentDir, 'pfs', id); - const testFile = join(newDir, 'writefile.txt'); + let testDir: string; - await mkdirp(newDir, 493); - assert.ok(fs.existsSync(newDir)); + setup(() => { + testDir = getRandomTestPath(tmpdir(), 'vsctests', 'pfs'); + + return mkdirp(testDir, 493); + }); + + teardown(() => { + return rimraf(testDir); + }); + + test('writeFile', async () => { + const testFile = join(testDir, 'writefile.txt'); + + assert.ok(!(await exists(testFile))); await writeFile(testFile, 'Hello World', (null!)); - assert.equal(fs.readFileSync(testFile), 'Hello World'); - return rimraf(parentDir); + assert.strictEqual((await readFile(testFile)).toString(), 'Hello World'); }); test('writeFile - parallel write on different files works', async () => { - const parentDir = getRandomTestPath(tmpdir(), 'vsctests', 'pfs'); - const id = generateUuid(); - const newDir = join(parentDir, 'pfs', id); - const testFile1 = join(newDir, 'writefile1.txt'); - const testFile2 = join(newDir, 'writefile2.txt'); - const testFile3 = join(newDir, 'writefile3.txt'); - const testFile4 = join(newDir, 'writefile4.txt'); - const testFile5 = join(newDir, 'writefile5.txt'); - - await mkdirp(newDir, 493); - assert.ok(fs.existsSync(newDir)); + const testFile1 = join(testDir, 'writefile1.txt'); + const testFile2 = join(testDir, 'writefile2.txt'); + const testFile3 = join(testDir, 'writefile3.txt'); + const testFile4 = join(testDir, 'writefile4.txt'); + const testFile5 = join(testDir, 'writefile5.txt'); await Promise.all([ writeFile(testFile1, 'Hello World 1', (null!)), @@ -53,23 +54,15 @@ flakySuite('PFS', function () { writeFile(testFile4, 'Hello World 4', (null!)), writeFile(testFile5, 'Hello World 5', (null!)) ]); - assert.equal(fs.readFileSync(testFile1), 'Hello World 1'); - assert.equal(fs.readFileSync(testFile2), 'Hello World 2'); - assert.equal(fs.readFileSync(testFile3), 'Hello World 3'); - assert.equal(fs.readFileSync(testFile4), 'Hello World 4'); - assert.equal(fs.readFileSync(testFile5), 'Hello World 5'); - - return rimraf(parentDir); + assert.strictEqual(fs.readFileSync(testFile1).toString(), 'Hello World 1'); + assert.strictEqual(fs.readFileSync(testFile2).toString(), 'Hello World 2'); + assert.strictEqual(fs.readFileSync(testFile3).toString(), 'Hello World 3'); + assert.strictEqual(fs.readFileSync(testFile4).toString(), 'Hello World 4'); + assert.strictEqual(fs.readFileSync(testFile5).toString(), 'Hello World 5'); }); test('writeFile - parallel write on same files works and is sequentalized', async () => { - const parentDir = getRandomTestPath(tmpdir(), 'vsctests', 'pfs'); - const id = generateUuid(); - const newDir = join(parentDir, 'pfs', id); - const testFile = join(newDir, 'writefile.txt'); - - await mkdirp(newDir, 493); - assert.ok(fs.existsSync(newDir)); + const testFile = join(testDir, 'writefile.txt'); await Promise.all([ writeFile(testFile, 'Hello World 1', undefined), @@ -78,166 +71,91 @@ flakySuite('PFS', function () { writeFile(testFile, 'Hello World 4', undefined), timeout(10).then(() => writeFile(testFile, 'Hello World 5', undefined)) ]); - assert.equal(fs.readFileSync(testFile), 'Hello World 5'); - - return rimraf(parentDir); + assert.strictEqual(fs.readFileSync(testFile).toString(), 'Hello World 5'); }); test('rimraf - simple - unlink', async () => { - const parentDir = getRandomTestPath(tmpdir(), 'vsctests', 'pfs'); - const id = generateUuid(); - const newDir = join(parentDir, 'pfs', id); + fs.writeFileSync(join(testDir, 'somefile.txt'), 'Contents'); + fs.writeFileSync(join(testDir, 'someOtherFile.txt'), 'Contents'); - await mkdirp(newDir, 493); - fs.writeFileSync(join(newDir, 'somefile.txt'), 'Contents'); - fs.writeFileSync(join(newDir, 'someOtherFile.txt'), 'Contents'); - - await rimraf(newDir); - assert.ok(!fs.existsSync(newDir)); - - return rimraf(parentDir); + await rimraf(testDir); + assert.ok(!fs.existsSync(testDir)); }); test('rimraf - simple - move', async () => { - const parentDir = getRandomTestPath(tmpdir(), 'vsctests', 'pfs'); - const id = generateUuid(); - const newDir = join(parentDir, 'pfs', id); + fs.writeFileSync(join(testDir, 'somefile.txt'), 'Contents'); + fs.writeFileSync(join(testDir, 'someOtherFile.txt'), 'Contents'); - await mkdirp(newDir, 493); - fs.writeFileSync(join(newDir, 'somefile.txt'), 'Contents'); - fs.writeFileSync(join(newDir, 'someOtherFile.txt'), 'Contents'); - - await rimraf(newDir, RimRafMode.MOVE); - assert.ok(!fs.existsSync(newDir)); - - return rimraf(parentDir); + await rimraf(testDir, RimRafMode.MOVE); + assert.ok(!fs.existsSync(testDir)); }); test('rimraf - recursive folder structure - unlink', async () => { - const parentDir = getRandomTestPath(tmpdir(), 'vsctests', 'pfs'); - const id = generateUuid(); - const newDir = join(parentDir, 'pfs', id); + fs.writeFileSync(join(testDir, 'somefile.txt'), 'Contents'); + fs.writeFileSync(join(testDir, 'someOtherFile.txt'), 'Contents'); + fs.mkdirSync(join(testDir, 'somefolder')); + fs.writeFileSync(join(testDir, 'somefolder', 'somefile.txt'), 'Contents'); - await mkdirp(newDir, 493); - fs.writeFileSync(join(newDir, 'somefile.txt'), 'Contents'); - fs.writeFileSync(join(newDir, 'someOtherFile.txt'), 'Contents'); - fs.mkdirSync(join(newDir, 'somefolder')); - fs.writeFileSync(join(newDir, 'somefolder', 'somefile.txt'), 'Contents'); - - await rimraf(newDir); - assert.ok(!fs.existsSync(newDir)); - - return rimraf(parentDir); + await rimraf(testDir); + assert.ok(!fs.existsSync(testDir)); }); test('rimraf - recursive folder structure - move', async () => { - const parentDir = getRandomTestPath(tmpdir(), 'vsctests', 'pfs'); - const id = generateUuid(); - const newDir = join(parentDir, 'pfs', id); + fs.writeFileSync(join(testDir, 'somefile.txt'), 'Contents'); + fs.writeFileSync(join(testDir, 'someOtherFile.txt'), 'Contents'); + fs.mkdirSync(join(testDir, 'somefolder')); + fs.writeFileSync(join(testDir, 'somefolder', 'somefile.txt'), 'Contents'); - await mkdirp(newDir, 493); - fs.writeFileSync(join(newDir, 'somefile.txt'), 'Contents'); - fs.writeFileSync(join(newDir, 'someOtherFile.txt'), 'Contents'); - fs.mkdirSync(join(newDir, 'somefolder')); - fs.writeFileSync(join(newDir, 'somefolder', 'somefile.txt'), 'Contents'); - - await rimraf(newDir, RimRafMode.MOVE); - assert.ok(!fs.existsSync(newDir)); - - return rimraf(parentDir); + await rimraf(testDir, RimRafMode.MOVE); + assert.ok(!fs.existsSync(testDir)); }); test('rimraf - simple ends with dot - move', async () => { - const parentDir = getRandomTestPath(tmpdir(), 'vsctests', 'pfs'); - const id = `${generateUuid()}.`; - const newDir = join(parentDir, 'pfs', id); + fs.writeFileSync(join(testDir, 'somefile.txt'), 'Contents'); + fs.writeFileSync(join(testDir, 'someOtherFile.txt'), 'Contents'); - await mkdirp(newDir, 493); - fs.writeFileSync(join(newDir, 'somefile.txt'), 'Contents'); - fs.writeFileSync(join(newDir, 'someOtherFile.txt'), 'Contents'); - - await rimraf(newDir, RimRafMode.MOVE); - assert.ok(!fs.existsSync(newDir)); - - return rimraf(parentDir); + await rimraf(testDir, RimRafMode.MOVE); + assert.ok(!fs.existsSync(testDir)); }); test('rimraf - simple ends with dot slash/backslash - move', async () => { - const parentDir = getRandomTestPath(tmpdir(), 'vsctests', 'pfs'); - const id = `${generateUuid()}.`; - const newDir = join(parentDir, 'pfs', id); + fs.writeFileSync(join(testDir, 'somefile.txt'), 'Contents'); + fs.writeFileSync(join(testDir, 'someOtherFile.txt'), 'Contents'); - await mkdirp(newDir, 493); - fs.writeFileSync(join(newDir, 'somefile.txt'), 'Contents'); - fs.writeFileSync(join(newDir, 'someOtherFile.txt'), 'Contents'); - - await rimraf(`${newDir}${sep}`, RimRafMode.MOVE); - assert.ok(!fs.existsSync(newDir)); - - return rimraf(parentDir); + await rimraf(`${testDir}${sep}`, RimRafMode.MOVE); + assert.ok(!fs.existsSync(testDir)); }); test('rimrafSync - swallows file not found error', function () { - const parentDir = getRandomTestPath(tmpdir(), 'vsctests', 'pfs'); - const id = generateUuid(); - const newDir = join(parentDir, 'pfs', id); + const nonExistingDir = join(testDir, 'not-existing'); + rimrafSync(nonExistingDir); - rimrafSync(newDir); - - assert.ok(!fs.existsSync(newDir)); - - return rimraf(parentDir); + assert.ok(!fs.existsSync(nonExistingDir)); }); test('rimrafSync - simple', async () => { - const parentDir = getRandomTestPath(tmpdir(), 'vsctests', 'pfs'); - const id = generateUuid(); - const newDir = join(parentDir, 'pfs', id); + fs.writeFileSync(join(testDir, 'somefile.txt'), 'Contents'); + fs.writeFileSync(join(testDir, 'someOtherFile.txt'), 'Contents'); - await mkdirp(newDir, 493); + rimrafSync(testDir); - fs.writeFileSync(join(newDir, 'somefile.txt'), 'Contents'); - fs.writeFileSync(join(newDir, 'someOtherFile.txt'), 'Contents'); - - rimrafSync(newDir); - - assert.ok(!fs.existsSync(newDir)); - - return rimraf(parentDir); + assert.ok(!fs.existsSync(testDir)); }); test('rimrafSync - recursive folder structure', async () => { - const parentDir = getRandomTestPath(tmpdir(), 'vsctests', 'pfs'); - const id = generateUuid(); - const newDir = join(parentDir, 'pfs', id); + fs.writeFileSync(join(testDir, 'somefile.txt'), 'Contents'); + fs.writeFileSync(join(testDir, 'someOtherFile.txt'), 'Contents'); - await mkdirp(newDir, 493); - fs.writeFileSync(join(newDir, 'somefile.txt'), 'Contents'); - fs.writeFileSync(join(newDir, 'someOtherFile.txt'), 'Contents'); + fs.mkdirSync(join(testDir, 'somefolder')); + fs.writeFileSync(join(testDir, 'somefolder', 'somefile.txt'), 'Contents'); - fs.mkdirSync(join(newDir, 'somefolder')); - fs.writeFileSync(join(newDir, 'somefolder', 'somefile.txt'), 'Contents'); + rimrafSync(testDir); - rimrafSync(newDir); - - assert.ok(!fs.existsSync(newDir)); - - return rimraf(parentDir); + assert.ok(!fs.existsSync(testDir)); }); - test('moveIgnoreError', async () => { - const parentDir = getRandomTestPath(tmpdir(), 'vsctests', 'pfs'); - const id = generateUuid(); - const newDir = join(parentDir, 'pfs', id); - - await mkdirp(newDir, 493); - try { - await renameIgnoreError(join(newDir, 'foo'), join(newDir, 'bar')); - return rimraf(parentDir, RimRafMode.MOVE); - } - catch (error) { - assert.fail(error); - } + test('moveIgnoreError', () => { + return renameIgnoreError(join(testDir, 'foo'), join(testDir, 'bar')); }); test('copy, move and delete', async () => { @@ -279,15 +197,13 @@ flakySuite('PFS', function () { (isWindows ? test.skip : test)('copy skips over dangling symbolic links', async () => { // Symlinks are not the same on win, and we can not create them programmatically without admin privileges const id1 = generateUuid(); - const parentDir = join(tmpdir(), 'vsctests', id1); - - const symbolicLinkTarget = join(parentDir, 'pfs', id1); + const symbolicLinkTarget = join(testDir, id1); const id2 = generateUuid(); - const symbolicLink = join(parentDir, 'pfs', id2); + const symbolicLink = join(testDir, id2); const id3 = generateUuid(); - const copyTarget = join(parentDir, 'pfs', id3); + const copyTarget = join(testDir, id3); await mkdirp(symbolicLinkTarget, 493); @@ -298,51 +214,36 @@ flakySuite('PFS', function () { await copy(symbolicLink, copyTarget); // this should not throw assert.ok(!fs.existsSync(copyTarget)); - - return rimraf(parentDir); }); test('mkdirp', async () => { - const parentDir = getRandomTestPath(tmpdir(), 'vsctests', 'pfs'); - const id = generateUuid(); - const newDir = join(parentDir, 'pfs', id); + const newDir = join(testDir, generateUuid()); await mkdirp(newDir, 493); assert.ok(fs.existsSync(newDir)); - - return rimraf(parentDir); }); test('readDirsInDir', async () => { - const parentDir = getRandomTestPath(tmpdir(), 'vsctests', 'pfs'); - const id = generateUuid(); - const newDir = join(parentDir, 'pfs', id); + fs.mkdirSync(join(testDir, 'somefolder1')); + fs.mkdirSync(join(testDir, 'somefolder2')); + fs.mkdirSync(join(testDir, 'somefolder3')); + fs.writeFileSync(join(testDir, 'somefile.txt'), 'Contents'); + fs.writeFileSync(join(testDir, 'someOtherFile.txt'), 'Contents'); - await mkdirp(newDir, 493); - - fs.mkdirSync(join(newDir, 'somefolder1')); - fs.mkdirSync(join(newDir, 'somefolder2')); - fs.mkdirSync(join(newDir, 'somefolder3')); - fs.writeFileSync(join(newDir, 'somefile.txt'), 'Contents'); - fs.writeFileSync(join(newDir, 'someOtherFile.txt'), 'Contents'); - - const result = await readDirsInDir(newDir); - assert.equal(result.length, 3); + const result = await readDirsInDir(testDir); + assert.strictEqual(result.length, 3); assert.ok(result.indexOf('somefolder1') !== -1); assert.ok(result.indexOf('somefolder2') !== -1); assert.ok(result.indexOf('somefolder3') !== -1); - - return rimraf(parentDir); }); (isWindows ? test.skip : test)('stat link', async () => { // Symlinks are not the same on win, and we can not create them programmatically without admin privileges const id1 = generateUuid(); - const parentDir = join(tmpdir(), 'vsctests', id1); - const directory = join(parentDir, 'pfs', id1); + const directory = join(testDir, id1); const id2 = generateUuid(); - const symbolicLink = join(parentDir, 'pfs', id2); + const symbolicLink = join(testDir, id2); await mkdirp(directory, 493); @@ -354,17 +255,14 @@ flakySuite('PFS', function () { statAndIsLink = await statLink(symbolicLink); assert.ok(statAndIsLink?.symbolicLink); assert.ok(!statAndIsLink?.symbolicLink?.dangling); - - return rimraf(parentDir); }); (isWindows ? test.skip : test)('stat link (non existing target)', async () => { // Symlinks are not the same on win, and we can not create them programmatically without admin privileges const id1 = generateUuid(); - const parentDir = join(tmpdir(), 'vsctests', id1); - const directory = join(parentDir, 'pfs', id1); + const directory = join(testDir, id1); const id2 = generateUuid(); - const symbolicLink = join(parentDir, 'pfs', id2); + const symbolicLink = join(testDir, id2); await mkdirp(directory, 493); @@ -375,33 +273,24 @@ flakySuite('PFS', function () { const statAndIsLink = await statLink(symbolicLink); assert.ok(statAndIsLink?.symbolicLink); assert.ok(statAndIsLink?.symbolicLink?.dangling); - - return rimraf(parentDir); }); test('readdir', async () => { if (canNormalize && typeof process.versions['electron'] !== 'undefined' /* needs electron */) { - const parentDir = getRandomTestPath(tmpdir(), 'vsctests', 'pfs'); const id = generateUuid(); - const newDir = join(parentDir, 'pfs', id, 'öäü'); + const newDir = join(testDir, 'pfs', id, 'öäü'); await mkdirp(newDir, 493); assert.ok(fs.existsSync(newDir)); - const children = await readdir(join(parentDir, 'pfs', id)); - assert.equal(children.some(n => n === 'öäü'), true); // Mac always converts to NFD, so - - return rimraf(parentDir); + const children = await readdir(join(testDir, 'pfs', id)); + assert.strictEqual(children.some(n => n === 'öäü'), true); // Mac always converts to NFD, so } }); test('readdirWithFileTypes', async () => { if (canNormalize && typeof process.versions['electron'] !== 'undefined' /* needs electron */) { - const parentDir = getRandomTestPath(tmpdir(), 'vsctests', 'pfs'); - const id = generateUuid(); - const testDir = join(parentDir, 'pfs', id); - const newDir = join(testDir, 'öäü'); await mkdirp(newDir, 493); @@ -411,13 +300,11 @@ flakySuite('PFS', function () { const children = await readdirWithFileTypes(testDir); - assert.equal(children.some(n => n.name === 'öäü'), true); // Mac always converts to NFD, so - assert.equal(children.some(n => n.isDirectory()), true); + assert.strictEqual(children.some(n => n.name === 'öäü'), true); // Mac always converts to NFD, so + assert.strictEqual(children.some(n => n.isDirectory()), true); - assert.equal(children.some(n => n.name === 'somefile.txt'), true); - assert.equal(children.some(n => n.isFile()), true); - - return rimraf(parentDir); + assert.strictEqual(children.some(n => n.name === 'somefile.txt'), true); + assert.strictEqual(children.some(n => n.isFile()), true); } }); @@ -448,34 +335,21 @@ flakySuite('PFS', function () { bigData: string | Buffer | Uint8Array, bigDataValue: string ): Promise { - const parentDir = getRandomTestPath(tmpdir(), 'vsctests', 'pfs'); - const id = generateUuid(); - const newDir = join(parentDir, 'pfs', id); - const testFile = join(newDir, 'flushed.txt'); + const testFile = join(testDir, 'flushed.txt'); - await mkdirp(newDir, 493); - assert.ok(fs.existsSync(newDir)); + assert.ok(fs.existsSync(testDir)); await writeFile(testFile, smallData); - assert.equal(fs.readFileSync(testFile), smallDataValue); + assert.strictEqual(fs.readFileSync(testFile).toString(), smallDataValue); await writeFile(testFile, bigData); - assert.equal(fs.readFileSync(testFile), bigDataValue); - - return rimraf(parentDir); + assert.strictEqual(fs.readFileSync(testFile).toString(), bigDataValue); } test('writeFile (string, error handling)', async () => { - const parentDir = getRandomTestPath(tmpdir(), 'vsctests', 'pfs'); - const id = generateUuid(); - const newDir = join(parentDir, 'pfs', id); - const testFile = join(newDir, 'flushed.txt'); + const testFile = join(testDir, 'flushed.txt'); - await mkdirp(newDir, 493); - - assert.ok(fs.existsSync(newDir)); - - fs.mkdirSync(testFile); // this will trigger an error because testFile is now a directory! + fs.mkdirSync(testFile); // this will trigger an error later because testFile is now a directory! let expectedError: Error | undefined; try { @@ -485,28 +359,17 @@ flakySuite('PFS', function () { } assert.ok(expectedError); - - return rimraf(parentDir); }); test('writeFileSync', async () => { - const parentDir = getRandomTestPath(tmpdir(), 'vsctests', 'pfs'); - const id = generateUuid(); - const newDir = join(parentDir, 'pfs', id); - const testFile = join(newDir, 'flushed.txt'); - - await mkdirp(newDir, 493); - - assert.ok(fs.existsSync(newDir)); + const testFile = join(testDir, 'flushed.txt'); writeFileSync(testFile, 'Hello World'); - assert.equal(fs.readFileSync(testFile), 'Hello World'); + assert.strictEqual(fs.readFileSync(testFile).toString(), 'Hello World'); const largeString = (new Array(100 * 1024)).join('Large String\n'); writeFileSync(testFile, largeString); - assert.equal(fs.readFileSync(testFile), largeString); - - return rimraf(parentDir); + assert.strictEqual(fs.readFileSync(testFile).toString(), largeString); }); }); 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 5d239dd565d..75b2cac3755 100644 --- a/src/vs/platform/backup/test/electron-main/backupMainService.test.ts +++ b/src/vs/platform/backup/test/electron-main/backupMainService.test.ts @@ -27,32 +27,7 @@ import { isEqual } from 'vs/base/common/resources'; flakySuite('BackupMainService', () => { function assertEqualUris(actual: URI[], expected: URI[]) { - assert.deepEqual(actual.map(a => a.toString()), expected.map(a => a.toString())); - } - - const parentDir = getRandomTestPath(os.tmpdir(), 'vsctests', 'backupservice'); - const backupHome = path.join(parentDir, 'Backups'); - const backupWorkspacesPath = path.join(backupHome, 'workspaces.json'); - - const environmentService = new EnvironmentMainService(parseArgs(process.argv, OPTIONS)); - - class TestBackupMainService extends BackupMainService { - - constructor(backupHome: string, backupWorkspacesPath: string, configService: TestConfigurationService) { - super(environmentService, configService, new ConsoleLogMainService()); - - this.backupHome = backupHome; - this.workspacesJsonPath = backupWorkspacesPath; - } - - toBackupPath(arg: URI | string): string { - const id = arg instanceof URI ? super.getFolderHash(arg) : arg; - return path.join(this.backupHome, id); - } - - getFolderHash(folderUri: URI): string { - return super.getFolderHash(folderUri); - } + assert.deepStrictEqual(actual.map(a => a.toString()), expected.map(a => a.toString())); } function toWorkspace(path: string): IWorkspaceIdentifier { @@ -79,20 +54,23 @@ flakySuite('BackupMainService', () => { }; } - async function ensureFolderExists(uri: URI): Promise { + function ensureFolderExists(uri: URI): Promise { if (!fs.existsSync(uri.fsPath)) { fs.mkdirSync(uri.fsPath); } + const backupFolder = service.toBackupPath(uri); - await createBackupFolder(backupFolder); + return createBackupFolder(backupFolder); } async function ensureWorkspaceExists(workspace: IWorkspaceIdentifier): Promise { if (!fs.existsSync(workspace.configPath.fsPath)) { await pfs.writeFile(workspace.configPath.fsPath, 'Hello'); } + const backupFolder = service.toBackupPath(workspace.id); await createBackupFolder(backupFolder); + return workspace; } @@ -111,25 +89,49 @@ flakySuite('BackupMainService', () => { const fooFile = URI.file(platform.isWindows ? 'C:\\foo' : '/foo'); const barFile = URI.file(platform.isWindows ? 'C:\\bar' : '/bar'); - const existingTestFolder1 = URI.file(path.join(parentDir, 'folder1')); - - let service: TestBackupMainService; + let service: BackupMainService & { toBackupPath(arg: URI | string): string, getFolderHash(folderUri: URI): string }; let configService: TestConfigurationService; - setup(async () => { + let environmentService: EnvironmentMainService; + let testDir: string; + let backupHome: string; + let backupWorkspacesPath: string; + let existingTestFolder1: URI; + + setup(async () => { + testDir = getRandomTestPath(os.tmpdir(), 'vsctests', 'backupmainservice'); + backupHome = path.join(testDir, 'Backups'); + backupWorkspacesPath = path.join(backupHome, 'workspaces.json'); + existingTestFolder1 = URI.file(path.join(testDir, 'folder1')); + + environmentService = new EnvironmentMainService(parseArgs(process.argv, OPTIONS)); - // Delete any existing backups completely and then re-create it. - await pfs.rimraf(backupHome); await pfs.mkdirp(backupHome); configService = new TestConfigurationService(); - service = new TestBackupMainService(backupHome, backupWorkspacesPath, configService); + service = new class TestBackupMainService extends BackupMainService { + constructor() { + super(environmentService, configService, new ConsoleLogMainService()); + + this.backupHome = backupHome; + this.workspacesJsonPath = backupWorkspacesPath; + } + + toBackupPath(arg: URI | string): string { + const id = arg instanceof URI ? super.getFolderHash(arg) : arg; + return path.join(this.backupHome, id); + } + + getFolderHash(folderUri: URI): string { + return super.getFolderHash(folderUri); + } + }; return service.initialize(); }); teardown(() => { - return pfs.rimraf(backupHome); + return pfs.rimraf(testDir); }); test('service validates backup workspaces on startup and cleans up (folder workspaces)', async function () { @@ -169,12 +171,12 @@ flakySuite('BackupMainService', () => { fs.mkdirSync(service.toBackupPath(barFile)); fs.mkdirSync(fileBackups); service.registerFolderBackupSync(fooFile); - assert.equal(service.getFolderBackupPaths().length, 1); - assert.equal(service.getEmptyWindowBackupPaths().length, 0); + assert.strictEqual(service.getFolderBackupPaths().length, 1); + assert.strictEqual(service.getEmptyWindowBackupPaths().length, 0); fs.writeFileSync(path.join(fileBackups, 'backup.txt'), ''); await service.initialize(); - assert.equal(service.getFolderBackupPaths().length, 0); - assert.equal(service.getEmptyWindowBackupPaths().length, 1); + assert.strictEqual(service.getFolderBackupPaths().length, 0); + assert.strictEqual(service.getEmptyWindowBackupPaths().length, 1); }); test('service validates backup workspaces on startup and cleans up (root workspaces)', async function () { @@ -183,7 +185,7 @@ flakySuite('BackupMainService', () => { service.registerWorkspaceBackupSync(toWorkspaceBackupInfo(fooFile.fsPath)); service.registerWorkspaceBackupSync(toWorkspaceBackupInfo(barFile.fsPath)); await service.initialize(); - assert.deepEqual(service.getWorkspaceBackups(), []); + assert.deepStrictEqual(service.getWorkspaceBackups(), []); // 2) backup workspace path exists with empty contents within fs.mkdirSync(service.toBackupPath(fooFile)); @@ -191,7 +193,7 @@ flakySuite('BackupMainService', () => { service.registerWorkspaceBackupSync(toWorkspaceBackupInfo(fooFile.fsPath)); service.registerWorkspaceBackupSync(toWorkspaceBackupInfo(barFile.fsPath)); await service.initialize(); - assert.deepEqual(service.getWorkspaceBackups(), []); + assert.deepStrictEqual(service.getWorkspaceBackups(), []); assert.ok(!fs.existsSync(service.toBackupPath(fooFile))); assert.ok(!fs.existsSync(service.toBackupPath(barFile))); @@ -203,7 +205,7 @@ flakySuite('BackupMainService', () => { service.registerWorkspaceBackupSync(toWorkspaceBackupInfo(fooFile.fsPath)); service.registerWorkspaceBackupSync(toWorkspaceBackupInfo(barFile.fsPath)); await service.initialize(); - assert.deepEqual(service.getWorkspaceBackups(), []); + assert.deepStrictEqual(service.getWorkspaceBackups(), []); assert.ok(!fs.existsSync(service.toBackupPath(fooFile))); assert.ok(!fs.existsSync(service.toBackupPath(barFile))); @@ -214,12 +216,12 @@ flakySuite('BackupMainService', () => { fs.mkdirSync(service.toBackupPath(barFile)); fs.mkdirSync(fileBackups); service.registerWorkspaceBackupSync(toWorkspaceBackupInfo(fooFile.fsPath)); - assert.equal(service.getWorkspaceBackups().length, 1); - assert.equal(service.getEmptyWindowBackupPaths().length, 0); + assert.strictEqual(service.getWorkspaceBackups().length, 1); + assert.strictEqual(service.getEmptyWindowBackupPaths().length, 0); fs.writeFileSync(path.join(fileBackups, 'backup.txt'), ''); await service.initialize(); - assert.equal(service.getWorkspaceBackups().length, 0); - assert.equal(service.getEmptyWindowBackupPaths().length, 1); + assert.strictEqual(service.getWorkspaceBackups().length, 0); + assert.strictEqual(service.getEmptyWindowBackupPaths().length, 1); }); test('service supports to migrate backup data from another location', () => { @@ -235,7 +237,7 @@ flakySuite('BackupMainService', () => { assert.ok(!fs.existsSync(backupPathToMigrate)); const emptyBackups = service.getEmptyWindowBackupPaths(); - assert.equal(0, emptyBackups.length); + assert.strictEqual(0, emptyBackups.length); }); test('service backup migration makes sure to preserve existing backups', () => { @@ -256,8 +258,8 @@ flakySuite('BackupMainService', () => { assert.ok(!fs.existsSync(backupPathToMigrate)); const emptyBackups = service.getEmptyWindowBackupPaths(); - assert.equal(1, emptyBackups.length); - assert.equal(1, fs.readdirSync(path.join(backupHome, emptyBackups[0].backupFolder!)).length); + assert.strictEqual(1, emptyBackups.length); + assert.strictEqual(1, fs.readdirSync(path.join(backupHome, emptyBackups[0].backupFolder!)).length); }); suite('loadSync', () => { @@ -313,120 +315,120 @@ flakySuite('BackupMainService', () => { }); test('getWorkspaceBackups() should return [] when workspaces.json doesn\'t exist', () => { - assert.deepEqual(service.getWorkspaceBackups(), []); + assert.deepStrictEqual(service.getWorkspaceBackups(), []); }); test('getWorkspaceBackups() should return [] when workspaces.json is not properly formed JSON', async () => { fs.writeFileSync(backupWorkspacesPath, ''); await service.initialize(); - assert.deepEqual(service.getWorkspaceBackups(), []); + assert.deepStrictEqual(service.getWorkspaceBackups(), []); fs.writeFileSync(backupWorkspacesPath, '{]'); await service.initialize(); - assert.deepEqual(service.getWorkspaceBackups(), []); + assert.deepStrictEqual(service.getWorkspaceBackups(), []); fs.writeFileSync(backupWorkspacesPath, 'foo'); await service.initialize(); - assert.deepEqual(service.getWorkspaceBackups(), []); + assert.deepStrictEqual(service.getWorkspaceBackups(), []); }); test('getWorkspaceBackups() should return [] when folderWorkspaces in workspaces.json is absent', async () => { fs.writeFileSync(backupWorkspacesPath, '{}'); await service.initialize(); - assert.deepEqual(service.getWorkspaceBackups(), []); + assert.deepStrictEqual(service.getWorkspaceBackups(), []); }); test('getWorkspaceBackups() should return [] when rootWorkspaces in workspaces.json is not a object array', async () => { fs.writeFileSync(backupWorkspacesPath, '{"rootWorkspaces":{}}'); await service.initialize(); - assert.deepEqual(service.getWorkspaceBackups(), []); + assert.deepStrictEqual(service.getWorkspaceBackups(), []); fs.writeFileSync(backupWorkspacesPath, '{"rootWorkspaces":{"foo": ["bar"]}}'); await service.initialize(); - assert.deepEqual(service.getWorkspaceBackups(), []); + assert.deepStrictEqual(service.getWorkspaceBackups(), []); fs.writeFileSync(backupWorkspacesPath, '{"rootWorkspaces":{"foo": []}}'); await service.initialize(); - assert.deepEqual(service.getWorkspaceBackups(), []); + assert.deepStrictEqual(service.getWorkspaceBackups(), []); fs.writeFileSync(backupWorkspacesPath, '{"rootWorkspaces":{"foo": "bar"}}'); await service.initialize(); - assert.deepEqual(service.getWorkspaceBackups(), []); + assert.deepStrictEqual(service.getWorkspaceBackups(), []); fs.writeFileSync(backupWorkspacesPath, '{"rootWorkspaces":"foo"}'); await service.initialize(); - assert.deepEqual(service.getWorkspaceBackups(), []); + assert.deepStrictEqual(service.getWorkspaceBackups(), []); fs.writeFileSync(backupWorkspacesPath, '{"rootWorkspaces":1}'); await service.initialize(); - assert.deepEqual(service.getWorkspaceBackups(), []); + assert.deepStrictEqual(service.getWorkspaceBackups(), []); }); test('getWorkspaceBackups() should return [] when rootURIWorkspaces in workspaces.json is not a object array', async () => { fs.writeFileSync(backupWorkspacesPath, '{"rootURIWorkspaces":{}}'); await service.initialize(); - assert.deepEqual(service.getWorkspaceBackups(), []); + assert.deepStrictEqual(service.getWorkspaceBackups(), []); fs.writeFileSync(backupWorkspacesPath, '{"rootURIWorkspaces":{"foo": ["bar"]}}'); await service.initialize(); - assert.deepEqual(service.getWorkspaceBackups(), []); + assert.deepStrictEqual(service.getWorkspaceBackups(), []); fs.writeFileSync(backupWorkspacesPath, '{"rootURIWorkspaces":{"foo": []}}'); await service.initialize(); - assert.deepEqual(service.getWorkspaceBackups(), []); + assert.deepStrictEqual(service.getWorkspaceBackups(), []); fs.writeFileSync(backupWorkspacesPath, '{"rootURIWorkspaces":{"foo": "bar"}}'); await service.initialize(); - assert.deepEqual(service.getWorkspaceBackups(), []); + assert.deepStrictEqual(service.getWorkspaceBackups(), []); fs.writeFileSync(backupWorkspacesPath, '{"rootURIWorkspaces":"foo"}'); await service.initialize(); - assert.deepEqual(service.getWorkspaceBackups(), []); + assert.deepStrictEqual(service.getWorkspaceBackups(), []); fs.writeFileSync(backupWorkspacesPath, '{"rootURIWorkspaces":1}'); await service.initialize(); - assert.deepEqual(service.getWorkspaceBackups(), []); + assert.deepStrictEqual(service.getWorkspaceBackups(), []); }); test('getWorkspaceBackups() should return [] when files.hotExit = "onExitAndWindowClose"', async () => { const upperFooPath = fooFile.fsPath.toUpperCase(); service.registerWorkspaceBackupSync(toWorkspaceBackupInfo(upperFooPath)); - assert.equal(service.getWorkspaceBackups().length, 1); + assert.strictEqual(service.getWorkspaceBackups().length, 1); assertEqualUris(service.getWorkspaceBackups().map(r => r.workspace.configPath), [URI.file(upperFooPath)]); configService.setUserConfiguration('files.hotExit', HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE); await service.initialize(); - assert.deepEqual(service.getWorkspaceBackups(), []); + assert.deepStrictEqual(service.getWorkspaceBackups(), []); }); test('getEmptyWorkspaceBackupPaths() should return [] when workspaces.json doesn\'t exist', () => { - assert.deepEqual(service.getEmptyWindowBackupPaths(), []); + assert.deepStrictEqual(service.getEmptyWindowBackupPaths(), []); }); test('getEmptyWorkspaceBackupPaths() should return [] when workspaces.json is not properly formed JSON', async () => { fs.writeFileSync(backupWorkspacesPath, ''); await service.initialize(); - assert.deepEqual(service.getEmptyWindowBackupPaths(), []); + assert.deepStrictEqual(service.getEmptyWindowBackupPaths(), []); fs.writeFileSync(backupWorkspacesPath, '{]'); await service.initialize(); - assert.deepEqual(service.getEmptyWindowBackupPaths(), []); + assert.deepStrictEqual(service.getEmptyWindowBackupPaths(), []); fs.writeFileSync(backupWorkspacesPath, 'foo'); await service.initialize(); - assert.deepEqual(service.getEmptyWindowBackupPaths(), []); + assert.deepStrictEqual(service.getEmptyWindowBackupPaths(), []); }); test('getEmptyWorkspaceBackupPaths() should return [] when folderWorkspaces in workspaces.json is absent', async () => { fs.writeFileSync(backupWorkspacesPath, '{}'); await service.initialize(); - assert.deepEqual(service.getEmptyWindowBackupPaths(), []); + assert.deepStrictEqual(service.getEmptyWindowBackupPaths(), []); }); test('getEmptyWorkspaceBackupPaths() should return [] when folderWorkspaces in workspaces.json is not a string array', async function () { fs.writeFileSync(backupWorkspacesPath, '{"emptyWorkspaces":{}}'); await service.initialize(); - assert.deepEqual(service.getEmptyWindowBackupPaths(), []); + assert.deepStrictEqual(service.getEmptyWindowBackupPaths(), []); fs.writeFileSync(backupWorkspacesPath, '{"emptyWorkspaces":{"foo": ["bar"]}}'); await service.initialize(); - assert.deepEqual(service.getEmptyWindowBackupPaths(), []); + assert.deepStrictEqual(service.getEmptyWindowBackupPaths(), []); fs.writeFileSync(backupWorkspacesPath, '{"emptyWorkspaces":{"foo": []}}'); await service.initialize(); - assert.deepEqual(service.getEmptyWindowBackupPaths(), []); + assert.deepStrictEqual(service.getEmptyWindowBackupPaths(), []); fs.writeFileSync(backupWorkspacesPath, '{"emptyWorkspaces":{"foo": "bar"}}'); await service.initialize(); - assert.deepEqual(service.getEmptyWindowBackupPaths(), []); + assert.deepStrictEqual(service.getEmptyWindowBackupPaths(), []); fs.writeFileSync(backupWorkspacesPath, '{"emptyWorkspaces":"foo"}'); await service.initialize(); - assert.deepEqual(service.getEmptyWindowBackupPaths(), []); + assert.deepStrictEqual(service.getEmptyWindowBackupPaths(), []); fs.writeFileSync(backupWorkspacesPath, '{"emptyWorkspaces":1}'); await service.initialize(); - assert.deepEqual(service.getEmptyWindowBackupPaths(), []); + assert.deepStrictEqual(service.getEmptyWindowBackupPaths(), []); }); }); @@ -445,7 +447,7 @@ flakySuite('BackupMainService', () => { const buffer = await pfs.readFile(backupWorkspacesPath, 'utf-8'); const json = JSON.parse(buffer); - assert.deepEqual(json.folderURIWorkspaces, [existingTestFolder1.toString()]); + assert.deepStrictEqual(json.folderURIWorkspaces, [existingTestFolder1.toString()]); }); test('should ignore duplicates on Windows and Mac (folder workspace)', async () => { @@ -461,14 +463,13 @@ flakySuite('BackupMainService', () => { await service.initialize(); const buffer = await pfs.readFile(backupWorkspacesPath, 'utf-8'); const json = JSON.parse(buffer); - assert.deepEqual(json.folderURIWorkspaces, [existingTestFolder1.toString()]); + assert.deepStrictEqual(json.folderURIWorkspaces, [existingTestFolder1.toString()]); }); test('should ignore duplicates on Windows and Mac (root workspace)', async () => { - - const workspacePath = path.join(parentDir, 'Foo.code-workspace'); - const workspacePath1 = path.join(parentDir, 'FOO.code-workspace'); - const workspacePath2 = path.join(parentDir, 'foo.code-workspace'); + const workspacePath = path.join(testDir, 'Foo.code-workspace'); + const workspacePath1 = path.join(testDir, 'FOO.code-workspace'); + const workspacePath2 = path.join(testDir, 'foo.code-workspace'); const workspace1 = await ensureWorkspaceExists(toWorkspace(workspacePath)); const workspace2 = await ensureWorkspaceExists(toWorkspace(workspacePath1)); @@ -484,11 +485,11 @@ flakySuite('BackupMainService', () => { const buffer = await pfs.readFile(backupWorkspacesPath, 'utf-8'); const json = JSON.parse(buffer); - assert.equal(json.rootURIWorkspaces.length, platform.isLinux ? 3 : 1); + assert.strictEqual(json.rootURIWorkspaces.length, platform.isLinux ? 3 : 1); if (platform.isLinux) { - assert.deepEqual(json.rootURIWorkspaces.map(r => r.configURIPath), [URI.file(workspacePath).toString(), URI.file(workspacePath1).toString(), URI.file(workspacePath2).toString()]); + assert.deepStrictEqual(json.rootURIWorkspaces.map(r => r.configURIPath), [URI.file(workspacePath).toString(), URI.file(workspacePath1).toString(), URI.file(workspacePath2).toString()]); } else { - assert.deepEqual(json.rootURIWorkspaces.map(r => r.configURIPath), [URI.file(workspacePath).toString()], 'should return the first duplicated entry'); + assert.deepStrictEqual(json.rootURIWorkspaces.map(r => r.configURIPath), [URI.file(workspacePath).toString()], 'should return the first duplicated entry'); } }); }); @@ -500,7 +501,7 @@ flakySuite('BackupMainService', () => { assertEqualUris(service.getFolderBackupPaths(), [fooFile, barFile]); const buffer = await pfs.readFile(backupWorkspacesPath, 'utf-8'); const json = JSON.parse(buffer); - assert.deepEqual(json.folderURIWorkspaces, [fooFile.toString(), barFile.toString()]); + assert.deepStrictEqual(json.folderURIWorkspaces, [fooFile.toString(), barFile.toString()]); }); test('should persist paths to workspaces.json (root workspace)', async () => { @@ -510,15 +511,15 @@ flakySuite('BackupMainService', () => { service.registerWorkspaceBackupSync(ws2); assertEqualUris(service.getWorkspaceBackups().map(b => b.workspace.configPath), [fooFile, barFile]); - assert.equal(ws1.workspace.id, service.getWorkspaceBackups()[0].workspace.id); - assert.equal(ws2.workspace.id, service.getWorkspaceBackups()[1].workspace.id); + assert.strictEqual(ws1.workspace.id, service.getWorkspaceBackups()[0].workspace.id); + assert.strictEqual(ws2.workspace.id, service.getWorkspaceBackups()[1].workspace.id); const buffer = await pfs.readFile(backupWorkspacesPath, 'utf-8'); const json = JSON.parse(buffer); - assert.deepEqual(json.rootURIWorkspaces.map(b => b.configURIPath), [fooFile.toString(), barFile.toString()]); - assert.equal(ws1.workspace.id, json.rootURIWorkspaces[0].id); - assert.equal(ws2.workspace.id, json.rootURIWorkspaces[1].id); + assert.deepStrictEqual(json.rootURIWorkspaces.map(b => b.configURIPath), [fooFile.toString(), barFile.toString()]); + assert.strictEqual(ws1.workspace.id, json.rootURIWorkspaces[0].id); + assert.strictEqual(ws2.workspace.id, json.rootURIWorkspaces[1].id); }); }); @@ -528,7 +529,7 @@ flakySuite('BackupMainService', () => { const buffer = await pfs.readFile(backupWorkspacesPath, 'utf-8'); const json = JSON.parse(buffer); - assert.deepEqual(json.folderURIWorkspaces, [URI.file(fooFile.fsPath.toUpperCase()).toString()]); + assert.deepStrictEqual(json.folderURIWorkspaces, [URI.file(fooFile.fsPath.toUpperCase()).toString()]); }); test('should always store the workspace path in workspaces.json using the case given, regardless of whether the file system is case-sensitive (root workspace)', async () => { @@ -538,7 +539,7 @@ flakySuite('BackupMainService', () => { const buffer = await pfs.readFile(backupWorkspacesPath, 'utf-8'); const json = (JSON.parse(buffer)); - assert.deepEqual(json.rootURIWorkspaces.map(b => b.configURIPath), [URI.file(upperFooPath).toString()]); + assert.deepStrictEqual(json.rootURIWorkspaces.map(b => b.configURIPath), [URI.file(upperFooPath).toString()]); }); suite('removeBackupPathSync', () => { @@ -549,12 +550,12 @@ flakySuite('BackupMainService', () => { const buffer = await pfs.readFile(backupWorkspacesPath, 'utf-8'); const json = (JSON.parse(buffer)); - assert.deepEqual(json.folderURIWorkspaces, [barFile.toString()]); + assert.deepStrictEqual(json.folderURIWorkspaces, [barFile.toString()]); service.unregisterFolderBackupSync(barFile); const content = await pfs.readFile(backupWorkspacesPath, 'utf-8'); const json2 = (JSON.parse(content)); - assert.deepEqual(json2.folderURIWorkspaces, []); + assert.deepStrictEqual(json2.folderURIWorkspaces, []); }); test('should remove folder workspaces from workspaces.json (root workspace)', async () => { @@ -566,12 +567,12 @@ flakySuite('BackupMainService', () => { const buffer = await pfs.readFile(backupWorkspacesPath, 'utf-8'); const json = (JSON.parse(buffer)); - assert.deepEqual(json.rootURIWorkspaces.map(r => r.configURIPath), [barFile.toString()]); + assert.deepStrictEqual(json.rootURIWorkspaces.map(r => r.configURIPath), [barFile.toString()]); service.unregisterWorkspaceBackupSync(ws2.workspace); const content = await pfs.readFile(backupWorkspacesPath, 'utf-8'); const json2 = (JSON.parse(content)); - assert.deepEqual(json2.rootURIWorkspaces, []); + assert.deepStrictEqual(json2.rootURIWorkspaces, []); }); test('should remove empty workspaces from workspaces.json', async () => { @@ -581,12 +582,12 @@ flakySuite('BackupMainService', () => { const buffer = await pfs.readFile(backupWorkspacesPath, 'utf-8'); const json = (JSON.parse(buffer)); - assert.deepEqual(json.emptyWorkspaceInfos, [{ backupFolder: 'bar' }]); + assert.deepStrictEqual(json.emptyWorkspaceInfos, [{ backupFolder: 'bar' }]); service.unregisterEmptyWindowBackupSync('bar'); const content = await pfs.readFile(backupWorkspacesPath, 'utf-8'); const json2 = (JSON.parse(content)); - assert.deepEqual(json2.emptyWorkspaceInfos, []); + assert.deepStrictEqual(json2.emptyWorkspaceInfos, []); }); test('should fail gracefully when removing a path that doesn\'t exist', async () => { @@ -600,18 +601,18 @@ flakySuite('BackupMainService', () => { service.unregisterEmptyWindowBackupSync('test'); const content = await pfs.readFile(backupWorkspacesPath, 'utf-8'); const json = (JSON.parse(content)); - assert.deepEqual(json.folderURIWorkspaces, [existingTestFolder1.toString()]); + assert.deepStrictEqual(json.folderURIWorkspaces, [existingTestFolder1.toString()]); }); }); suite('getWorkspaceHash', () => { (platform.isLinux ? test.skip : test)('should ignore case on Windows and Mac', () => { if (platform.isMacintosh) { - assert.equal(service.getFolderHash(URI.file('/foo')), service.getFolderHash(URI.file('/FOO'))); + assert.strictEqual(service.getFolderHash(URI.file('/foo')), service.getFolderHash(URI.file('/FOO'))); } if (platform.isWindows) { - assert.equal(service.getFolderHash(URI.file('c:\\foo')), service.getFolderHash(URI.file('C:\\FOO'))); + assert.strictEqual(service.getFolderHash(URI.file('c:\\foo')), service.getFolderHash(URI.file('C:\\FOO'))); } }); }); @@ -622,9 +623,9 @@ flakySuite('BackupMainService', () => { service.registerFolderBackupSync(URI.file(fooFile.fsPath.toUpperCase())); if (platform.isLinux) { - assert.equal(service.getFolderBackupPaths().length, 2); + assert.strictEqual(service.getFolderBackupPaths().length, 2); } else { - assert.equal(service.getFolderBackupPaths().length, 1); + assert.strictEqual(service.getFolderBackupPaths().length, 1); } }); @@ -633,9 +634,9 @@ flakySuite('BackupMainService', () => { service.registerWorkspaceBackupSync(toWorkspaceBackupInfo(fooFile.fsPath.toUpperCase())); if (platform.isLinux) { - assert.equal(service.getWorkspaceBackups().length, 2); + assert.strictEqual(service.getWorkspaceBackups().length, 2); } else { - assert.equal(service.getWorkspaceBackups().length, 1); + assert.strictEqual(service.getWorkspaceBackups().length, 1); } }); @@ -644,16 +645,16 @@ flakySuite('BackupMainService', () => { // same case service.registerFolderBackupSync(fooFile); service.unregisterFolderBackupSync(fooFile); - assert.equal(service.getFolderBackupPaths().length, 0); + assert.strictEqual(service.getFolderBackupPaths().length, 0); // mixed case service.registerFolderBackupSync(fooFile); service.unregisterFolderBackupSync(URI.file(fooFile.fsPath.toUpperCase())); if (platform.isLinux) { - assert.equal(service.getFolderBackupPaths().length, 1); + assert.strictEqual(service.getFolderBackupPaths().length, 1); } else { - assert.equal(service.getFolderBackupPaths().length, 0); + assert.strictEqual(service.getFolderBackupPaths().length, 0); } }); }); @@ -665,7 +666,7 @@ flakySuite('BackupMainService', () => { const backupWorkspaceInfo = toWorkspaceBackupInfo(fooFile.fsPath); const workspaceBackupPath = service.registerWorkspaceBackupSync(backupWorkspaceInfo); - assert.equal(((await service.getDirtyWorkspaces()).length), 0); + assert.strictEqual(((await service.getDirtyWorkspaces()).length), 0); try { await pfs.mkdirp(path.join(folderBackupPath, Schemas.file)); @@ -674,13 +675,13 @@ flakySuite('BackupMainService', () => { // ignore - folder might exist already } - assert.equal(((await service.getDirtyWorkspaces()).length), 0); + assert.strictEqual(((await service.getDirtyWorkspaces()).length), 0); fs.writeFileSync(path.join(folderBackupPath, Schemas.file, '594a4a9d82a277a899d4713a5b08f504'), ''); fs.writeFileSync(path.join(workspaceBackupPath, Schemas.untitled, '594a4a9d82a277a899d4713a5b08f504'), ''); const dirtyWorkspaces = await service.getDirtyWorkspaces(); - assert.equal(dirtyWorkspaces.length, 2); + assert.strictEqual(dirtyWorkspaces.length, 2); let found = 0; for (const dirtyWorkpspace of dirtyWorkspaces) { @@ -695,7 +696,7 @@ flakySuite('BackupMainService', () => { } } - assert.equal(found, 2); + assert.strictEqual(found, 2); }); }); }); diff --git a/src/vs/platform/files/test/electron-browser/diskFileService.test.ts b/src/vs/platform/files/test/electron-browser/diskFileService.test.ts index e943415e9de..769f364145a 100644 --- a/src/vs/platform/files/test/electron-browser/diskFileService.test.ts +++ b/src/vs/platform/files/test/electron-browser/diskFileService.test.ts @@ -166,14 +166,14 @@ flakySuite('Disk File Service', function () { const newFolder = await service.createFolder(newFolderResource); - assert.equal(newFolder.name, 'newFolder'); - assert.equal(existsSync(newFolder.resource.fsPath), true); + assert.strictEqual(newFolder.name, 'newFolder'); + assert.strictEqual(existsSync(newFolder.resource.fsPath), true); assert.ok(event); - assert.equal(event!.resource.fsPath, newFolderResource.fsPath); - assert.equal(event!.operation, FileOperation.CREATE); - assert.equal(event!.target!.resource.fsPath, newFolderResource.fsPath); - assert.equal(event!.target!.isDirectory, true); + assert.strictEqual(event!.resource.fsPath, newFolderResource.fsPath); + assert.strictEqual(event!.operation, FileOperation.CREATE); + assert.strictEqual(event!.target!.resource.fsPath, newFolderResource.fsPath); + assert.strictEqual(event!.target!.isDirectory, true); }); test('createFolder: creating multiple folders at once', async () => { @@ -188,34 +188,34 @@ flakySuite('Disk File Service', function () { const newFolder = await service.createFolder(newFolderResource); const lastFolderName = multiFolderPaths[multiFolderPaths.length - 1]; - assert.equal(newFolder.name, lastFolderName); - assert.equal(existsSync(newFolder.resource.fsPath), true); + assert.strictEqual(newFolder.name, lastFolderName); + assert.strictEqual(existsSync(newFolder.resource.fsPath), true); assert.ok(event!); - assert.equal(event!.resource.fsPath, newFolderResource.fsPath); - assert.equal(event!.operation, FileOperation.CREATE); - assert.equal(event!.target!.resource.fsPath, newFolderResource.fsPath); - assert.equal(event!.target!.isDirectory, true); + assert.strictEqual(event!.resource.fsPath, newFolderResource.fsPath); + assert.strictEqual(event!.operation, FileOperation.CREATE); + assert.strictEqual(event!.target!.resource.fsPath, newFolderResource.fsPath); + assert.strictEqual(event!.target!.isDirectory, true); }); test('exists', async () => { let exists = await service.exists(URI.file(testDir)); - assert.equal(exists, true); + assert.strictEqual(exists, true); exists = await service.exists(URI.file(testDir + 'something')); - assert.equal(exists, false); + assert.strictEqual(exists, false); }); test('resolve - file', async () => { const resource = URI.file(getPathFromAmdModule(require, './fixtures/resolver/index.html')); const resolved = await service.resolve(resource); - assert.equal(resolved.name, 'index.html'); - assert.equal(resolved.isFile, true); - assert.equal(resolved.isDirectory, false); - assert.equal(resolved.isSymbolicLink, false); - assert.equal(resolved.resource.toString(), resource.toString()); - assert.equal(resolved.children, undefined); + assert.strictEqual(resolved.name, 'index.html'); + assert.strictEqual(resolved.isFile, true); + assert.strictEqual(resolved.isDirectory, false); + assert.strictEqual(resolved.isSymbolicLink, false); + assert.strictEqual(resolved.resource.toString(), resource.toString()); + assert.strictEqual(resolved.children, undefined); assert.ok(resolved.mtime! > 0); assert.ok(resolved.ctime! > 0); assert.ok(resolved.size! > 0); @@ -228,14 +228,14 @@ flakySuite('Disk File Service', function () { const result = await service.resolve(resource); assert.ok(result); - assert.equal(result.resource.toString(), resource.toString()); - assert.equal(result.name, 'resolver'); + assert.strictEqual(result.resource.toString(), resource.toString()); + assert.strictEqual(result.name, 'resolver'); assert.ok(result.children); assert.ok(result.children!.length > 0); assert.ok(result!.isDirectory); assert.ok(result.mtime! > 0); assert.ok(result.ctime! > 0); - assert.equal(result.children!.length, testsElements.length); + assert.strictEqual(result.children!.length, testsElements.length); assert.ok(result.children!.every(entry => { return testsElements.some(name => { @@ -247,18 +247,18 @@ flakySuite('Disk File Service', function () { assert.ok(basename(value.resource.fsPath)); if (['examples', 'other'].indexOf(basename(value.resource.fsPath)) >= 0) { assert.ok(value.isDirectory); - assert.equal(value.mtime, undefined); - assert.equal(value.ctime, undefined); + assert.strictEqual(value.mtime, undefined); + assert.strictEqual(value.ctime, undefined); } else if (basename(value.resource.fsPath) === 'index.html') { assert.ok(!value.isDirectory); assert.ok(!value.children); - assert.equal(value.mtime, undefined); - assert.equal(value.ctime, undefined); + assert.strictEqual(value.mtime, undefined); + assert.strictEqual(value.ctime, undefined); } else if (basename(value.resource.fsPath) === 'site.css') { assert.ok(!value.isDirectory); assert.ok(!value.children); - assert.equal(value.mtime, undefined); - assert.equal(value.ctime, undefined); + assert.strictEqual(value.mtime, undefined); + assert.strictEqual(value.ctime, undefined); } else { assert.ok(!'Unexpected value ' + basename(value.resource.fsPath)); } @@ -271,13 +271,13 @@ flakySuite('Disk File Service', function () { const result = await service.resolve(URI.file(getPathFromAmdModule(require, './fixtures/resolver')), { resolveMetadata: true }); assert.ok(result); - assert.equal(result.name, 'resolver'); + assert.strictEqual(result.name, 'resolver'); assert.ok(result.children); assert.ok(result.children!.length > 0); assert.ok(result!.isDirectory); assert.ok(result.mtime! > 0); assert.ok(result.ctime! > 0); - assert.equal(result.children!.length, testsElements.length); + assert.strictEqual(result.children!.length, testsElements.length); assert.ok(result.children!.every(entry => { return testsElements.some(name => { @@ -311,10 +311,10 @@ flakySuite('Disk File Service', function () { test('resolve - directory with resolveTo', async () => { const resolved = await service.resolve(URI.file(testDir), { resolveTo: [URI.file(join(testDir, 'deep'))] }); - assert.equal(resolved.children!.length, 8); + assert.strictEqual(resolved.children!.length, 8); const deep = (getByName(resolved, 'deep')!); - assert.equal(deep.children!.length, 4); + assert.strictEqual(deep.children!.length, 4); }); test('resolve - directory - resolveTo single directory', async () => { @@ -327,7 +327,7 @@ flakySuite('Disk File Service', function () { assert.ok(result.isDirectory); const children = result.children!; - assert.equal(children.length, 4); + assert.strictEqual(children.length, 4); const other = getByName(result, 'other'); assert.ok(other); @@ -336,7 +336,7 @@ flakySuite('Disk File Service', function () { const deep = getByName(other!, 'deep'); assert.ok(deep); assert.ok(deep!.children!.length > 0); - assert.equal(deep!.children!.length, 4); + assert.strictEqual(deep!.children!.length, 4); }); test('resolve directory - resolveTo multiple directories', async () => { @@ -354,7 +354,7 @@ flakySuite('Disk File Service', function () { assert.ok(result.isDirectory); const children = result.children!; - assert.equal(children.length, 4); + assert.strictEqual(children.length, 4); const other = getByName(result, 'other'); assert.ok(other); @@ -363,12 +363,12 @@ flakySuite('Disk File Service', function () { const deep = getByName(other!, 'deep'); assert.ok(deep); assert.ok(deep!.children!.length > 0); - assert.equal(deep!.children!.length, 4); + assert.strictEqual(deep!.children!.length, 4); const examples = getByName(result, 'examples'); assert.ok(examples); assert.ok(examples!.children!.length > 0); - assert.equal(examples!.children!.length, 4); + assert.strictEqual(examples!.children!.length, 4); }); test('resolve directory - resolveSingleChildFolders', async () => { @@ -381,12 +381,12 @@ flakySuite('Disk File Service', function () { assert.ok(result.isDirectory); const children = result.children!; - assert.equal(children.length, 1); + assert.strictEqual(children.length, 1); let deep = getByName(result, 'deep'); assert.ok(deep); assert.ok(deep!.children!.length > 0); - assert.equal(deep!.children!.length, 4); + assert.strictEqual(deep!.children!.length, 4); }); test('resolves', async () => { @@ -396,14 +396,14 @@ flakySuite('Disk File Service', function () { ]); const r1 = (res[0].stat!); - assert.equal(r1.children!.length, 8); + assert.strictEqual(r1.children!.length, 8); const deep = (getByName(r1, 'deep')!); - assert.equal(deep.children!.length, 4); + assert.strictEqual(deep.children!.length, 4); const r2 = (res[1].stat!); - assert.equal(r2.children!.length, 4); - assert.equal(r2.name, 'deep'); + assert.strictEqual(r2.children!.length, 4); + assert.strictEqual(r2.name, 'deep'); }); (isWindows /* symlinks are not reliable on windows */ ? test.skip : test)('resolve - folder symbolic link', async () => { @@ -411,9 +411,9 @@ flakySuite('Disk File Service', function () { await symlink(join(testDir, 'deep'), link.fsPath); const resolved = await service.resolve(link); - assert.equal(resolved.children!.length, 4); - assert.equal(resolved.isDirectory, true); - assert.equal(resolved.isSymbolicLink, true); + assert.strictEqual(resolved.children!.length, 4); + assert.strictEqual(resolved.isDirectory, true); + assert.strictEqual(resolved.isSymbolicLink, true); }); (isWindows /* symlinks are not reliable on windows */ ? test.skip : test)('resolve - file symbolic link', async () => { @@ -421,16 +421,16 @@ flakySuite('Disk File Service', function () { await symlink(join(testDir, 'lorem.txt'), link.fsPath); const resolved = await service.resolve(link); - assert.equal(resolved.isDirectory, false); - assert.equal(resolved.isSymbolicLink, true); + assert.strictEqual(resolved.isDirectory, false); + assert.strictEqual(resolved.isSymbolicLink, true); }); (isWindows /* symlinks are not reliable on windows */ ? test.skip : test)('resolve - symbolic link pointing to non-existing file does not break', async () => { await symlink(join(testDir, 'foo'), join(testDir, 'bar')); const resolved = await service.resolve(URI.file(testDir)); - assert.equal(resolved.isDirectory, true); - assert.equal(resolved.children!.length, 9); + assert.strictEqual(resolved.isDirectory, true); + assert.strictEqual(resolved.children!.length, 9); const resolvedLink = resolved.children?.find(child => child.name === 'bar' && child.isSymbolicLink); assert.ok(resolvedLink); @@ -454,14 +454,14 @@ flakySuite('Disk File Service', function () { const resource = URI.file(join(testDir, 'deep', 'conway.js')); const source = await service.resolve(resource); - assert.equal(await service.canDelete(source.resource, { useTrash }), true); + assert.strictEqual(await service.canDelete(source.resource, { useTrash }), true); await service.del(source.resource, { useTrash }); - assert.equal(existsSync(source.resource.fsPath), false); + assert.strictEqual(existsSync(source.resource.fsPath), false); assert.ok(event!); - assert.equal(event!.resource.fsPath, resource.fsPath); - assert.equal(event!.operation, FileOperation.DELETE); + assert.strictEqual(event!.resource.fsPath, resource.fsPath); + assert.strictEqual(event!.operation, FileOperation.DELETE); let error: Error | undefined = undefined; try { @@ -471,7 +471,7 @@ flakySuite('Disk File Service', function () { } assert.ok(error); - assert.equal((error).fileOperationResult, FileOperationResult.FILE_NOT_FOUND); + assert.strictEqual((error).fileOperationResult, FileOperationResult.FILE_NOT_FOUND); } (isWindows /* symlinks are not reliable on windows */ ? test.skip : test)('deleteFile - symbolic link (exists)', async () => { @@ -484,16 +484,16 @@ flakySuite('Disk File Service', function () { let event: FileOperationEvent; disposables.add(service.onDidRunOperation(e => event = e)); - assert.equal(await service.canDelete(source.resource), true); + assert.strictEqual(await service.canDelete(source.resource), true); await service.del(source.resource); - assert.equal(existsSync(source.resource.fsPath), false); + assert.strictEqual(existsSync(source.resource.fsPath), false); assert.ok(event!); - assert.equal(event!.resource.fsPath, link.fsPath); - assert.equal(event!.operation, FileOperation.DELETE); + assert.strictEqual(event!.resource.fsPath, link.fsPath); + assert.strictEqual(event!.operation, FileOperation.DELETE); - assert.equal(existsSync(target.fsPath), true); // target the link pointed to is never deleted + assert.strictEqual(existsSync(target.fsPath), true); // target the link pointed to is never deleted }); (isWindows /* symlinks are not reliable on windows */ ? test.skip : test)('deleteFile - symbolic link (pointing to non-existing file)', async () => { @@ -504,14 +504,14 @@ flakySuite('Disk File Service', function () { let event: FileOperationEvent; disposables.add(service.onDidRunOperation(e => event = e)); - assert.equal(await service.canDelete(link), true); + assert.strictEqual(await service.canDelete(link), true); await service.del(link); - assert.equal(existsSync(link.fsPath), false); + assert.strictEqual(existsSync(link.fsPath), false); assert.ok(event!); - assert.equal(event!.resource.fsPath, link.fsPath); - assert.equal(event!.operation, FileOperation.DELETE); + assert.strictEqual(event!.resource.fsPath, link.fsPath); + assert.strictEqual(event!.operation, FileOperation.DELETE); }); test('deleteFolder (recursive)', async () => { @@ -529,13 +529,13 @@ flakySuite('Disk File Service', function () { const resource = URI.file(join(testDir, 'deep')); const source = await service.resolve(resource); - assert.equal(await service.canDelete(source.resource, { recursive: true, useTrash }), true); + assert.strictEqual(await service.canDelete(source.resource, { recursive: true, useTrash }), true); await service.del(source.resource, { recursive: true, useTrash }); - assert.equal(existsSync(source.resource.fsPath), false); + assert.strictEqual(existsSync(source.resource.fsPath), false); assert.ok(event!); - assert.equal(event!.resource.fsPath, resource.fsPath); - assert.equal(event!.operation, FileOperation.DELETE); + assert.strictEqual(event!.resource.fsPath, resource.fsPath); + assert.strictEqual(event!.operation, FileOperation.DELETE); } test('deleteFolder (non recursive)', async () => { @@ -563,20 +563,20 @@ flakySuite('Disk File Service', function () { const target = URI.file(join(dirname(source.fsPath), 'other.html')); - assert.equal(await service.canMove(source, target), true); + assert.strictEqual(await service.canMove(source, target), true); const renamed = await service.move(source, target); - assert.equal(existsSync(renamed.resource.fsPath), true); - assert.equal(existsSync(source.fsPath), false); + assert.strictEqual(existsSync(renamed.resource.fsPath), true); + assert.strictEqual(existsSync(source.fsPath), false); assert.ok(event!); - assert.equal(event!.resource.fsPath, source.fsPath); - assert.equal(event!.operation, FileOperation.MOVE); - assert.equal(event!.target!.resource.fsPath, renamed.resource.fsPath); + assert.strictEqual(event!.resource.fsPath, source.fsPath); + assert.strictEqual(event!.operation, FileOperation.MOVE); + assert.strictEqual(event!.target!.resource.fsPath, renamed.resource.fsPath); const targetContents = readFileSync(target.fsPath); - assert.equal(sourceContents.byteLength, targetContents.byteLength); - assert.equal(sourceContents.toString(), targetContents.toString()); + assert.strictEqual(sourceContents.byteLength, targetContents.byteLength); + assert.strictEqual(sourceContents.toString(), targetContents.toString()); }); test('move - across providers (buffered => buffered)', async () => { @@ -644,20 +644,20 @@ flakySuite('Disk File Service', function () { const target = URI.file(join(dirname(source.fsPath), 'other.html')).with({ scheme: testSchema }); - assert.equal(await service.canMove(source, target), true); + assert.strictEqual(await service.canMove(source, target), true); const renamed = await service.move(source, target); - assert.equal(existsSync(renamed.resource.fsPath), true); - assert.equal(existsSync(source.fsPath), false); + assert.strictEqual(existsSync(renamed.resource.fsPath), true); + assert.strictEqual(existsSync(source.fsPath), false); assert.ok(event!); - assert.equal(event!.resource.fsPath, source.fsPath); - assert.equal(event!.operation, FileOperation.COPY); - assert.equal(event!.target!.resource.fsPath, renamed.resource.fsPath); + assert.strictEqual(event!.resource.fsPath, source.fsPath); + assert.strictEqual(event!.operation, FileOperation.COPY); + assert.strictEqual(event!.target!.resource.fsPath, renamed.resource.fsPath); const targetContents = readFileSync(target.fsPath); - assert.equal(sourceContents.byteLength, targetContents.byteLength); - assert.equal(sourceContents.toString(), targetContents.toString()); + assert.strictEqual(sourceContents.byteLength, targetContents.byteLength); + assert.strictEqual(sourceContents.toString(), targetContents.toString()); } test('move - multi folder', async () => { @@ -669,15 +669,15 @@ flakySuite('Disk File Service', function () { const source = URI.file(join(testDir, 'index.html')); - assert.equal(await service.canMove(source, URI.file(join(dirname(source.fsPath), renameToPath))), true); + assert.strictEqual(await service.canMove(source, URI.file(join(dirname(source.fsPath), renameToPath))), true); const renamed = await service.move(source, URI.file(join(dirname(source.fsPath), renameToPath))); - assert.equal(existsSync(renamed.resource.fsPath), true); - assert.equal(existsSync(source.fsPath), false); + assert.strictEqual(existsSync(renamed.resource.fsPath), true); + assert.strictEqual(existsSync(source.fsPath), false); assert.ok(event!); - assert.equal(event!.resource.fsPath, source.fsPath); - assert.equal(event!.operation, FileOperation.MOVE); - assert.equal(event!.target!.resource.fsPath, renamed.resource.fsPath); + assert.strictEqual(event!.resource.fsPath, source.fsPath); + assert.strictEqual(event!.operation, FileOperation.MOVE); + assert.strictEqual(event!.target!.resource.fsPath, renamed.resource.fsPath); }); test('move - directory', async () => { @@ -686,15 +686,15 @@ flakySuite('Disk File Service', function () { const source = URI.file(join(testDir, 'deep')); - assert.equal(await service.canMove(source, URI.file(join(dirname(source.fsPath), 'deeper'))), true); + assert.strictEqual(await service.canMove(source, URI.file(join(dirname(source.fsPath), 'deeper'))), true); const renamed = await service.move(source, URI.file(join(dirname(source.fsPath), 'deeper'))); - assert.equal(existsSync(renamed.resource.fsPath), true); - assert.equal(existsSync(source.fsPath), false); + assert.strictEqual(existsSync(renamed.resource.fsPath), true); + assert.strictEqual(existsSync(source.fsPath), false); assert.ok(event!); - assert.equal(event!.resource.fsPath, source.fsPath); - assert.equal(event!.operation, FileOperation.MOVE); - assert.equal(event!.target!.resource.fsPath, renamed.resource.fsPath); + assert.strictEqual(event!.resource.fsPath, source.fsPath); + assert.strictEqual(event!.operation, FileOperation.MOVE); + assert.strictEqual(event!.target!.resource.fsPath, renamed.resource.fsPath); }); test('move - directory - across providers (buffered => buffered)', async () => { @@ -734,20 +734,20 @@ flakySuite('Disk File Service', function () { const target = URI.file(join(dirname(source.fsPath), 'deeper')).with({ scheme: testSchema }); - assert.equal(await service.canMove(source, target), true); + assert.strictEqual(await service.canMove(source, target), true); const renamed = await service.move(source, target); - assert.equal(existsSync(renamed.resource.fsPath), true); - assert.equal(existsSync(source.fsPath), false); + assert.strictEqual(existsSync(renamed.resource.fsPath), true); + assert.strictEqual(existsSync(source.fsPath), false); assert.ok(event!); - assert.equal(event!.resource.fsPath, source.fsPath); - assert.equal(event!.operation, FileOperation.COPY); - assert.equal(event!.target!.resource.fsPath, renamed.resource.fsPath); + assert.strictEqual(event!.resource.fsPath, source.fsPath); + assert.strictEqual(event!.operation, FileOperation.COPY); + assert.strictEqual(event!.target!.resource.fsPath, renamed.resource.fsPath); const targetChildren = readdirSync(target.fsPath); - assert.equal(sourceChildren.length, targetChildren.length); + assert.strictEqual(sourceChildren.length, targetChildren.length); for (let i = 0; i < sourceChildren.length; i++) { - assert.equal(sourceChildren[i], targetChildren[i]); + assert.strictEqual(sourceChildren[i], targetChildren[i]); } } @@ -759,18 +759,18 @@ flakySuite('Disk File Service', function () { assert.ok(source.size > 0); const renamedResource = URI.file(join(dirname(source.resource.fsPath), 'INDEX.html')); - assert.equal(await service.canMove(source.resource, renamedResource), true); + assert.strictEqual(await service.canMove(source.resource, renamedResource), true); let renamed = await service.move(source.resource, renamedResource); - assert.equal(existsSync(renamedResource.fsPath), true); - assert.equal(basename(renamedResource.fsPath), 'INDEX.html'); + assert.strictEqual(existsSync(renamedResource.fsPath), true); + assert.strictEqual(basename(renamedResource.fsPath), 'INDEX.html'); assert.ok(event!); - assert.equal(event!.resource.fsPath, source.resource.fsPath); - assert.equal(event!.operation, FileOperation.MOVE); - assert.equal(event!.target!.resource.fsPath, renamedResource.fsPath); + assert.strictEqual(event!.resource.fsPath, source.resource.fsPath); + assert.strictEqual(event!.operation, FileOperation.MOVE); + assert.strictEqual(event!.target!.resource.fsPath, renamedResource.fsPath); renamed = await service.resolve(renamedResource, { resolveMetadata: true }); - assert.equal(source.size, renamed.size); + assert.strictEqual(source.size, renamed.size); }); test('move - same file', async () => { @@ -780,18 +780,18 @@ flakySuite('Disk File Service', function () { const source = await service.resolve(URI.file(join(testDir, 'index.html')), { resolveMetadata: true }); assert.ok(source.size > 0); - assert.equal(await service.canMove(source.resource, URI.file(source.resource.fsPath)), true); + assert.strictEqual(await service.canMove(source.resource, URI.file(source.resource.fsPath)), true); let renamed = await service.move(source.resource, URI.file(source.resource.fsPath)); - assert.equal(existsSync(renamed.resource.fsPath), true); - assert.equal(basename(renamed.resource.fsPath), 'index.html'); + assert.strictEqual(existsSync(renamed.resource.fsPath), true); + assert.strictEqual(basename(renamed.resource.fsPath), 'index.html'); assert.ok(event!); - assert.equal(event!.resource.fsPath, source.resource.fsPath); - assert.equal(event!.operation, FileOperation.MOVE); - assert.equal(event!.target!.resource.fsPath, renamed.resource.fsPath); + assert.strictEqual(event!.resource.fsPath, source.resource.fsPath); + assert.strictEqual(event!.operation, FileOperation.MOVE); + assert.strictEqual(event!.target!.resource.fsPath, renamed.resource.fsPath); renamed = await service.resolve(renamed.resource, { resolveMetadata: true }); - assert.equal(source.size, renamed.size); + assert.strictEqual(source.size, renamed.size); }); test('move - same file #2', async () => { @@ -804,18 +804,18 @@ flakySuite('Disk File Service', function () { const targetParent = URI.file(testDir); const target = targetParent.with({ path: posix.join(targetParent.path, posix.basename(source.resource.path)) }); - assert.equal(await service.canMove(source.resource, target), true); + assert.strictEqual(await service.canMove(source.resource, target), true); let renamed = await service.move(source.resource, target); - assert.equal(existsSync(renamed.resource.fsPath), true); - assert.equal(basename(renamed.resource.fsPath), 'index.html'); + assert.strictEqual(existsSync(renamed.resource.fsPath), true); + assert.strictEqual(basename(renamed.resource.fsPath), 'index.html'); assert.ok(event!); - assert.equal(event!.resource.fsPath, source.resource.fsPath); - assert.equal(event!.operation, FileOperation.MOVE); - assert.equal(event!.target!.resource.fsPath, renamed.resource.fsPath); + assert.strictEqual(event!.resource.fsPath, source.resource.fsPath); + assert.strictEqual(event!.operation, FileOperation.MOVE); + assert.strictEqual(event!.target!.resource.fsPath, renamed.resource.fsPath); renamed = await service.resolve(renamed.resource, { resolveMetadata: true }); - assert.equal(source.size, renamed.size); + assert.strictEqual(source.size, renamed.size); }); test('move - source parent of target', async () => { @@ -839,7 +839,7 @@ flakySuite('Disk File Service', function () { assert.ok(!event!); source = await service.resolve(source.resource, { resolveMetadata: true }); - assert.equal(originalSize, source.size); + assert.strictEqual(originalSize, source.size); }); test('move - FILE_MOVE_CONFLICT', async () => { @@ -859,11 +859,11 @@ flakySuite('Disk File Service', function () { error = e; } - assert.equal(error.fileOperationResult, FileOperationResult.FILE_MOVE_CONFLICT); + assert.strictEqual(error.fileOperationResult, FileOperationResult.FILE_MOVE_CONFLICT); assert.ok(!event!); source = await service.resolve(source.resource, { resolveMetadata: true }); - assert.equal(originalSize, source.size); + assert.strictEqual(originalSize, source.size); }); test('move - overwrite folder with file', async () => { @@ -885,17 +885,17 @@ flakySuite('Disk File Service', function () { const f = await service.createFolder(folderResource); const source = URI.file(join(testDir, 'deep', 'conway.js')); - assert.equal(await service.canMove(source, f.resource, true), true); + assert.strictEqual(await service.canMove(source, f.resource, true), true); const moved = await service.move(source, f.resource, true); - assert.equal(existsSync(moved.resource.fsPath), true); + assert.strictEqual(existsSync(moved.resource.fsPath), true); assert.ok(statSync(moved.resource.fsPath).isFile); assert.ok(createEvent!); assert.ok(deleteEvent!); assert.ok(moveEvent!); - assert.equal(moveEvent!.resource.fsPath, source.fsPath); - assert.equal(moveEvent!.target!.resource.fsPath, moved.resource.fsPath); - assert.equal(deleteEvent!.resource.fsPath, folderResource.fsPath); + assert.strictEqual(moveEvent!.resource.fsPath, source.fsPath); + assert.strictEqual(moveEvent!.target!.resource.fsPath, moved.resource.fsPath); + assert.strictEqual(deleteEvent!.resource.fsPath, folderResource.fsPath); }); test('copy', async () => { @@ -940,21 +940,21 @@ flakySuite('Disk File Service', function () { const source = await service.resolve(URI.file(join(testDir, sourceName))); const target = URI.file(join(testDir, 'other.html')); - assert.equal(await service.canCopy(source.resource, target), true); + assert.strictEqual(await service.canCopy(source.resource, target), true); const copied = await service.copy(source.resource, target); - assert.equal(existsSync(copied.resource.fsPath), true); - assert.equal(existsSync(source.resource.fsPath), true); + assert.strictEqual(existsSync(copied.resource.fsPath), true); + assert.strictEqual(existsSync(source.resource.fsPath), true); assert.ok(event!); - assert.equal(event!.resource.fsPath, source.resource.fsPath); - assert.equal(event!.operation, FileOperation.COPY); - assert.equal(event!.target!.resource.fsPath, copied.resource.fsPath); + assert.strictEqual(event!.resource.fsPath, source.resource.fsPath); + assert.strictEqual(event!.operation, FileOperation.COPY); + assert.strictEqual(event!.target!.resource.fsPath, copied.resource.fsPath); const sourceContents = readFileSync(source.resource.fsPath); const targetContents = readFileSync(target.fsPath); - assert.equal(sourceContents.byteLength, targetContents.byteLength); - assert.equal(sourceContents.toString(), targetContents.toString()); + assert.strictEqual(sourceContents.byteLength, targetContents.byteLength); + assert.strictEqual(sourceContents.toString(), targetContents.toString()); } test('copy - overwrite folder with file', async () => { @@ -976,17 +976,17 @@ flakySuite('Disk File Service', function () { const f = await service.createFolder(folderResource); const source = URI.file(join(testDir, 'deep', 'conway.js')); - assert.equal(await service.canCopy(source, f.resource, true), true); + assert.strictEqual(await service.canCopy(source, f.resource, true), true); const copied = await service.copy(source, f.resource, true); - assert.equal(existsSync(copied.resource.fsPath), true); + assert.strictEqual(existsSync(copied.resource.fsPath), true); assert.ok(statSync(copied.resource.fsPath).isFile); assert.ok(createEvent!); assert.ok(deleteEvent!); assert.ok(copyEvent!); - assert.equal(copyEvent!.resource.fsPath, source.fsPath); - assert.equal(copyEvent!.target!.resource.fsPath, copied.resource.fsPath); - assert.equal(deleteEvent!.resource.fsPath, folderResource.fsPath); + assert.strictEqual(copyEvent!.resource.fsPath, source.fsPath); + assert.strictEqual(copyEvent!.target!.resource.fsPath, copied.resource.fsPath); + assert.strictEqual(deleteEvent!.resource.fsPath, folderResource.fsPath); }); test('copy - MIX CASE same target - no overwrite', async () => { @@ -1008,17 +1008,17 @@ flakySuite('Disk File Service', function () { if (isLinux) { assert.ok(!error); - assert.equal(canCopy, true); + assert.strictEqual(canCopy, true); - assert.equal(existsSync(copied!.resource.fsPath), true); + assert.strictEqual(existsSync(copied!.resource.fsPath), true); assert.ok(readdirSync(testDir).some(f => f === 'INDEX.html')); - assert.equal(source.size, copied!.size); + assert.strictEqual(source.size, copied!.size); } else { assert.ok(error); assert.ok(canCopy instanceof Error); source = await service.resolve(source.resource, { resolveMetadata: true }); - assert.equal(originalSize, source.size); + assert.strictEqual(originalSize, source.size); } }); @@ -1041,17 +1041,17 @@ flakySuite('Disk File Service', function () { if (isLinux) { assert.ok(!error); - assert.equal(canCopy, true); + assert.strictEqual(canCopy, true); - assert.equal(existsSync(copied!.resource.fsPath), true); + assert.strictEqual(existsSync(copied!.resource.fsPath), true); assert.ok(readdirSync(testDir).some(f => f === 'INDEX.html')); - assert.equal(source.size, copied!.size); + assert.strictEqual(source.size, copied!.size); } else { assert.ok(error); assert.ok(canCopy instanceof Error); source = await service.resolve(source.resource, { resolveMetadata: true }); - assert.equal(originalSize, source.size); + assert.strictEqual(originalSize, source.size); } }); @@ -1060,18 +1060,18 @@ flakySuite('Disk File Service', function () { assert.ok(source1.size > 0); const renamed = await service.move(source1.resource, URI.file(join(dirname(source1.resource.fsPath), 'CONWAY.js'))); - assert.equal(existsSync(renamed.resource.fsPath), true); + assert.strictEqual(existsSync(renamed.resource.fsPath), true); assert.ok(readdirSync(testDir).some(f => f === 'CONWAY.js')); - assert.equal(source1.size, renamed.size); + assert.strictEqual(source1.size, renamed.size); const source2 = await service.resolve(URI.file(join(testDir, 'deep', 'conway.js')), { resolveMetadata: true }); const target = URI.file(join(testDir, basename(source2.resource.path))); - assert.equal(await service.canCopy(source2.resource, target, true), true); + assert.strictEqual(await service.canCopy(source2.resource, target, true), true); const res = await service.copy(source2.resource, target, true); - assert.equal(existsSync(res.resource.fsPath), true); + assert.strictEqual(existsSync(res.resource.fsPath), true); assert.ok(readdirSync(testDir).some(f => f === 'conway.js')); - assert.equal(source2.size, res.size); + assert.strictEqual(source2.size, res.size); }); test('copy - same file', async () => { @@ -1081,18 +1081,18 @@ flakySuite('Disk File Service', function () { const source = await service.resolve(URI.file(join(testDir, 'index.html')), { resolveMetadata: true }); assert.ok(source.size > 0); - assert.equal(await service.canCopy(source.resource, URI.file(source.resource.fsPath)), true); + assert.strictEqual(await service.canCopy(source.resource, URI.file(source.resource.fsPath)), true); let copied = await service.copy(source.resource, URI.file(source.resource.fsPath)); - assert.equal(existsSync(copied.resource.fsPath), true); - assert.equal(basename(copied.resource.fsPath), 'index.html'); + assert.strictEqual(existsSync(copied.resource.fsPath), true); + assert.strictEqual(basename(copied.resource.fsPath), 'index.html'); assert.ok(event!); - assert.equal(event!.resource.fsPath, source.resource.fsPath); - assert.equal(event!.operation, FileOperation.COPY); - assert.equal(event!.target!.resource.fsPath, copied.resource.fsPath); + assert.strictEqual(event!.resource.fsPath, source.resource.fsPath); + assert.strictEqual(event!.operation, FileOperation.COPY); + assert.strictEqual(event!.target!.resource.fsPath, copied.resource.fsPath); copied = await service.resolve(source.resource, { resolveMetadata: true }); - assert.equal(source.size, copied.size); + assert.strictEqual(source.size, copied.size); }); test('copy - same file #2', async () => { @@ -1105,18 +1105,18 @@ flakySuite('Disk File Service', function () { const targetParent = URI.file(testDir); const target = targetParent.with({ path: posix.join(targetParent.path, posix.basename(source.resource.path)) }); - assert.equal(await service.canCopy(source.resource, URI.file(target.fsPath)), true); + assert.strictEqual(await service.canCopy(source.resource, URI.file(target.fsPath)), true); let copied = await service.copy(source.resource, URI.file(target.fsPath)); - assert.equal(existsSync(copied.resource.fsPath), true); - assert.equal(basename(copied.resource.fsPath), 'index.html'); + assert.strictEqual(existsSync(copied.resource.fsPath), true); + assert.strictEqual(basename(copied.resource.fsPath), 'index.html'); assert.ok(event!); - assert.equal(event!.resource.fsPath, source.resource.fsPath); - assert.equal(event!.operation, FileOperation.COPY); - assert.equal(event!.target!.resource.fsPath, copied.resource.fsPath); + assert.strictEqual(event!.resource.fsPath, source.resource.fsPath); + assert.strictEqual(event!.operation, FileOperation.COPY); + assert.strictEqual(event!.target!.resource.fsPath, copied.resource.fsPath); copied = await service.resolve(source.resource, { resolveMetadata: true }); - assert.equal(source.size, copied.size); + assert.strictEqual(source.size, copied.size); }); test('readFile - small file - default', () => { @@ -1184,7 +1184,7 @@ flakySuite('Disk File Service', function () { async function testReadFile(resource: URI): Promise { const content = await service.readFile(resource); - assert.equal(content.value.toString(), readFileSync(resource.fsPath)); + assert.strictEqual(content.value.toString(), readFileSync(resource.fsPath).toString()); } test('readFileStream - small file - default', () => { @@ -1212,7 +1212,7 @@ flakySuite('Disk File Service', function () { async function testReadFileStream(resource: URI): Promise { const content = await service.readFileStream(resource); - assert.equal((await streamToBuffer(content.value)).toString(), readFileSync(resource.fsPath)); + assert.strictEqual((await streamToBuffer(content.value)).toString(), readFileSync(resource.fsPath).toString()); } test('readFile - Files are intermingled #38331 - default', async () => { @@ -1251,8 +1251,8 @@ flakySuite('Disk File Service', function () { service.readFile(resource2) ]); - assert.equal(result[0].value.toString(), value1.value.toString()); - assert.equal(result[1].value.toString(), value2.value.toString()); + assert.strictEqual(result[0].value.toString(), value1.value.toString()); + assert.strictEqual(result[1].value.toString(), value2.value.toString()); } test('readFile - from position (ASCII) - default', async () => { @@ -1282,7 +1282,7 @@ flakySuite('Disk File Service', function () { const contents = await service.readFile(resource, { position: 6 }); - assert.equal(contents.value.toString(), 'File'); + assert.strictEqual(contents.value.toString(), 'File'); } test('readFile - from position (with umlaut) - default', async () => { @@ -1312,7 +1312,7 @@ flakySuite('Disk File Service', function () { const contents = await service.readFile(resource, { position: Buffer.from('Small File with Ü').length }); - assert.equal(contents.value.toString(), 'mlaut'); + assert.strictEqual(contents.value.toString(), 'mlaut'); } test('readFile - 3 bytes (ASCII) - default', async () => { @@ -1342,7 +1342,7 @@ flakySuite('Disk File Service', function () { const contents = await service.readFile(resource, { length: 3 }); - assert.equal(contents.value.toString(), 'Sma'); + assert.strictEqual(contents.value.toString(), 'Sma'); } test('readFile - 20000 bytes (large) - default', async () => { @@ -1394,7 +1394,7 @@ flakySuite('Disk File Service', function () { const contents = await service.readFile(resource, { length }); - assert.equal(contents.value.byteLength, length); + assert.strictEqual(contents.value.byteLength, length); } test('readFile - FILE_IS_DIRECTORY', async () => { @@ -1408,7 +1408,7 @@ flakySuite('Disk File Service', function () { } assert.ok(error); - assert.equal(error!.fileOperationResult, FileOperationResult.FILE_IS_DIRECTORY); + assert.strictEqual(error!.fileOperationResult, FileOperationResult.FILE_IS_DIRECTORY); }); (isWindows /* error code does not seem to be supported on windows */ ? test.skip : test)('readFile - FILE_NOT_DIRECTORY', async () => { @@ -1422,7 +1422,7 @@ flakySuite('Disk File Service', function () { } assert.ok(error); - assert.equal(error!.fileOperationResult, FileOperationResult.FILE_NOT_DIRECTORY); + assert.strictEqual(error!.fileOperationResult, FileOperationResult.FILE_NOT_DIRECTORY); }); test('readFile - FILE_NOT_FOUND', async () => { @@ -1436,7 +1436,7 @@ flakySuite('Disk File Service', function () { } assert.ok(error); - assert.equal(error!.fileOperationResult, FileOperationResult.FILE_NOT_FOUND); + assert.strictEqual(error!.fileOperationResult, FileOperationResult.FILE_NOT_FOUND); }); test('readFile - FILE_NOT_MODIFIED_SINCE - default', async () => { @@ -1475,8 +1475,8 @@ flakySuite('Disk File Service', function () { } assert.ok(error); - assert.equal(error!.fileOperationResult, FileOperationResult.FILE_NOT_MODIFIED_SINCE); - assert.equal(fileProvider.totalBytesRead, 0); + assert.strictEqual(error!.fileOperationResult, FileOperationResult.FILE_NOT_MODIFIED_SINCE); + assert.strictEqual(fileProvider.totalBytesRead, 0); } test('readFile - FILE_NOT_MODIFIED_SINCE does not fire wrongly - https://github.com/microsoft/vscode/issues/72909', async () => { @@ -1537,7 +1537,7 @@ flakySuite('Disk File Service', function () { } assert.ok(error); - assert.equal(error!.fileOperationResult, FileOperationResult.FILE_EXCEEDS_MEMORY_LIMIT); + assert.strictEqual(error!.fileOperationResult, FileOperationResult.FILE_EXCEEDS_MEMORY_LIMIT); } test('readFile - FILE_TOO_LARGE - default', async () => { @@ -1581,7 +1581,7 @@ flakySuite('Disk File Service', function () { } assert.ok(error); - assert.equal(error!.fileOperationResult, FileOperationResult.FILE_TOO_LARGE); + assert.strictEqual(error!.fileOperationResult, FileOperationResult.FILE_TOO_LARGE); } test('createFile', async () => { @@ -1603,16 +1603,16 @@ flakySuite('Disk File Service', function () { const contents = 'Hello World'; const resource = URI.file(join(testDir, 'test.txt')); - assert.equal(await service.canCreateFile(resource), true); + assert.strictEqual(await service.canCreateFile(resource), true); const fileStat = await service.createFile(resource, converter(contents)); - assert.equal(fileStat.name, 'test.txt'); - assert.equal(existsSync(fileStat.resource.fsPath), true); - assert.equal(readFileSync(fileStat.resource.fsPath), contents); + assert.strictEqual(fileStat.name, 'test.txt'); + assert.strictEqual(existsSync(fileStat.resource.fsPath), true); + assert.strictEqual(readFileSync(fileStat.resource.fsPath).toString(), contents); assert.ok(event!); - assert.equal(event!.resource.fsPath, resource.fsPath); - assert.equal(event!.operation, FileOperation.CREATE); - assert.equal(event!.target!.resource.fsPath, resource.fsPath); + assert.strictEqual(event!.resource.fsPath, resource.fsPath); + assert.strictEqual(event!.operation, FileOperation.CREATE); + assert.strictEqual(event!.target!.resource.fsPath, resource.fsPath); } test('createFile (does not overwrite by default)', async () => { @@ -1642,16 +1642,16 @@ flakySuite('Disk File Service', function () { writeFileSync(resource.fsPath, ''); // create file - assert.equal(await service.canCreateFile(resource, { overwrite: true }), true); + assert.strictEqual(await service.canCreateFile(resource, { overwrite: true }), true); const fileStat = await service.createFile(resource, VSBuffer.fromString(contents), { overwrite: true }); - assert.equal(fileStat.name, 'test.txt'); - assert.equal(existsSync(fileStat.resource.fsPath), true); - assert.equal(readFileSync(fileStat.resource.fsPath), contents); + assert.strictEqual(fileStat.name, 'test.txt'); + assert.strictEqual(existsSync(fileStat.resource.fsPath), true); + assert.strictEqual(readFileSync(fileStat.resource.fsPath).toString(), contents); assert.ok(event!); - assert.equal(event!.resource.fsPath, resource.fsPath); - assert.equal(event!.operation, FileOperation.CREATE); - assert.equal(event!.target!.resource.fsPath, resource.fsPath); + assert.strictEqual(event!.resource.fsPath, resource.fsPath); + assert.strictEqual(event!.operation, FileOperation.CREATE); + assert.strictEqual(event!.target!.resource.fsPath, resource.fsPath); }); test('writeFile - default', async () => { @@ -1673,13 +1673,13 @@ flakySuite('Disk File Service', function () { async function testWriteFile() { const resource = URI.file(join(testDir, 'small.txt')); - const content = readFileSync(resource.fsPath); - assert.equal(content, 'Small File'); + const content = readFileSync(resource.fsPath).toString(); + assert.strictEqual(content, 'Small File'); const newContent = 'Updates to the small file'; await service.writeFile(resource, VSBuffer.fromString(newContent)); - assert.equal(readFileSync(resource.fsPath), newContent); + assert.strictEqual(readFileSync(resource.fsPath).toString(), newContent); } test('writeFile (large file) - default', async () => { @@ -1705,9 +1705,9 @@ flakySuite('Disk File Service', function () { const newContent = content.toString() + content.toString(); const fileStat = await service.writeFile(resource, VSBuffer.fromString(newContent)); - assert.equal(fileStat.name, 'lorem.txt'); + assert.strictEqual(fileStat.name, 'lorem.txt'); - assert.equal(readFileSync(resource.fsPath), newContent); + assert.strictEqual(readFileSync(resource.fsPath).toString(), newContent); } test('writeFile - buffered - readonly throws', async () => { @@ -1725,8 +1725,8 @@ flakySuite('Disk File Service', function () { async function testWriteFileReadonlyThrows() { const resource = URI.file(join(testDir, 'small.txt')); - const content = readFileSync(resource.fsPath); - assert.equal(content, 'Small File'); + const content = readFileSync(resource.fsPath).toString(); + assert.strictEqual(content, 'Small File'); const newContent = 'Updates to the small file'; @@ -1748,7 +1748,7 @@ flakySuite('Disk File Service', function () { await Promise.all(['0', '00', '000', '0000', '00000'].map(async offset => { const fileStat = await service.writeFile(resource, VSBuffer.fromString(offset + newContent)); - assert.equal(fileStat.name, 'lorem.txt'); + assert.strictEqual(fileStat.name, 'lorem.txt'); })); const fileContent = readFileSync(resource.fsPath).toString(); @@ -1774,13 +1774,13 @@ flakySuite('Disk File Service', function () { async function testWriteFileReadable() { const resource = URI.file(join(testDir, 'small.txt')); - const content = readFileSync(resource.fsPath); - assert.equal(content, 'Small File'); + const content = readFileSync(resource.fsPath).toString(); + assert.strictEqual(content, 'Small File'); const newContent = 'Updates to the small file'; await service.writeFile(resource, toLineByLineReadable(newContent)); - assert.equal(readFileSync(resource.fsPath), newContent); + assert.strictEqual(readFileSync(resource.fsPath).toString(), newContent); } test('writeFile (large file - readable) - default', async () => { @@ -1806,9 +1806,9 @@ flakySuite('Disk File Service', function () { const newContent = content.toString() + content.toString(); const fileStat = await service.writeFile(resource, toLineByLineReadable(newContent)); - assert.equal(fileStat.name, 'lorem.txt'); + assert.strictEqual(fileStat.name, 'lorem.txt'); - assert.equal(readFileSync(resource.fsPath), newContent); + assert.strictEqual(readFileSync(resource.fsPath).toString(), newContent); } test('writeFile (stream) - default', async () => { @@ -1832,10 +1832,10 @@ flakySuite('Disk File Service', function () { const target = URI.file(join(testDir, 'small-copy.txt')); const fileStat = await service.writeFile(target, streamToBufferReadableStream(createReadStream(source.fsPath))); - assert.equal(fileStat.name, 'small-copy.txt'); + assert.strictEqual(fileStat.name, 'small-copy.txt'); const targetContents = readFileSync(target.fsPath).toString(); - assert.equal(readFileSync(source.fsPath).toString(), targetContents); + assert.strictEqual(readFileSync(source.fsPath).toString(), targetContents); } test('writeFile (large file - stream) - default', async () => { @@ -1859,10 +1859,10 @@ flakySuite('Disk File Service', function () { const target = URI.file(join(testDir, 'lorem-copy.txt')); const fileStat = await service.writeFile(target, streamToBufferReadableStream(createReadStream(source.fsPath))); - assert.equal(fileStat.name, 'lorem-copy.txt'); + assert.strictEqual(fileStat.name, 'lorem-copy.txt'); const targetContents = readFileSync(target.fsPath).toString(); - assert.equal(readFileSync(source.fsPath).toString(), targetContents); + assert.strictEqual(readFileSync(source.fsPath).toString(), targetContents); } test('writeFile (file is created including parents)', async () => { @@ -1870,9 +1870,9 @@ flakySuite('Disk File Service', function () { const content = 'File is created including parent'; const fileStat = await service.writeFile(resource, VSBuffer.fromString(content)); - assert.equal(fileStat.name, 'newfile.txt'); + assert.strictEqual(fileStat.name, 'newfile.txt'); - assert.equal(readFileSync(resource.fsPath), content); + assert.strictEqual(readFileSync(resource.fsPath).toString(), content); }); test('writeFile (error when folder is encountered)', async () => { @@ -1893,13 +1893,13 @@ flakySuite('Disk File Service', function () { const stat = await service.resolve(resource); - const content = readFileSync(resource.fsPath); - assert.equal(content, 'Small File'); + const content = readFileSync(resource.fsPath).toString(); + assert.strictEqual(content, 'Small File'); const newContent = 'Updates to the small file'; await service.writeFile(resource, VSBuffer.fromString(newContent), { etag: stat.etag, mtime: stat.mtime }); - assert.equal(readFileSync(resource.fsPath), newContent); + assert.strictEqual(readFileSync(resource.fsPath).toString(), newContent); }); test('writeFile - error when writing to file that has been updated meanwhile', async () => { @@ -1908,7 +1908,7 @@ flakySuite('Disk File Service', function () { const stat = await service.resolve(resource); const content = readFileSync(resource.fsPath).toString(); - assert.equal(content, 'Small File'); + assert.strictEqual(content, 'Small File'); const newContent = 'Updates to the small file'; await service.writeFile(resource, VSBuffer.fromString(newContent), { etag: stat.etag, mtime: stat.mtime }); @@ -1927,7 +1927,7 @@ flakySuite('Disk File Service', function () { assert.ok(error); assert.ok(error instanceof FileOperationError); - assert.equal(error!.fileOperationResult, FileOperationResult.FILE_MODIFIED_SINCE); + assert.strictEqual(error!.fileOperationResult, FileOperationResult.FILE_MODIFIED_SINCE); }); test('writeFile - no error when writing to file where size is the same', async () => { @@ -1936,7 +1936,7 @@ flakySuite('Disk File Service', function () { const stat = await service.resolve(resource); const content = readFileSync(resource.fsPath).toString(); - assert.equal(content, 'Small File'); + assert.strictEqual(content, 'Small File'); const newContent = content; // same content await service.writeFile(resource, VSBuffer.fromString(newContent), { etag: stat.etag, mtime: stat.mtime }); @@ -2197,14 +2197,14 @@ flakySuite('Disk File Service', function () { listenerDisposable.dispose(); try { - assert.equal(event.changes.length, expected.length, `Expected ${expected.length} events, but got ${event.changes.length}. Details (${printEvents(event)})`); + assert.strictEqual(event.changes.length, expected.length, `Expected ${expected.length} events, but got ${event.changes.length}. Details (${printEvents(event)})`); if (expected.length === 1) { - assert.equal(event.changes[0].type, expected[0][0], `Expected ${toString(expected[0][0])} but got ${toString(event.changes[0].type)}. Details (${printEvents(event)})`); - assert.equal(event.changes[0].resource.fsPath, expected[0][1].fsPath); + assert.strictEqual(event.changes[0].type, expected[0][0], `Expected ${toString(expected[0][0])} but got ${toString(event.changes[0].type)}. Details (${printEvents(event)})`); + assert.strictEqual(event.changes[0].resource.fsPath, expected[0][1].fsPath); } else { for (const expect of expected) { - assert.equal(hasChange(event.changes, expect[0], expect[1]), true, `Unable to find ${toString(expect[0])} for ${expect[1].fsPath}. Details (${printEvents(event)})`); + assert.strictEqual(hasChange(event.changes, expect[0], expect[1]), true, `Unable to find ${toString(expect[0])} for ${expect[1].fsPath}. Details (${printEvents(event)})`); } } @@ -2228,7 +2228,7 @@ flakySuite('Disk File Service', function () { let fd = await fileProvider.open(resource, { create: false }); for (let i = 0; i < 3; i++) { await fileProvider.read(fd, 0, buffer.buffer, 0, 26); - assert.equal(buffer.slice(0, 26).toString(), 'Lorem ipsum dolor sit amet'); + assert.strictEqual(buffer.slice(0, 26).toString(), 'Lorem ipsum dolor sit amet'); } await fileProvider.close(fd); @@ -2239,31 +2239,31 @@ flakySuite('Disk File Service', function () { let posInFile = 0; await fileProvider.read(fd, posInFile, buffer.buffer, 0, 26); - assert.equal(buffer.slice(0, 26).toString(), 'Lorem ipsum dolor sit amet'); + assert.strictEqual(buffer.slice(0, 26).toString(), 'Lorem ipsum dolor sit amet'); posInFile += 26; await fileProvider.read(fd, posInFile, buffer.buffer, 0, 1); - assert.equal(buffer.slice(0, 1).toString(), ','); + assert.strictEqual(buffer.slice(0, 1).toString(), ','); posInFile += 1; await fileProvider.read(fd, posInFile, buffer.buffer, 0, 12); - assert.equal(buffer.slice(0, 12).toString(), ' consectetur'); + assert.strictEqual(buffer.slice(0, 12).toString(), ' consectetur'); posInFile += 12; await fileProvider.read(fd, 98 /* no longer in sequence of posInFile */, buffer.buffer, 0, 9); - assert.equal(buffer.slice(0, 9).toString(), 'fermentum'); + assert.strictEqual(buffer.slice(0, 9).toString(), 'fermentum'); await fileProvider.read(fd, 27, buffer.buffer, 0, 12); - assert.equal(buffer.slice(0, 12).toString(), ' consectetur'); + assert.strictEqual(buffer.slice(0, 12).toString(), ' consectetur'); await fileProvider.read(fd, 26, buffer.buffer, 0, 1); - assert.equal(buffer.slice(0, 1).toString(), ','); + assert.strictEqual(buffer.slice(0, 1).toString(), ','); await fileProvider.read(fd, 0, buffer.buffer, 0, 26); - assert.equal(buffer.slice(0, 26).toString(), 'Lorem ipsum dolor sit amet'); + assert.strictEqual(buffer.slice(0, 26).toString(), 'Lorem ipsum dolor sit amet'); await fileProvider.read(fd, posInFile /* back in sequence */, buffer.buffer, 0, 11); - assert.equal(buffer.slice(0, 11).toString(), ' adipiscing'); + assert.strictEqual(buffer.slice(0, 11).toString(), ' adipiscing'); await fileProvider.close(fd); }); @@ -2283,7 +2283,7 @@ flakySuite('Disk File Service', function () { posInFileWrite += initialContents.byteLength; await fileProvider.read(fdRead, posInFileRead, buffer.buffer, 0, 26); - assert.equal(buffer.slice(0, 26).toString(), 'Lorem ipsum dolor sit amet'); + assert.strictEqual(buffer.slice(0, 26).toString(), 'Lorem ipsum dolor sit amet'); posInFileRead += 26; const contents = VSBuffer.fromString('Hello World'); @@ -2292,19 +2292,19 @@ flakySuite('Disk File Service', function () { posInFileWrite += contents.byteLength; await fileProvider.read(fdRead, posInFileRead, buffer.buffer, 0, contents.byteLength); - assert.equal(buffer.slice(0, contents.byteLength).toString(), 'Hello World'); + assert.strictEqual(buffer.slice(0, contents.byteLength).toString(), 'Hello World'); posInFileRead += contents.byteLength; await fileProvider.write(fdWrite, 6, contents.buffer, 0, contents.byteLength); await fileProvider.read(fdRead, 0, buffer.buffer, 0, 11); - assert.equal(buffer.slice(0, 11).toString(), 'Lorem Hello'); + assert.strictEqual(buffer.slice(0, 11).toString(), 'Lorem Hello'); await fileProvider.write(fdWrite, posInFileWrite, contents.buffer, 0, contents.byteLength); posInFileWrite += contents.byteLength; await fileProvider.read(fdRead, posInFileWrite - contents.byteLength, buffer.buffer, 0, contents.byteLength); - assert.equal(buffer.slice(0, contents.byteLength).toString(), 'Hello World'); + assert.strictEqual(buffer.slice(0, contents.byteLength).toString(), 'Hello World'); await fileProvider.close(fdWrite); await fileProvider.close(fdRead); diff --git a/src/vs/platform/windows/test/electron-main/window.test.ts b/src/vs/platform/windows/test/electron-main/window.test.ts index cc3bdb720ce..42f458f9776 100644 --- a/src/vs/platform/windows/test/electron-main/window.test.ts +++ b/src/vs/platform/windows/test/electron-main/window.test.ts @@ -83,8 +83,8 @@ const windows: ICodeWindow[] = [ suite('WindowsFinder', () => { test('New window without folder when no windows exist', () => { - assert.equal(findWindowOnFile([], URI.file('nonexisting'), localWorkspaceResolver), null); - assert.equal(findWindowOnFile([], URI.file(path.join(fixturesFolder, 'no_vscode_folder', 'file.txt')), localWorkspaceResolver), null); + assert.strictEqual(findWindowOnFile([], URI.file('nonexisting'), localWorkspaceResolver), undefined); + assert.strictEqual(findWindowOnFile([], URI.file(path.join(fixturesFolder, 'no_vscode_folder', 'file.txt')), localWorkspaceResolver), undefined); }); test('Existing window with folder', () => { diff --git a/src/vs/platform/workspaces/test/electron-main/workspacesHistoryStorage.test.ts b/src/vs/platform/workspaces/test/electron-main/workspacesHistoryStorage.test.ts index 3439009aa91..6f502744882 100644 --- a/src/vs/platform/workspaces/test/electron-main/workspacesHistoryStorage.test.ts +++ b/src/vs/platform/workspaces/test/electron-main/workspacesHistoryStorage.test.ts @@ -129,8 +129,5 @@ suite('History Storage', () => { }; assertEqualRecentlyOpened(windowsState, expected, 'v1_33'); - }); - - }); diff --git a/src/vs/platform/workspaces/test/electron-main/workspacesManagementMainService.test.ts b/src/vs/platform/workspaces/test/electron-main/workspacesManagementMainService.test.ts index 7dfaf962c4d..2cbc34f48ca 100644 --- a/src/vs/platform/workspaces/test/electron-main/workspacesManagementMainService.test.ts +++ b/src/vs/platform/workspaces/test/electron-main/workspacesManagementMainService.test.ts @@ -105,14 +105,6 @@ export class TestBackupMainService implements IBackupMainService { } suite('WorkspacesManagementMainService', () => { - const parentDir = getRandomTestPath(os.tmpdir(), 'vsctests', 'workspacesmanagementmainservice'); - const untitledWorkspacesHomePath = path.join(parentDir, 'Workspaces'); - - class TestEnvironmentService extends EnvironmentMainService { - get untitledWorkspacesHome(): URI { - return URI.file(untitledWorkspacesHomePath); - } - } function createUntitledWorkspace(folders: string[], names?: string[]) { return service.createUntitledWorkspace(folders.map((folder, index) => ({ uri: URI.file(folder), name: names ? names[index] : undefined } as IWorkspaceFolderCreationData))); @@ -138,22 +130,31 @@ suite('WorkspacesManagementMainService', () => { return service.createUntitledWorkspaceSync(folders.map((folder, index) => ({ uri: URI.file(folder), name: names ? names[index] : undefined } as IWorkspaceFolderCreationData))); } - const environmentService = new TestEnvironmentService(parseArgs(process.argv, OPTIONS)); - const logService = new NullLogService(); - + let testDir: string; + let untitledWorkspacesHomePath: string; + let environmentService: EnvironmentMainService; let service: WorkspacesManagementMainService; setup(async () => { - service = new WorkspacesManagementMainService(environmentService, logService, new TestBackupMainService(), new TestDialogMainService()); + testDir = getRandomTestPath(os.tmpdir(), 'vsctests', 'workspacesmanagementmainservice'); + untitledWorkspacesHomePath = path.join(testDir, 'Workspaces'); - // Delete any existing backups completely and then re-create it. - await pfs.rimraf(parentDir); + environmentService = new class TestEnvironmentService extends EnvironmentMainService { + constructor() { + super(parseArgs(process.argv, OPTIONS)); + } + get untitledWorkspacesHome(): URI { + return URI.file(untitledWorkspacesHomePath); + } + }; + + service = new WorkspacesManagementMainService(environmentService, new NullLogService(), new TestBackupMainService(), new TestDialogMainService()); return pfs.mkdirp(untitledWorkspacesHomePath); }); teardown(() => { - return pfs.rimraf(parentDir); + return pfs.rimraf(testDir); }); function assertPathEquals(p1: string, p2: string): void { @@ -454,13 +455,13 @@ suite('WorkspacesManagementMainService', () => { const nonLocalUriId = getSingleFolderWorkspaceIdentifier(nonLocalUri); assert.ok(nonLocalUriId?.id); - const localNonExistingUri = URI.file(path.join(parentDir, 'f1')); + const localNonExistingUri = URI.file(path.join(testDir, 'f1')); const localNonExistingUriId = getSingleFolderWorkspaceIdentifier(localNonExistingUri); assert.ok(!localNonExistingUriId); - fs.mkdirSync(path.join(parentDir, 'f1')); + fs.mkdirSync(path.join(testDir, 'f1')); - const localExistingUri = URI.file(path.join(parentDir, 'f1')); + const localExistingUri = URI.file(path.join(testDir, 'f1')); const localExistingUriId = getSingleFolderWorkspaceIdentifier(localExistingUri); assert.ok(localExistingUriId?.id); }); diff --git a/src/vs/workbench/contrib/backup/test/electron-browser/backupTracker.test.ts b/src/vs/workbench/contrib/backup/test/electron-browser/backupTracker.test.ts index 1b0c10f4898..01050783472 100644 --- a/src/vs/workbench/contrib/backup/test/electron-browser/backupTracker.test.ts +++ b/src/vs/workbench/contrib/backup/test/electron-browser/backupTracker.test.ts @@ -89,6 +89,7 @@ class BeforeShutdownEventImpl implements BeforeShutdownEvent { } flakySuite('BackupTracker (native)', function () { + let testDir: string; let backupHome: string; let workspaceBackupPath: string; @@ -96,8 +97,8 @@ flakySuite('BackupTracker (native)', function () { let disposables: IDisposable[] = []; setup(async () => { - const userdataDir = getRandomTestPath(os.tmpdir(), 'vsctests', 'backuprestorer'); - backupHome = path.join(userdataDir, 'Backups'); + testDir = getRandomTestPath(os.tmpdir(), 'vsctests', 'backuprestorer'); + backupHome = path.join(testDir, 'Backups'); const workspacesJsonPath = path.join(backupHome, 'workspaces.json'); const workspaceResource = URI.file(platform.isWindows ? 'c:\\workspace' : '/workspace'); @@ -127,11 +128,11 @@ flakySuite('BackupTracker (native)', function () { (accessor.textFileService.files).dispose(); - return pfs.rimraf(backupHome); + return pfs.rimraf(testDir); }); async function createTracker(autoSaveEnabled = false): Promise<{ accessor: TestServiceAccessor, part: EditorPart, tracker: BackupTracker, instantiationService: IInstantiationService, cleanup: () => Promise }> { - const backupFileService = new NodeTestBackupFileService(workspaceBackupPath); + const backupFileService = new NodeTestBackupFileService(testDir, workspaceBackupPath); const instantiationService = workbenchInstantiationService(); instantiationService.stub(IBackupFileService, backupFileService); diff --git a/src/vs/workbench/services/backup/test/electron-browser/backupFileService.test.ts b/src/vs/workbench/services/backup/test/electron-browser/backupFileService.test.ts index b1f1734bc89..147c47c5d1c 100644 --- a/src/vs/workbench/services/backup/test/electron-browser/backupFileService.test.ts +++ b/src/vs/workbench/services/backup/test/electron-browser/backupFileService.test.ts @@ -31,26 +31,10 @@ import { TestProductService } from 'vs/workbench/test/browser/workbenchTestServi import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cancellation'; import { insert } from 'vs/base/common/arrays'; -const userdataDir = getRandomTestPath(os.tmpdir(), 'vsctests', 'backupfileservice'); -const backupHome = path.join(userdataDir, 'Backups'); -const workspacesJsonPath = path.join(backupHome, 'workspaces.json'); - -const workspaceResource = URI.file(platform.isWindows ? 'c:\\workspace' : '/workspace'); -const workspaceBackupPath = path.join(backupHome, hashPath(workspaceResource)); -const fooFile = URI.file(platform.isWindows ? 'c:\\Foo' : '/Foo'); -const customFile = URI.parse('customScheme://some/path'); -const customFileWithFragment = URI.parse('customScheme2://some/path#fragment'); -const barFile = URI.file(platform.isWindows ? 'c:\\Bar' : '/Bar'); -const fooBarFile = URI.file(platform.isWindows ? 'c:\\Foo Bar' : '/Foo Bar'); -const untitledFile = URI.from({ scheme: Schemas.untitled, path: 'Untitled-1' }); -const fooBackupPath = path.join(workspaceBackupPath, 'file', hashPath(fooFile)); -const barBackupPath = path.join(workspaceBackupPath, 'file', hashPath(barFile)); -const untitledBackupPath = path.join(workspaceBackupPath, 'untitled', hashPath(untitledFile)); - class TestWorkbenchEnvironmentService extends NativeWorkbenchEnvironmentService { - constructor(backupPath: string) { - super({ ...TestWorkbenchConfiguration, backupPath, 'user-data-dir': userdataDir }, TestProductService); + constructor(testDir: string, backupPath: string) { + super({ ...TestWorkbenchConfiguration, backupPath, 'user-data-dir': testDir }, TestProductService); } } @@ -63,8 +47,8 @@ export class NodeTestBackupFileService extends NativeBackupFileService { discardedBackups: URI[]; private pendingBackupsArr: Promise[]; - constructor(workspaceBackupPath: string) { - const environmentService = new TestWorkbenchEnvironmentService(workspaceBackupPath); + constructor(testDir: string, workspaceBackupPath: string) { + const environmentService = new TestWorkbenchEnvironmentService(testDir, workspaceBackupPath); const logService = new NullLogService(); const fileService = new FileService(logService); const diskFileSystemProvider = new DiskFileSystemProvider(logService); @@ -126,20 +110,43 @@ export class NodeTestBackupFileService extends NativeBackupFileService { } suite('BackupFileService', () => { + + let testDir: string; + let backupHome: string; + let workspacesJsonPath: string; + let workspaceBackupPath: string; + let fooBackupPath: string; + let barBackupPath: string; + let untitledBackupPath: string; + let service: NodeTestBackupFileService; - setup(async () => { - service = new NodeTestBackupFileService(workspaceBackupPath); + let workspaceResource = URI.file(platform.isWindows ? 'c:\\workspace' : '/workspace'); + let fooFile = URI.file(platform.isWindows ? 'c:\\Foo' : '/Foo'); + let customFile = URI.parse('customScheme://some/path'); + let customFileWithFragment = URI.parse('customScheme2://some/path#fragment'); + let barFile = URI.file(platform.isWindows ? 'c:\\Bar' : '/Bar'); + let fooBarFile = URI.file(platform.isWindows ? 'c:\\Foo Bar' : '/Foo Bar'); + let untitledFile = URI.from({ scheme: Schemas.untitled, path: 'Untitled-1' }); + + setup(async () => { + testDir = getRandomTestPath(os.tmpdir(), 'vsctests', 'backupfileservice'); + backupHome = path.join(testDir, 'Backups'); + workspacesJsonPath = path.join(backupHome, 'workspaces.json'); + workspaceBackupPath = path.join(backupHome, hashPath(workspaceResource)); + fooBackupPath = path.join(workspaceBackupPath, 'file', hashPath(fooFile)); + barBackupPath = path.join(workspaceBackupPath, 'file', hashPath(barFile)); + untitledBackupPath = path.join(workspaceBackupPath, 'untitled', hashPath(untitledFile)); + + service = new NodeTestBackupFileService(testDir, workspaceBackupPath); - // Delete any existing backups completely and then re-create it. - await pfs.rimraf(backupHome); await pfs.mkdirp(backupHome); return pfs.writeFile(workspacesJsonPath, ''); }); teardown(() => { - return pfs.rimraf(backupHome); + return pfs.rimraf(testDir); }); suite('hashPath', () => { @@ -150,8 +157,8 @@ suite('BackupFileService', () => { }); const actual = hashPath(uri); // If these hashes change people will lose their backed up files! - assert.equal(actual, '13264068d108c6901b3592ea654fcd57'); - assert.equal(actual, crypto.createHash('md5').update(uri.fsPath).digest('hex')); + assert.strictEqual(actual, '13264068d108c6901b3592ea654fcd57'); + assert.strictEqual(actual, crypto.createHash('md5').update(uri.fsPath).digest('hex')); }); test('should correctly hash the path for file scheme URIs', () => { @@ -159,11 +166,11 @@ suite('BackupFileService', () => { const actual = hashPath(uri); // If these hashes change people will lose their backed up files! if (platform.isWindows) { - assert.equal(actual, 'dec1a583f52468a020bd120c3f01d812'); + assert.strictEqual(actual, 'dec1a583f52468a020bd120c3f01d812'); } else { - assert.equal(actual, '1effb2475fcfba4f9e8b8a1dbc8f3caf'); + assert.strictEqual(actual, '1effb2475fcfba4f9e8b8a1dbc8f3caf'); } - assert.equal(actual, crypto.createHash('md5').update(uri.fsPath).digest('hex')); + assert.strictEqual(actual, crypto.createHash('md5').update(uri.fsPath).digest('hex')); }); }); @@ -174,7 +181,7 @@ suite('BackupFileService', () => { const workspaceHash = hashPath(workspaceResource); const filePathHash = hashPath(backupResource); const expectedPath = URI.file(path.join(backupHome, workspaceHash, Schemas.file, filePathHash)).with({ scheme: Schemas.userData }).toString(); - assert.equal(service.toBackupResource(backupResource).toString(), expectedPath); + assert.strictEqual(service.toBackupResource(backupResource).toString(), expectedPath); }); test('should get the correct backup path for untitled files', () => { @@ -183,49 +190,49 @@ suite('BackupFileService', () => { const workspaceHash = hashPath(workspaceResource); const filePathHash = hashPath(backupResource); const expectedPath = URI.file(path.join(backupHome, workspaceHash, Schemas.untitled, filePathHash)).with({ scheme: Schemas.userData }).toString(); - assert.equal(service.toBackupResource(backupResource).toString(), expectedPath); + assert.strictEqual(service.toBackupResource(backupResource).toString(), expectedPath); }); }); suite('backup', () => { test('no text', async () => { await service.backup(fooFile); - assert.equal(fs.readdirSync(path.join(workspaceBackupPath, 'file')).length, 1); - assert.equal(fs.existsSync(fooBackupPath), true); - assert.equal(fs.readFileSync(fooBackupPath), `${fooFile.toString()}\n`); + assert.strictEqual(fs.readdirSync(path.join(workspaceBackupPath, 'file')).length, 1); + assert.strictEqual(fs.existsSync(fooBackupPath), true); + assert.strictEqual(fs.readFileSync(fooBackupPath).toString(), `${fooFile.toString()}\n`); assert.ok(service.hasBackupSync(fooFile)); }); test('text file', async () => { await service.backup(fooFile, createTextBufferFactory('test').create(DefaultEndOfLine.LF).textBuffer.createSnapshot(false)); - assert.equal(fs.readdirSync(path.join(workspaceBackupPath, 'file')).length, 1); - assert.equal(fs.existsSync(fooBackupPath), true); - assert.equal(fs.readFileSync(fooBackupPath), `${fooFile.toString()}\ntest`); + assert.strictEqual(fs.readdirSync(path.join(workspaceBackupPath, 'file')).length, 1); + assert.strictEqual(fs.existsSync(fooBackupPath), true); + assert.strictEqual(fs.readFileSync(fooBackupPath).toString(), `${fooFile.toString()}\ntest`); assert.ok(service.hasBackupSync(fooFile)); }); test('text file (with version)', async () => { await service.backup(fooFile, createTextBufferFactory('test').create(DefaultEndOfLine.LF).textBuffer.createSnapshot(false), 666); - assert.equal(fs.readdirSync(path.join(workspaceBackupPath, 'file')).length, 1); - assert.equal(fs.existsSync(fooBackupPath), true); - assert.equal(fs.readFileSync(fooBackupPath), `${fooFile.toString()}\ntest`); + assert.strictEqual(fs.readdirSync(path.join(workspaceBackupPath, 'file')).length, 1); + assert.strictEqual(fs.existsSync(fooBackupPath), true); + assert.strictEqual(fs.readFileSync(fooBackupPath).toString(), `${fooFile.toString()}\ntest`); assert.ok(!service.hasBackupSync(fooFile, 555)); assert.ok(service.hasBackupSync(fooFile, 666)); }); test('text file (with meta)', async () => { await service.backup(fooFile, createTextBufferFactory('test').create(DefaultEndOfLine.LF).textBuffer.createSnapshot(false), undefined, { etag: '678', orphaned: true }); - assert.equal(fs.readdirSync(path.join(workspaceBackupPath, 'file')).length, 1); - assert.equal(fs.existsSync(fooBackupPath), true); - assert.equal(fs.readFileSync(fooBackupPath).toString(), `${fooFile.toString()} {"etag":"678","orphaned":true}\ntest`); + assert.strictEqual(fs.readdirSync(path.join(workspaceBackupPath, 'file')).length, 1); + assert.strictEqual(fs.existsSync(fooBackupPath), true); + assert.strictEqual(fs.readFileSync(fooBackupPath).toString(), `${fooFile.toString()} {"etag":"678","orphaned":true}\ntest`); assert.ok(service.hasBackupSync(fooFile)); }); test('untitled file', async () => { await service.backup(untitledFile, createTextBufferFactory('test').create(DefaultEndOfLine.LF).textBuffer.createSnapshot(false)); - assert.equal(fs.readdirSync(path.join(workspaceBackupPath, 'untitled')).length, 1); - assert.equal(fs.existsSync(untitledBackupPath), true); - assert.equal(fs.readFileSync(untitledBackupPath), `${untitledFile.toString()}\ntest`); + assert.strictEqual(fs.readdirSync(path.join(workspaceBackupPath, 'untitled')).length, 1); + assert.strictEqual(fs.existsSync(untitledBackupPath), true); + assert.strictEqual(fs.readFileSync(untitledBackupPath).toString(), `${untitledFile.toString()}\ntest`); assert.ok(service.hasBackupSync(untitledFile)); }); @@ -233,9 +240,9 @@ suite('BackupFileService', () => { const model = createTextModel('test'); await service.backup(fooFile, model.createSnapshot()); - assert.equal(fs.readdirSync(path.join(workspaceBackupPath, 'file')).length, 1); - assert.equal(fs.existsSync(fooBackupPath), true); - assert.equal(fs.readFileSync(fooBackupPath), `${fooFile.toString()}\ntest`); + assert.strictEqual(fs.readdirSync(path.join(workspaceBackupPath, 'file')).length, 1); + assert.strictEqual(fs.existsSync(fooBackupPath), true); + assert.strictEqual(fs.readFileSync(fooBackupPath).toString(), `${fooFile.toString()}\ntest`); assert.ok(service.hasBackupSync(fooFile)); model.dispose(); @@ -245,9 +252,9 @@ suite('BackupFileService', () => { const model = createTextModel('test'); await service.backup(untitledFile, model.createSnapshot()); - assert.equal(fs.readdirSync(path.join(workspaceBackupPath, 'untitled')).length, 1); - assert.equal(fs.existsSync(untitledBackupPath), true); - assert.equal(fs.readFileSync(untitledBackupPath), `${untitledFile.toString()}\ntest`); + assert.strictEqual(fs.readdirSync(path.join(workspaceBackupPath, 'untitled')).length, 1); + assert.strictEqual(fs.existsSync(untitledBackupPath), true); + assert.strictEqual(fs.readFileSync(untitledBackupPath).toString(), `${untitledFile.toString()}\ntest`); model.dispose(); }); @@ -257,9 +264,9 @@ suite('BackupFileService', () => { const model = createTextModel(largeString); await service.backup(fooFile, model.createSnapshot()); - assert.equal(fs.readdirSync(path.join(workspaceBackupPath, 'file')).length, 1); - assert.equal(fs.existsSync(fooBackupPath), true); - assert.equal(fs.readFileSync(fooBackupPath), `${fooFile.toString()}\n${largeString}`); + assert.strictEqual(fs.readdirSync(path.join(workspaceBackupPath, 'file')).length, 1); + assert.strictEqual(fs.existsSync(fooBackupPath), true); + assert.strictEqual(fs.readFileSync(fooBackupPath).toString(), `${fooFile.toString()}\n${largeString}`); assert.ok(service.hasBackupSync(fooFile)); model.dispose(); @@ -270,9 +277,9 @@ suite('BackupFileService', () => { const model = createTextModel(largeString); await service.backup(untitledFile, model.createSnapshot()); - assert.equal(fs.readdirSync(path.join(workspaceBackupPath, 'untitled')).length, 1); - assert.equal(fs.existsSync(untitledBackupPath), true); - assert.equal(fs.readFileSync(untitledBackupPath), `${untitledFile.toString()}\n${largeString}`); + assert.strictEqual(fs.readdirSync(path.join(workspaceBackupPath, 'untitled')).length, 1); + assert.strictEqual(fs.existsSync(untitledBackupPath), true); + assert.strictEqual(fs.readFileSync(untitledBackupPath).toString(), `${untitledFile.toString()}\n${largeString}`); assert.ok(service.hasBackupSync(untitledFile)); model.dispose(); @@ -284,7 +291,7 @@ suite('BackupFileService', () => { cts.cancel(); await promise; - assert.equal(fs.existsSync(fooBackupPath), false); + assert.strictEqual(fs.existsSync(fooBackupPath), false); assert.ok(!service.hasBackupSync(fooFile)); }); }); @@ -292,48 +299,48 @@ suite('BackupFileService', () => { suite('discardBackup', () => { test('text file', async () => { await service.backup(fooFile, createTextBufferFactory('test').create(DefaultEndOfLine.LF).textBuffer.createSnapshot(false)); - assert.equal(fs.readdirSync(path.join(workspaceBackupPath, 'file')).length, 1); + assert.strictEqual(fs.readdirSync(path.join(workspaceBackupPath, 'file')).length, 1); assert.ok(service.hasBackupSync(fooFile)); await service.discardBackup(fooFile); - assert.equal(fs.existsSync(fooBackupPath), false); - assert.equal(fs.readdirSync(path.join(workspaceBackupPath, 'file')).length, 0); + assert.strictEqual(fs.existsSync(fooBackupPath), false); + assert.strictEqual(fs.readdirSync(path.join(workspaceBackupPath, 'file')).length, 0); assert.ok(!service.hasBackupSync(fooFile)); }); test('untitled file', async () => { await service.backup(untitledFile, createTextBufferFactory('test').create(DefaultEndOfLine.LF).textBuffer.createSnapshot(false)); - assert.equal(fs.readdirSync(path.join(workspaceBackupPath, 'untitled')).length, 1); + assert.strictEqual(fs.readdirSync(path.join(workspaceBackupPath, 'untitled')).length, 1); await service.discardBackup(untitledFile); - assert.equal(fs.existsSync(untitledBackupPath), false); - assert.equal(fs.readdirSync(path.join(workspaceBackupPath, 'untitled')).length, 0); + assert.strictEqual(fs.existsSync(untitledBackupPath), false); + assert.strictEqual(fs.readdirSync(path.join(workspaceBackupPath, 'untitled')).length, 0); }); }); suite('discardBackups', () => { test('text file', async () => { await service.backup(fooFile, createTextBufferFactory('test').create(DefaultEndOfLine.LF).textBuffer.createSnapshot(false)); - assert.equal(fs.readdirSync(path.join(workspaceBackupPath, 'file')).length, 1); + assert.strictEqual(fs.readdirSync(path.join(workspaceBackupPath, 'file')).length, 1); await service.backup(barFile, createTextBufferFactory('test').create(DefaultEndOfLine.LF).textBuffer.createSnapshot(false)); - assert.equal(fs.readdirSync(path.join(workspaceBackupPath, 'file')).length, 2); + assert.strictEqual(fs.readdirSync(path.join(workspaceBackupPath, 'file')).length, 2); await service.discardBackups(); - assert.equal(fs.existsSync(fooBackupPath), false); - assert.equal(fs.existsSync(barBackupPath), false); - assert.equal(fs.existsSync(path.join(workspaceBackupPath, 'file')), false); + assert.strictEqual(fs.existsSync(fooBackupPath), false); + assert.strictEqual(fs.existsSync(barBackupPath), false); + assert.strictEqual(fs.existsSync(path.join(workspaceBackupPath, 'file')), false); }); test('untitled file', async () => { await service.backup(untitledFile, createTextBufferFactory('test').create(DefaultEndOfLine.LF).textBuffer.createSnapshot(false)); - assert.equal(fs.readdirSync(path.join(workspaceBackupPath, 'untitled')).length, 1); + assert.strictEqual(fs.readdirSync(path.join(workspaceBackupPath, 'untitled')).length, 1); await service.discardBackups(); - assert.equal(fs.existsSync(untitledBackupPath), false); - assert.equal(fs.existsSync(path.join(workspaceBackupPath, 'untitled')), false); + assert.strictEqual(fs.existsSync(untitledBackupPath), false); + assert.strictEqual(fs.existsSync(path.join(workspaceBackupPath, 'untitled')), false); }); test('can backup after discarding all', async () => { await service.discardBackups(); await service.backup(untitledFile, createTextBufferFactory('test').create(DefaultEndOfLine.LF).textBuffer.createSnapshot(false)); - assert.equal(fs.existsSync(workspaceBackupPath), true); + assert.strictEqual(fs.existsSync(workspaceBackupPath), true); }); }); @@ -341,22 +348,22 @@ suite('BackupFileService', () => { test('("file") - text file', async () => { await service.backup(fooFile, createTextBufferFactory('test').create(DefaultEndOfLine.LF).textBuffer.createSnapshot(false)); const textFiles = await service.getBackups(); - assert.deepEqual(textFiles.map(f => f.fsPath), [fooFile.fsPath]); + assert.deepStrictEqual(textFiles.map(f => f.fsPath), [fooFile.fsPath]); await service.backup(barFile, createTextBufferFactory('test').create(DefaultEndOfLine.LF).textBuffer.createSnapshot(false)); const textFiles_1 = await service.getBackups(); - assert.deepEqual(textFiles_1.map(f => f.fsPath), [fooFile.fsPath, barFile.fsPath]); + assert.deepStrictEqual(textFiles_1.map(f => f.fsPath), [fooFile.fsPath, barFile.fsPath]); }); test('("file") - untitled file', async () => { await service.backup(untitledFile, createTextBufferFactory('test').create(DefaultEndOfLine.LF).textBuffer.createSnapshot(false)); const textFiles = await service.getBackups(); - assert.deepEqual(textFiles.map(f => f.fsPath), [untitledFile.fsPath]); + assert.deepStrictEqual(textFiles.map(f => f.fsPath), [untitledFile.fsPath]); }); test('("untitled") - untitled file', async () => { await service.backup(untitledFile, createTextBufferFactory('test').create(DefaultEndOfLine.LF).textBuffer.createSnapshot(false)); const textFiles = await service.getBackups(); - assert.deepEqual(textFiles.map(f => f.fsPath), ['Untitled-1']); + assert.deepStrictEqual(textFiles.map(f => f.fsPath), ['Untitled-1']); }); }); @@ -468,7 +475,7 @@ suite('BackupFileService', () => { await service.backup(fooFile, createTextBufferFactory(contents).create(DefaultEndOfLine.LF).textBuffer.createSnapshot(false), 1, meta); const fileContents = fs.readFileSync(fooBackupPath).toString(); - assert.equal(fileContents.indexOf(fooFile.toString()), 0); + assert.strictEqual(fileContents.indexOf(fooFile.toString()), 0); const metaIndex = fileContents.indexOf('{'); const newFileContents = fileContents.substring(0, metaIndex) + '{{' + fileContents.substr(metaIndex); @@ -476,7 +483,7 @@ suite('BackupFileService', () => { const backup = await service.resolve(fooFile); assert.ok(backup); - assert.equal(contents, snapshotToString(backup!.value.create(platform.isWindows ? DefaultEndOfLine.CRLF : DefaultEndOfLine.LF).textBuffer.createSnapshot(true))); + assert.strictEqual(contents, snapshotToString(backup!.value.create(platform.isWindows ? DefaultEndOfLine.CRLF : DefaultEndOfLine.LF).textBuffer.createSnapshot(true))); assert.ok(!backup!.meta); }); @@ -565,111 +572,96 @@ suite('BackupFileService', () => { const backup = await service.resolve(resource); assert.ok(backup); - assert.equal(contents, snapshotToString(backup!.value.create(platform.isWindows ? DefaultEndOfLine.CRLF : DefaultEndOfLine.LF).textBuffer.createSnapshot(true))); + assert.strictEqual(contents, snapshotToString(backup!.value.create(platform.isWindows ? DefaultEndOfLine.CRLF : DefaultEndOfLine.LF).textBuffer.createSnapshot(true))); if (expectedMeta) { - assert.equal(backup!.meta!.etag, expectedMeta.etag); - assert.equal(backup!.meta!.size, expectedMeta.size); - assert.equal(backup!.meta!.mtime, expectedMeta.mtime); - assert.equal(backup!.meta!.orphaned, expectedMeta.orphaned); + assert.strictEqual(backup!.meta!.etag, expectedMeta.etag); + assert.strictEqual(backup!.meta!.size, expectedMeta.size); + assert.strictEqual(backup!.meta!.mtime, expectedMeta.mtime); + assert.strictEqual(backup!.meta!.orphaned, expectedMeta.orphaned); } else { assert.ok(!backup!.meta); } } }); -}); - -suite('BackupFilesModel', () => { - - let service: NodeTestBackupFileService; - - setup(async () => { - service = new NodeTestBackupFileService(workspaceBackupPath); - - // Delete any existing backups completely and then re-create it. - await pfs.rimraf(backupHome); - await pfs.mkdirp(backupHome); - - return pfs.writeFile(workspacesJsonPath, ''); - }); - - teardown(() => { - return pfs.rimraf(backupHome); - }); - - test('simple', () => { - const model = new BackupFilesModel(service.fileService); - - const resource1 = URI.file('test.html'); - - assert.equal(model.has(resource1), false); - - model.add(resource1); - - assert.equal(model.has(resource1), true); - assert.equal(model.has(resource1, 0), true); - assert.equal(model.has(resource1, 1), false); - assert.equal(model.has(resource1, 1, { foo: 'bar' }), false); - - model.remove(resource1); - - assert.equal(model.has(resource1), false); - - model.add(resource1); - - assert.equal(model.has(resource1), true); - assert.equal(model.has(resource1, 0), true); - assert.equal(model.has(resource1, 1), false); - - model.clear(); - - assert.equal(model.has(resource1), false); - - model.add(resource1, 1); - - assert.equal(model.has(resource1), true); - assert.equal(model.has(resource1, 0), false); - assert.equal(model.has(resource1, 1), true); - - const resource2 = URI.file('test1.html'); - const resource3 = URI.file('test2.html'); - const resource4 = URI.file('test3.html'); - - model.add(resource2); - model.add(resource3); - model.add(resource4, undefined, { foo: 'bar' }); - - assert.equal(model.has(resource1), true); - assert.equal(model.has(resource2), true); - assert.equal(model.has(resource3), true); - - assert.equal(model.has(resource4), true); - assert.equal(model.has(resource4, undefined, { foo: 'bar' }), true); - assert.equal(model.has(resource4, undefined, { bar: 'foo' }), false); - }); - - test('resolve', async () => { - await pfs.mkdirp(path.dirname(fooBackupPath)); - fs.writeFileSync(fooBackupPath, 'foo'); - const model = new BackupFilesModel(service.fileService); - - const resolvedModel = await model.resolve(URI.file(workspaceBackupPath)); - assert.equal(resolvedModel.has(URI.file(fooBackupPath)), true); - }); - - test('get', () => { - const model = new BackupFilesModel(service.fileService); - - assert.deepEqual(model.get(), []); - - const file1 = URI.file('/root/file/foo.html'); - const file2 = URI.file('/root/file/bar.html'); - const untitled = URI.file('/root/untitled/bar.html'); - - model.add(file1); - model.add(file2); - model.add(untitled); - - assert.deepEqual(model.get().map(f => f.fsPath), [file1.fsPath, file2.fsPath, untitled.fsPath]); - }); + + suite('BackupFilesModel', () => { + + test('simple', () => { + const model = new BackupFilesModel(service.fileService); + + const resource1 = URI.file('test.html'); + + assert.strictEqual(model.has(resource1), false); + + model.add(resource1); + + assert.strictEqual(model.has(resource1), true); + assert.strictEqual(model.has(resource1, 0), true); + assert.strictEqual(model.has(resource1, 1), false); + assert.strictEqual(model.has(resource1, 1, { foo: 'bar' }), false); + + model.remove(resource1); + + assert.strictEqual(model.has(resource1), false); + + model.add(resource1); + + assert.strictEqual(model.has(resource1), true); + assert.strictEqual(model.has(resource1, 0), true); + assert.strictEqual(model.has(resource1, 1), false); + + model.clear(); + + assert.strictEqual(model.has(resource1), false); + + model.add(resource1, 1); + + assert.strictEqual(model.has(resource1), true); + assert.strictEqual(model.has(resource1, 0), false); + assert.strictEqual(model.has(resource1, 1), true); + + const resource2 = URI.file('test1.html'); + const resource3 = URI.file('test2.html'); + const resource4 = URI.file('test3.html'); + + model.add(resource2); + model.add(resource3); + model.add(resource4, undefined, { foo: 'bar' }); + + assert.strictEqual(model.has(resource1), true); + assert.strictEqual(model.has(resource2), true); + assert.strictEqual(model.has(resource3), true); + + assert.strictEqual(model.has(resource4), true); + assert.strictEqual(model.has(resource4, undefined, { foo: 'bar' }), true); + assert.strictEqual(model.has(resource4, undefined, { bar: 'foo' }), false); + }); + + test('resolve', async () => { + await pfs.mkdirp(path.dirname(fooBackupPath)); + fs.writeFileSync(fooBackupPath, 'foo'); + const model = new BackupFilesModel(service.fileService); + + const resolvedModel = await model.resolve(URI.file(workspaceBackupPath)); + assert.strictEqual(resolvedModel.has(URI.file(fooBackupPath)), true); + }); + + test('get', () => { + const model = new BackupFilesModel(service.fileService); + + assert.deepStrictEqual(model.get(), []); + + const file1 = URI.file('/root/file/foo.html'); + const file2 = URI.file('/root/file/bar.html'); + const untitled = URI.file('/root/untitled/bar.html'); + + model.add(file1); + model.add(file2); + model.add(untitled); + + assert.deepStrictEqual(model.get().map(f => f.fsPath), [file1.fsPath, file2.fsPath, untitled.fsPath]); + }); + }); + }); diff --git a/src/vs/workbench/services/label/test/electron-browser/label.test.ts b/src/vs/workbench/services/label/test/electron-browser/label.test.ts index bb467cb48f1..24c474bddda 100644 --- a/src/vs/workbench/services/label/test/electron-browser/label.test.ts +++ b/src/vs/workbench/services/label/test/electron-browser/label.test.ts @@ -32,12 +32,12 @@ suite('URI Label', () => { }); const uri1 = TestWorkspace.folders[0].uri.with({ path: TestWorkspace.folders[0].uri.path.concat('/a/b/c/d') }); - assert.equal(labelService.getUriLabel(uri1, { relative: true }), isWindows ? 'a\\b\\c\\d' : 'a/b/c/d'); - assert.equal(labelService.getUriLabel(uri1, { relative: false }), isWindows ? 'C:\\testWorkspace\\a\\b\\c\\d' : '/testWorkspace/a/b/c/d'); - assert.equal(labelService.getUriBasenameLabel(uri1), 'd'); + assert.strictEqual(labelService.getUriLabel(uri1, { relative: true }), isWindows ? 'a\\b\\c\\d' : 'a/b/c/d'); + assert.strictEqual(labelService.getUriLabel(uri1, { relative: false }), isWindows ? 'C:\\testWorkspace\\a\\b\\c\\d' : '/testWorkspace/a/b/c/d'); + assert.strictEqual(labelService.getUriBasenameLabel(uri1), 'd'); const uri2 = URI.file('c:\\1/2/3'); - assert.equal(labelService.getUriLabel(uri2, { relative: false }), isWindows ? 'C:\\1\\2\\3' : '/c:\\1/2/3'); - assert.equal(labelService.getUriBasenameLabel(uri2), '3'); + assert.strictEqual(labelService.getUriLabel(uri2, { relative: false }), isWindows ? 'C:\\1\\2\\3' : '/c:\\1/2/3'); + assert.strictEqual(labelService.getUriBasenameLabel(uri2), '3'); }); });