Skip to content

Commit

Permalink
Don't update vscode during tests
Browse files Browse the repository at this point in the history
Needs to be a short dir name, see microsoft/vscode#86382
  • Loading branch information
badsyntax committed May 18, 2020
1 parent 3380a19 commit 74cbbe4
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 17 deletions.
43 changes: 43 additions & 0 deletions extension/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
40 changes: 32 additions & 8 deletions extension/src/test/runTests.ts
Original file line number Diff line number Diff line change
@@ -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<void> {
async function runTestsWithGradle(
vscodeExecutablePath: string,
userDir: string
): Promise<void> {
const fixtures = [
'gradle-groovy-default-build-file',
'gradle-kotlin-default-build-file',
Expand All @@ -20,6 +25,7 @@ async function runTestsWithGradle(vscodeExecutablePath: string): Promise<void> {
launchArgs: [
path.resolve(__dirname, `../../test-fixtures/${fixture}`),
'--disable-extensions',
`--user-data-dir=${userDir}`,
],
extensionTestsEnv: {
FIXTURE_NAME: fixture,
Expand All @@ -29,22 +35,29 @@ async function runTestsWithGradle(vscodeExecutablePath: string): Promise<void> {
}
}

function runTestsWithoutGradle(vscodeExecutablePath: string): Promise<number> {
function runTestsWithoutGradle(
vscodeExecutablePath: string,
userDir: string
): Promise<number> {
return runTests({
vscodeExecutablePath,
extensionDevelopmentPath,
extensionTestsPath: path.resolve(__dirname, 'no-gradle'),
launchArgs: [
path.resolve(__dirname, '../../test-fixtures/no-gradle'),
'--disable-extensions',
`--user-data-dir=${userDir}`,
],
extensionTestsEnv: {
VSCODE_TEST: 'true',
},
});
}

function runTestsWithMultiRoot(vscodeExecutablePath: string): Promise<number> {
function runTestsWithMultiRoot(
vscodeExecutablePath: string,
userDir: string
): Promise<number> {
return runTests({
vscodeExecutablePath,
extensionDevelopmentPath,
Expand All @@ -55,6 +68,7 @@ function runTestsWithMultiRoot(vscodeExecutablePath: string): Promise<number> {
'../../test-fixtures/multi-root/multiple-project.code-workspace'
),
'--disable-extensions',
`--user-data-dir=${userDir}`,
],
extensionTestsEnv: {
FIXTURE_NAME: 'multi-root',
Expand All @@ -64,7 +78,8 @@ function runTestsWithMultiRoot(vscodeExecutablePath: string): Promise<number> {
}

async function runTestsWithMultiProject(
vscodeExecutablePath: string
vscodeExecutablePath: string,
userDir: string
): Promise<number> {
return runTests({
vscodeExecutablePath,
Expand All @@ -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',
Expand All @@ -82,14 +98,22 @@ async function runTestsWithMultiProject(
}

async function main(): Promise<void> {
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);
});
}

Expand Down

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions extension/test-fixtures/multi-project/.vscode/settings.json

This file was deleted.

0 comments on commit 74cbbe4

Please sign in to comment.