From 74cbbe4aff8af92a0376b07d7b4668256f724928 Mon Sep 17 00:00:00 2001 From: Richard Willis Date: Mon, 18 May 2020 20:43:42 +0100 Subject: [PATCH] Don't update vscode during tests Needs to be a short dir name, see microsoft/vscode#86382 --- extension/package-lock.json | 43 +++++++++++++++++++ extension/package.json | 2 + extension/src/test/runTests.ts | 40 +++++++++++++---- .../.vscode/settings.json | 3 -- .../.vscode/settings.json | 3 -- .../multi-project/.vscode/settings.json | 3 -- .../User}/settings.json | 0 7 files changed, 77 insertions(+), 17 deletions(-) delete mode 100644 extension/test-fixtures/gradle-groovy-default-build-file/.vscode/settings.json delete mode 100644 extension/test-fixtures/gradle-kotlin-default-build-file/.vscode/settings.json delete mode 100644 extension/test-fixtures/multi-project/.vscode/settings.json rename extension/test-fixtures/{gradle-groovy-custom-build-file/.vscode => vscode-user/User}/settings.json (100%) diff --git a/extension/package-lock.json b/extension/package-lock.json index 9ca938208..1cfeb3e8e 100644 --- a/extension/package-lock.json +++ b/extension/package-lock.json @@ -471,6 +471,15 @@ "integrity": "sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g==", "dev": true }, + "@types/fs-extra": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-9.0.0.tgz", + "integrity": "sha512-xCbDUSZArlmMjiJdczt8AFNH2MwcMb/pj/HKja1hx3u1qzOUINcJktQMGoGVlgFnzxnuCahxKFlcRBkSAcm33g==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, "@types/glob": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.1.1.tgz", @@ -1102,6 +1111,12 @@ "dev": true, "optional": true }, + "at-least-node": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz", + "integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==", + "dev": true + }, "atob": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", @@ -3151,6 +3166,18 @@ "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==", "dev": true }, + "fs-extra": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.0.0.tgz", + "integrity": "sha512-pmEYSk3vYsG/bF651KPUXZ+hvjpgWYw/Gc7W9NFUe3ZVLczKKWIij3IKpOrQcdw4TILtibFslZ0UmR8Vvzig4g==", + "dev": true, + "requires": { + "at-least-node": "^1.0.0", + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^1.0.0" + } + }, "fs-write-stream-atomic": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/fs-write-stream-atomic/-/fs-write-stream-atomic-1.0.10.tgz", @@ -4648,6 +4675,16 @@ "minimist": "^1.2.0" } }, + "jsonfile": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.0.1.tgz", + "integrity": "sha512-jR2b5v7d2vIOust+w3wtFKZIfpC2pnRmFAhAC/BuweZFQR8qZzxH1OyrQ10HmdVYiXWkYUqPVsz91cG7EL2FBg==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.6", + "universalify": "^1.0.0" + } + }, "jszip": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/jszip/-/jszip-3.4.0.tgz", @@ -8001,6 +8038,12 @@ "crypto-random-string": "^1.0.0" } }, + "universalify": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-1.0.0.tgz", + "integrity": "sha512-rb6X1W158d7pRQBg5gkR8uPaSfiids68LTJQYOtEUhoJUWBdaQHsuT/EUduxXYxcrt4r5PJ4fuHW1MHT6p0qug==", + "dev": true + }, "unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", diff --git a/extension/package.json b/extension/package.json index 0d56e0867..73e9c81aa 100644 --- a/extension/package.json +++ b/extension/package.json @@ -531,6 +531,7 @@ "dependencies": {}, "devDependencies": { "@grpc/grpc-js": "^1.0.2", + "@types/fs-extra": "^9.0.0", "@types/glob": "^7.1.1", "@types/google-protobuf": "^3.7.2", "@types/mocha": "^7.0.2", @@ -544,6 +545,7 @@ "eslint-plugin-prettier": "^3.1.3", "eslint-plugin-sonarjs": "^0.5.0", "fast-glob": "^3.2.2", + "fs-extra": "^9.0.0", "get-port": "^5.1.1", "google-protobuf": "^3.11.4", "grpc-tools": "^1.8.1", diff --git a/extension/src/test/runTests.ts b/extension/src/test/runTests.ts index 32788c0ad..f3a487c34 100644 --- a/extension/src/test/runTests.ts +++ b/extension/src/test/runTests.ts @@ -1,12 +1,17 @@ /* eslint-disable sonarjs/no-duplicate-string */ import * as path from 'path'; +import * as os from 'os'; +import * as fs from 'fs-extra'; import { runTests, downloadAndUnzipVSCode } from 'vscode-test'; const extensionDevelopmentPath = path.resolve(__dirname, '../../'); const VSCODE_VERSION = '1.45.0'; -async function runTestsWithGradle(vscodeExecutablePath: string): Promise { +async function runTestsWithGradle( + vscodeExecutablePath: string, + userDir: string +): Promise { const fixtures = [ 'gradle-groovy-default-build-file', 'gradle-kotlin-default-build-file', @@ -20,6 +25,7 @@ async function runTestsWithGradle(vscodeExecutablePath: string): Promise { launchArgs: [ path.resolve(__dirname, `../../test-fixtures/${fixture}`), '--disable-extensions', + `--user-data-dir=${userDir}`, ], extensionTestsEnv: { FIXTURE_NAME: fixture, @@ -29,7 +35,10 @@ async function runTestsWithGradle(vscodeExecutablePath: string): Promise { } } -function runTestsWithoutGradle(vscodeExecutablePath: string): Promise { +function runTestsWithoutGradle( + vscodeExecutablePath: string, + userDir: string +): Promise { return runTests({ vscodeExecutablePath, extensionDevelopmentPath, @@ -37,6 +46,7 @@ function runTestsWithoutGradle(vscodeExecutablePath: string): Promise { launchArgs: [ path.resolve(__dirname, '../../test-fixtures/no-gradle'), '--disable-extensions', + `--user-data-dir=${userDir}`, ], extensionTestsEnv: { VSCODE_TEST: 'true', @@ -44,7 +54,10 @@ function runTestsWithoutGradle(vscodeExecutablePath: string): Promise { }); } -function runTestsWithMultiRoot(vscodeExecutablePath: string): Promise { +function runTestsWithMultiRoot( + vscodeExecutablePath: string, + userDir: string +): Promise { return runTests({ vscodeExecutablePath, extensionDevelopmentPath, @@ -55,6 +68,7 @@ function runTestsWithMultiRoot(vscodeExecutablePath: string): Promise { '../../test-fixtures/multi-root/multiple-project.code-workspace' ), '--disable-extensions', + `--user-data-dir=${userDir}`, ], extensionTestsEnv: { FIXTURE_NAME: 'multi-root', @@ -64,7 +78,8 @@ function runTestsWithMultiRoot(vscodeExecutablePath: string): Promise { } async function runTestsWithMultiProject( - vscodeExecutablePath: string + vscodeExecutablePath: string, + userDir: string ): Promise { return runTests({ vscodeExecutablePath, @@ -73,6 +88,7 @@ async function runTestsWithMultiProject( launchArgs: [ path.resolve(__dirname, '../../test-fixtures/multi-project/'), '--disable-extensions', + `--user-data-dir=${userDir}`, ], extensionTestsEnv: { FIXTURE_NAME: 'multi-project', @@ -82,14 +98,22 @@ async function runTestsWithMultiProject( } async function main(): Promise { + const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'vscode-user')); + fs.copySync( + path.resolve(__dirname, '../../test-fixtures/vscode-user/User'), + path.join(tmpDir, 'User') + ); const vscodeExecutablePath = await downloadAndUnzipVSCode(VSCODE_VERSION); - runTestsWithGradle(vscodeExecutablePath) - .then(() => runTestsWithMultiRoot(vscodeExecutablePath)) - .then(() => runTestsWithMultiProject(vscodeExecutablePath)) - .then(() => runTestsWithoutGradle(vscodeExecutablePath)) + runTestsWithGradle(vscodeExecutablePath, tmpDir) + .then(() => runTestsWithMultiRoot(vscodeExecutablePath, tmpDir)) + .then(() => runTestsWithMultiProject(vscodeExecutablePath, tmpDir)) + .then(() => runTestsWithoutGradle(vscodeExecutablePath, tmpDir)) .catch((err) => { console.error('Error running tests:', err.message); + }) + .finally(() => { + fs.remove(tmpDir); }); } diff --git a/extension/test-fixtures/gradle-groovy-default-build-file/.vscode/settings.json b/extension/test-fixtures/gradle-groovy-default-build-file/.vscode/settings.json deleted file mode 100644 index 756721312..000000000 --- a/extension/test-fixtures/gradle-groovy-default-build-file/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "update.mode": "none" -} diff --git a/extension/test-fixtures/gradle-kotlin-default-build-file/.vscode/settings.json b/extension/test-fixtures/gradle-kotlin-default-build-file/.vscode/settings.json deleted file mode 100644 index 756721312..000000000 --- a/extension/test-fixtures/gradle-kotlin-default-build-file/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "update.mode": "none" -} diff --git a/extension/test-fixtures/multi-project/.vscode/settings.json b/extension/test-fixtures/multi-project/.vscode/settings.json deleted file mode 100644 index 756721312..000000000 --- a/extension/test-fixtures/multi-project/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "update.mode": "none" -} diff --git a/extension/test-fixtures/gradle-groovy-custom-build-file/.vscode/settings.json b/extension/test-fixtures/vscode-user/User/settings.json similarity index 100% rename from extension/test-fixtures/gradle-groovy-custom-build-file/.vscode/settings.json rename to extension/test-fixtures/vscode-user/User/settings.json