diff --git a/.vscode/launch.json b/.vscode/launch.json index 81146c7b3..fd30fb9c5 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -48,7 +48,8 @@ "runtimeExecutable": "${execPath}", "env": { "FIXTURE_NAME": "gradle-groovy-default-build-file", - "VSCODE_TEST": "true" + "VSCODE_TEST": "true", + "SUITE_NAME": "Run tests with Gradle" }, "args": [ "--disable-extensions", @@ -72,7 +73,8 @@ "runtimeExecutable": "${execPath}", "env": { "FIXTURE_NAME": "gradle-kotlin-default-build-file", - "VSCODE_TEST": "true" + "VSCODE_TEST": "true", + "SUITE_NAME": "Run tests with Gradle" }, "args": [ "--disable-extensions", @@ -96,7 +98,8 @@ "runtimeExecutable": "${execPath}", "env": { "FIXTURE_NAME": "gradle-groovy-custom-build-file", - "VSCODE_TEST": "true" + "VSCODE_TEST": "true", + "SUITE_NAME": "Run tests with Gradle" }, "args": [ "--disable-extensions", @@ -119,7 +122,8 @@ "request": "launch", "runtimeExecutable": "${execPath}", "env": { - "VSCODE_TEST": "true" + "VSCODE_TEST": "true", + "SUITE_NAME": "Run tests without Gradle" }, "args": [ "--disable-extensions", @@ -143,7 +147,8 @@ "runtimeExecutable": "${execPath}", "env": { "FIXTURE_NAME": "multi-root-workspace", - "VSCODE_TEST": "true" + "VSCODE_TEST": "true", + "SUITE_NAME": "Run tests with multi-root vscode project" }, "args": [ "--disable-extensions", @@ -166,7 +171,8 @@ "request": "launch", "runtimeExecutable": "${execPath}", "env": { - "VSCODE_TEST": "true" + "VSCODE_TEST": "true", + "SUITE_NAME": "Run tests with Gradle multi-project" }, "args": [ "--disable-extensions", @@ -182,7 +188,33 @@ "presentation": { "group": "test" } - } + }, + { + "name": "Test: Network", + "type": "extensionHost", + "request": "launch", + "runtimeExecutable": "${execPath}", + "env": { + "FIXTURE_NAME": "gradle-groovy-default-build-file", + "VSCODE_TEST": "true", + "http_proxy": "http://0.0.0.0", + "SUITE_NAME": "Run network tests with Gradle" + }, + "args": [ + "--disable-extensions", + "--extensionDevelopmentPath=${workspaceFolder}/extension", + "--extensionTestsPath=${workspaceFolder}/extension/out/test/gradle", + "${workspaceFolder}/extension/test-fixtures/gradle-groovy-default-build-file" + ], + "outFiles": [ + "${workspaceFolder}/extension/dist/**/*.js", + "${workspaceFolder}/extension/out/test/**/*.js" + ], + "preLaunchTask": "Gradle: Build", + "presentation": { + "group": "test" + } + }, ], "compounds": [ { diff --git a/extension/package-lock.json b/extension/package-lock.json index a18c4d60d..3617097fd 100644 --- a/extension/package-lock.json +++ b/extension/package-lock.json @@ -31,12 +31,11 @@ } }, "@grpc/grpc-js": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.0.4.tgz", - "integrity": "sha512-Qawt6HUrEmljQMPWnLnIXpcjelmtIAydi3M9awiG02WWJ1CmIvFEx4IOC1EsWUWUlabOGksRbpfvoIeZKFTNXw==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.0.5.tgz", + "integrity": "sha512-Hm+xOiqAhcpT9RYM8lc15dbQD7aQurM7ZU8ulmulepiPlN7iwBXXwP3vSBUimoFoApRqz7pSIisXU8pZaCB4og==", "dev": true, "requires": { - "google-auth-library": "^6.0.0", "semver": "^6.2.0" } }, @@ -3487,9 +3486,9 @@ } }, "google-auth-library": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-6.0.0.tgz", - "integrity": "sha512-uLydy1t6SHN/EvYUJrtN3GCHFrnJ0c8HJjOxXiGjoTuYHIoCUT3jVxnzmjHwVnSdkfE9Akasm2rM6qG1COTXfQ==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-6.0.1.tgz", + "integrity": "sha512-NWEM9W0o+fmUJMK/wEuJ1vAc8H/JAseOWB8tjOAAkz8yobU+5IDtO/rPCbbRwFF1obIOCe0lj1pkq9ld2OFZeg==", "dev": true, "requires": { "arrify": "^2.0.0", @@ -3497,7 +3496,7 @@ "ecdsa-sig-formatter": "^1.0.11", "fast-text-encoding": "^1.0.0", "gaxios": "^3.0.0", - "gcp-metadata": "^4.0.0", + "gcp-metadata": "^4.1.0", "gtoken": "^5.0.0", "jws": "^4.0.0", "lru-cache": "^5.0.0" @@ -4694,9 +4693,9 @@ } }, "mime": { - "version": "2.4.5", - "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.5.tgz", - "integrity": "sha512-3hQhEUF027BuxZjQA3s7rIv/7VCQPa27hN9u9g87sEkWaKwQPuXOkVKtOeiyUrnWqTDiOs8Ed2rwg733mB0R5w==", + "version": "2.4.6", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.6.tgz", + "integrity": "sha512-RZKhC3EmpBchfTGBVb8fb+RL2cWyw/32lshnsETttkBAyAUXSGHxbEJWWRXc751DrIxG1q04b8QwMbAwkRPpUA==", "dev": true }, "mimic-fn": { diff --git a/extension/package.json b/extension/package.json index 9070ae1fd..97b554d64 100644 --- a/extension/package.json +++ b/extension/package.json @@ -475,7 +475,7 @@ }, "dependencies": {}, "devDependencies": { - "@grpc/grpc-js": "^1.0.4", + "@grpc/grpc-js": "^1.0.5", "@types/fs-extra": "^9.0.0", "@types/glob": "^7.1.1", "@types/google-protobuf": "^3.7.2", @@ -492,6 +492,7 @@ "fast-glob": "^3.2.2", "fs-extra": "^9.0.0", "get-port": "^5.1.1", + "google-auth-library": "^6.0.1", "google-protobuf": "^3.11.4", "grpc-tools": "^1.9.0", "mocha": "^7.1.2", diff --git a/extension/src/client.ts b/extension/src/client.ts index 250e573de..68c06b8e6 100644 --- a/extension/src/client.ts +++ b/extension/src/client.ts @@ -89,7 +89,8 @@ export class GradleTasksClient implements vscode.Disposable { try { this.grpcClient = new GrpcClient( `localhost:${this.server.getPort()}`, - grpc.credentials.createInsecure() + grpc.credentials.createInsecure(), + { 'grpc.enable_http_proxy': 0 } ); const deadline = new Date(); deadline.setSeconds(deadline.getSeconds() + this.connectDeadline); diff --git a/extension/src/server.ts b/extension/src/server.ts index 7206dc36c..f86fa111c 100644 --- a/extension/src/server.ts +++ b/extension/src/server.ts @@ -3,19 +3,10 @@ import * as getPort from 'get-port'; import { logger } from './logger'; import { buildGradleServerTask } from './tasks'; -import { isDebuggingServer, waitOnTcp } from './util'; +import { isDebuggingServer } from './util'; export const SERVER_TASK_NAME = 'Gradle Tasks Server'; -function isProcessRunning(pid: number): boolean { - try { - process.kill(pid, 0); - return true; - } catch (error) { - return error.code === 'EPERM'; - } -} - export interface ServerOptions { host: string; } @@ -38,19 +29,7 @@ export class GradleTasksServer implements vscode.Disposable { context.subscriptions.push( vscode.tasks.onDidStartTaskProcess(async (event) => { if (event.execution.task.name === SERVER_TASK_NAME) { - if (isProcessRunning(event.processId)) { - logger.debug( - 'Gradle server process started, waiting for server to start' - ); - try { - await waitOnTcp('localhost', this.port!); - this.fireOnReady(); - } catch (e) { - logger.error('Gradle server not started:', e.message); - } - } else { - logger.error('Gradle server processes not started'); - } + this.fireOnReady(); } }), vscode.tasks.onDidEndTaskProcess((event) => { diff --git a/extension/src/test/gradle/extension.test.ts b/extension/src/test/gradle/extension.test.ts index ad06d55ee..5d8783e8a 100644 --- a/extension/src/test/gradle/extension.test.ts +++ b/extension/src/test/gradle/extension.test.ts @@ -18,11 +18,12 @@ import { Output } from '../../proto/gradle_tasks_pb'; const extensionName = 'richardwillis.vscode-gradle'; const refreshCommand = 'gradle.refresh'; const fixtureName = process.env.FIXTURE_NAME || '(unknown fixture)'; +const suiteName = process.env.SUITE_NAME || '(unknown suite)'; const fixturePath = vscode.Uri.file( path.resolve(__dirname, '..', '..', '..', 'test-fixtures', fixtureName) ); -describe(fixtureName, () => { +describe(`${suiteName} - ${fixtureName}`, () => { // eslint-disable-next-line @typescript-eslint/no-explicit-any let extension: vscode.Extension | undefined; diff --git a/extension/src/test/multi-project/extension.test.ts b/extension/src/test/multi-project/extension.test.ts index f1738b49e..c5ff3495f 100644 --- a/extension/src/test/multi-project/extension.test.ts +++ b/extension/src/test/multi-project/extension.test.ts @@ -6,8 +6,9 @@ import { waitForTasksToLoad } from '../testUtil'; const extensionName = 'richardwillis.vscode-gradle'; const fixtureName = process.env.FIXTURE_NAME || '(unknown fixture)'; +const suiteName = process.env.SUITE_NAME || '(unknown suite)'; -describe(fixtureName, () => { +describe(`${suiteName} - ${fixtureName}`, () => { // eslint-disable-next-line @typescript-eslint/no-explicit-any let extension: vscode.Extension | undefined; diff --git a/extension/src/test/multi-root/extension.test.ts b/extension/src/test/multi-root/extension.test.ts index 7b27272f6..64832283b 100644 --- a/extension/src/test/multi-root/extension.test.ts +++ b/extension/src/test/multi-root/extension.test.ts @@ -6,8 +6,9 @@ import { waitForTasksToLoad } from '../testUtil'; const extensionName = 'richardwillis.vscode-gradle'; const fixtureName = process.env.FIXTURE_NAME || '(unknown fixture)'; +const suiteName = process.env.SUITE_NAME || '(unknown suite)'; -describe(fixtureName, () => { +describe(`${suiteName} - ${fixtureName}`, () => { // eslint-disable-next-line @typescript-eslint/no-explicit-any let extension: vscode.Extension | undefined; diff --git a/extension/src/test/runTests.ts b/extension/src/test/runTests.ts index f94db5dda..9791f815e 100644 --- a/extension/src/test/runTests.ts +++ b/extension/src/test/runTests.ts @@ -29,12 +29,39 @@ async function runTestsWithGradle( ], extensionTestsEnv: { FIXTURE_NAME: fixture, + SUITE_NAME: 'Run tests with Gradle', VSCODE_TEST: 'true', }, }); } } +async function runNetworkTestsWithGradle( + vscodeExecutablePath: string, + userDir: string +): Promise { + const fixtures = ['gradle-groovy-custom-build-file']; + for (const fixture of fixtures) { + await runTests({ + vscodeExecutablePath, + extensionDevelopmentPath, + extensionTestsPath: path.resolve(__dirname, 'gradle'), + launchArgs: [ + path.resolve(__dirname, `../../test-fixtures/${fixture}`), + '--disable-extensions', + `--user-data-dir=${userDir}`, + ], + extensionTestsEnv: { + FIXTURE_NAME: fixture, + VSCODE_TEST: 'true', + SUITE_NAME: 'Run network tests with Gradle', + // eslint-disable-next-line @typescript-eslint/camelcase + http_proxy: 'http://0.0.0.0', + }, + }); + } +} + function runTestsWithoutGradle( vscodeExecutablePath: string, userDir: string @@ -50,6 +77,7 @@ function runTestsWithoutGradle( ], extensionTestsEnv: { VSCODE_TEST: 'true', + SUITE_NAME: 'Run tests without Gradle', }, }); } @@ -73,6 +101,7 @@ function runTestsWithMultiRoot( extensionTestsEnv: { FIXTURE_NAME: 'multi-root', VSCODE_TEST: 'true', + SUITE_NAME: 'Run tests with multi-root vscode project', }, }); } @@ -93,6 +122,7 @@ function runTestsWithMultiProject( extensionTestsEnv: { FIXTURE_NAME: 'multi-project', VSCODE_TEST: 'true', + SUITE_NAME: 'Run tests with Gradle multi-project', }, }); } @@ -109,6 +139,7 @@ async function main(): Promise { try { await runTestsWithGradle(vscodeExecutablePath, tmpDir); + await runNetworkTestsWithGradle(vscodeExecutablePath, tmpDir); await runTestsWithMultiRoot(vscodeExecutablePath, tmpDir); await runTestsWithMultiProject(vscodeExecutablePath, tmpDir); await runTestsWithoutGradle(vscodeExecutablePath, tmpDir); diff --git a/npm-package/package-lock.json b/npm-package/package-lock.json index 2a4f1665b..3effcfbe1 100644 --- a/npm-package/package-lock.json +++ b/npm-package/package-lock.json @@ -31,9 +31,9 @@ } }, "@grpc/grpc-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.0.3.tgz", - "integrity": "sha512-JKV3f5Bv2TZxK6eJSB9EarsZrnLxrvcFNwI9goq0YRXa3S6NNoCSnI3cG3lkXVIJ03Wng1WXe76kc2JQtRe7AQ==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.0.5.tgz", + "integrity": "sha512-Hm+xOiqAhcpT9RYM8lc15dbQD7aQurM7ZU8ulmulepiPlN7iwBXXwP3vSBUimoFoApRqz7pSIisXU8pZaCB4og==", "requires": { "semver": "^6.2.0" } diff --git a/npm-package/package.json b/npm-package/package.json index d94ebf373..f0f545411 100644 --- a/npm-package/package.json +++ b/npm-package/package.json @@ -25,7 +25,7 @@ "compile": "tsc -p ./" }, "dependencies": { - "@grpc/grpc-js": "^1.0.3", + "@grpc/grpc-js": "^1.0.5", "@types/google-protobuf": "^3.7.2", "@types/vscode": "^1.45.0", "google-protobuf": "^3.12.0-rc.1"