From b9f1bb2cba6ce04054159071019052f99fc67f64 Mon Sep 17 00:00:00 2001 From: Richard Willis Date: Mon, 18 May 2020 18:00:36 +0100 Subject: [PATCH] Don't update vscode when tests are running --- .github/workflows/build-and-test.yml | 2 +- extension/src/test/runTests.ts | 40 +++++++++++-------- .../.vscode/settings.json | 3 ++ .../.gitignore | 3 -- .../.vscode/settings.json | 3 ++ .../.vscode/settings.json | 3 ++ .../multi-project/.vscode/settings.json | 3 ++ 7 files changed, 37 insertions(+), 20 deletions(-) create mode 100644 extension/test-fixtures/gradle-groovy-custom-build-file/.vscode/settings.json create mode 100644 extension/test-fixtures/gradle-groovy-default-build-file/.vscode/settings.json create mode 100644 extension/test-fixtures/gradle-kotlin-default-build-file/.vscode/settings.json create mode 100644 extension/test-fixtures/multi-project/.vscode/settings.json diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 87bb891cd..50a3e0205 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -45,7 +45,7 @@ jobs: matrix: node-version: [12.16.2] java-version: ['8', '11'] - os: [ubuntu-latest, windows-latest] # unable to test on macos-latest, see https://github.com/microsoft/vscode/issues/98080 + os: [ubuntu-latest, windows-latest, macos-latest] steps: - uses: actions/checkout@v1 - name: Use Node ${{ matrix.node-version }} diff --git a/extension/src/test/runTests.ts b/extension/src/test/runTests.ts index 303a53e4d..32788c0ad 100644 --- a/extension/src/test/runTests.ts +++ b/extension/src/test/runTests.ts @@ -1,11 +1,12 @@ /* eslint-disable sonarjs/no-duplicate-string */ import * as path from 'path'; -import { runTests } from 'vscode-test'; +import { runTests, downloadAndUnzipVSCode } from 'vscode-test'; const extensionDevelopmentPath = path.resolve(__dirname, '../../'); +const VSCODE_VERSION = '1.45.0'; -async function runTestsWithGradle(): Promise { +async function runTestsWithGradle(vscodeExecutablePath: string): Promise { const fixtures = [ 'gradle-groovy-default-build-file', 'gradle-kotlin-default-build-file', @@ -13,6 +14,7 @@ async function runTestsWithGradle(): Promise { ]; for (const fixture of fixtures) { await runTests({ + vscodeExecutablePath, extensionDevelopmentPath, extensionTestsPath: path.resolve(__dirname, 'gradle'), launchArgs: [ @@ -27,8 +29,9 @@ async function runTestsWithGradle(): Promise { } } -async function runTestsWithoutGradle(): Promise { - await runTests({ +function runTestsWithoutGradle(vscodeExecutablePath: string): Promise { + return runTests({ + vscodeExecutablePath, extensionDevelopmentPath, extensionTestsPath: path.resolve(__dirname, 'no-gradle'), launchArgs: [ @@ -41,8 +44,9 @@ async function runTestsWithoutGradle(): Promise { }); } -async function runTestsWithMultiRoot(): Promise { - await runTests({ +function runTestsWithMultiRoot(vscodeExecutablePath: string): Promise { + return runTests({ + vscodeExecutablePath, extensionDevelopmentPath, extensionTestsPath: path.resolve(__dirname, 'multi-root'), launchArgs: [ @@ -59,8 +63,11 @@ async function runTestsWithMultiRoot(): Promise { }); } -async function runTestsWithMultiProject(): Promise { - await runTests({ +async function runTestsWithMultiProject( + vscodeExecutablePath: string +): Promise { + return runTests({ + vscodeExecutablePath, extensionDevelopmentPath, extensionTestsPath: path.resolve(__dirname, 'multi-project'), launchArgs: [ @@ -75,14 +82,15 @@ async function runTestsWithMultiProject(): Promise { } async function main(): Promise { - try { - await runTestsWithGradle(); - await runTestsWithMultiRoot(); - await runTestsWithMultiProject(); - await runTestsWithoutGradle(); - } catch (err) { - process.exit(1); - } + const vscodeExecutablePath = await downloadAndUnzipVSCode(VSCODE_VERSION); + + runTestsWithGradle(vscodeExecutablePath) + .then(() => runTestsWithMultiRoot(vscodeExecutablePath)) + .then(() => runTestsWithMultiProject(vscodeExecutablePath)) + .then(() => runTestsWithoutGradle(vscodeExecutablePath)) + .catch((err) => { + console.error('Error running tests:', err.message); + }); } main(); diff --git a/extension/test-fixtures/gradle-groovy-custom-build-file/.vscode/settings.json b/extension/test-fixtures/gradle-groovy-custom-build-file/.vscode/settings.json new file mode 100644 index 000000000..756721312 --- /dev/null +++ b/extension/test-fixtures/gradle-groovy-custom-build-file/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "update.mode": "none" +} diff --git a/extension/test-fixtures/gradle-groovy-default-build-file/.gitignore b/extension/test-fixtures/gradle-groovy-default-build-file/.gitignore index 406e5d275..1b6985c00 100644 --- a/extension/test-fixtures/gradle-groovy-default-build-file/.gitignore +++ b/extension/test-fixtures/gradle-groovy-default-build-file/.gitignore @@ -3,6 +3,3 @@ # Ignore Gradle build output directory build - -# Ignore .vscode settings -.vscode 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 new file mode 100644 index 000000000..756721312 --- /dev/null +++ b/extension/test-fixtures/gradle-groovy-default-build-file/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "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 new file mode 100644 index 000000000..756721312 --- /dev/null +++ b/extension/test-fixtures/gradle-kotlin-default-build-file/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "update.mode": "none" +} diff --git a/extension/test-fixtures/multi-project/.vscode/settings.json b/extension/test-fixtures/multi-project/.vscode/settings.json new file mode 100644 index 000000000..756721312 --- /dev/null +++ b/extension/test-fixtures/multi-project/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "update.mode": "none" +}