Skip to content

Commit 92de223

Browse files
authored
Refactor language server tests and add tests for language server (#3231)
For #2041
1 parent e370a3b commit 92de223

27 files changed

+806
-1222
lines changed

.travis.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ matrix:
3939
- os: linux
4040
python: "3.7-dev"
4141
env: DEBUGGER_TEST_RELEASE=true
42+
- os: linux
43+
python: "3.7-dev"
44+
env: LANGUAGE_SERVER_TEST=true
4245
- os: linux
4346
python: "3.7-dev"
4447
env: SINGLE_WORKSPACE_TEST=true
@@ -97,6 +100,10 @@ script:
97100
python -m pip install --upgrade -r functionalTestRequirements.txt;
98101
npm run test:functional;
99102
fi
103+
- if [ $LANGUAGE_SERVER_TEST == "true" ]; then
104+
npm run cover:enable;
105+
npm run testAnalysisEngine --silent;
106+
fi
100107
- if [ $SINGLE_WORKSPACE_TEST == "true" ]; then
101108
npm run cover:enable;
102109
npm run testSingleWorkspace --silent;

.vscode/launch.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"runtimeExecutable": "${execPath}",
4343
"args": [
4444
"${workspaceFolder}/src/testMultiRootWkspc/multi.code-workspace",
45+
"--disable-extensions",
4546
"--extensionDevelopmentPath=${workspaceFolder}",
4647
"--extensionTestsPath=${workspaceFolder}/out/test"
4748
],
@@ -63,6 +64,7 @@
6364
"runtimeExecutable": "${execPath}",
6465
"args": [
6566
"${workspaceFolder}/src/test",
67+
"--disable-extensions",
6668
"--extensionDevelopmentPath=${workspaceFolder}",
6769
"--extensionTestsPath=${workspaceFolder}/out/test"
6870
],
@@ -80,6 +82,7 @@
8082
"runtimeExecutable": "${execPath}",
8183
"args": [
8284
"${workspaceFolder}/src/testMultiRootWkspc/multi.code-workspace",
85+
"--disable-extensions",
8386
"--extensionDevelopmentPath=${workspaceFolder}",
8487
"--extensionTestsPath=${workspaceFolder}/out/test"
8588
],
@@ -98,6 +101,7 @@
98101
"runtimeExecutable": "${execPath}",
99102
"args": [
100103
"${workspaceFolder}/src/test",
104+
"--disable-extensions",
101105
"--extensionDevelopmentPath=${workspaceFolder}",
102106
"--extensionTestsPath=${workspaceFolder}/out/test"
103107
],
@@ -108,7 +112,8 @@
108112
],
109113
"preLaunchTask": "Compile",
110114
"env": {
111-
"VSC_PYTHON_LANGUAGE_SERVER": "1"
115+
"VSC_PYTHON_LANGUAGE_SERVER": "1",
116+
"TEST_FILES_SUFFIX": "ls.test"
112117
}
113118
},
114119
{
@@ -118,6 +123,7 @@
118123
"runtimeExecutable": "${execPath}",
119124
"args": [
120125
"${workspaceFolder}/src/test",
126+
"--disable-extensions",
121127
"--extensionDevelopmentPath=${workspaceFolder}",
122128
"--extensionTestsPath=${workspaceFolder}/out/test"
123129
],

news/3 Code Health/2041.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added basic integration tests for the new Lanaguage Server.

src/client/activation/activationService.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
IApplicationShell, ICommandManager,
1313
IWorkspaceService
1414
} from '../common/application/types';
15-
import { isLanguageServerTest, STANDARD_OUTPUT_CHANNEL } from '../common/constants';
15+
import { STANDARD_OUTPUT_CHANNEL } from '../common/constants';
1616
import '../common/extensions';
1717
import { IPlatformService } from '../common/platform/types';
1818
import {
@@ -111,9 +111,6 @@ export class ExtensionActivationService implements IExtensionActivationService,
111111
}
112112
}
113113
private useJedi(): boolean {
114-
if (isLanguageServerTest()) {
115-
return false;
116-
}
117114
const workspacesUris: (Uri | undefined)[] = this.workspaceService.hasWorkspaceFolders ? this.workspaceService.workspaceFolders!.map(item => item.uri) : [undefined];
118115
const configuraionService = this.serviceContainer.get<IConfigurationService>(IConfigurationService);
119116
return workspacesUris.filter(uri => configuraionService.getSettings(uri).jediEnabled).length > 0;

src/client/common/constants.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,5 @@ export function isTestExecution(): boolean {
8585
export function isUnitTestExecution(): boolean {
8686
return process.env.VSC_PYTHON_UNIT_TEST === '1';
8787
}
88-
export function isLanguageServerTest(): boolean {
89-
return process.env.VSC_PYTHON_LANGUAGE_SERVER === '1';
90-
}
9188

9289
export const EXTENSION_ROOT_DIR = path.join(__dirname, '..', '..', '..');

src/client/linters/linterInfo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export class PylintLinterInfo extends LinterInfo {
7979
return enabled;
8080
}
8181
// If we're using new LS, then by default Pylint is disabled (unless the user provides a value).
82-
const inspection = this.workspaceService.getConfiguration('python.linting', resource).inspect<boolean>('pylintEnabled');
82+
const inspection = this.workspaceService.getConfiguration('python', resource).inspect<boolean>('linting.pylintEnabled');
8383
if (!inspection || inspection.globalValue === undefined && inspection.workspaceFolderValue === undefined || inspection.workspaceValue === undefined) {
8484
return false;
8585
}

src/test/.vscode/settings.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,9 @@
1818
"python.linting.mypyEnabled": false,
1919
"python.linting.banditEnabled": false,
2020
"python.formatting.provider": "yapf",
21-
"python.linting.pylintUseMinimalCheckers": false,
21+
"python.linting.pylintUseMinimalCheckers": false
22+
// Do not set this to true/false even when LS is the default, else
23+
// it will result in LS being downloaded on CI and slow down tests significantly.
24+
// We have other tests on CI for testing downloading of CI with this setting enabled.
25+
// "python.jediEnabled": true
2226
}

src/test/activation/activationService.unit.test.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
IApplicationShell, ICommandManager,
1919
IWorkspaceService
2020
} from '../../client/common/application/types';
21-
import { isLanguageServerTest } from '../../client/common/constants';
2221
import { IPlatformService } from '../../client/common/platform/types';
2322
import {
2423
IConfigurationService, IDisposableRegistry,
@@ -37,11 +36,7 @@ suite('Activation - ActivationService', () => {
3736
let cmdManager: TypeMoq.IMock<ICommandManager>;
3837
let workspaceService: TypeMoq.IMock<IWorkspaceService>;
3938
let platformService: TypeMoq.IMock<IPlatformService>;
40-
setup(function () {
41-
if (isLanguageServerTest()) {
42-
// tslint:disable-next-line:no-invalid-this
43-
return this.skip();
44-
}
39+
setup(() => {
4540
serviceContainer = TypeMoq.Mock.ofType<IServiceContainer>();
4641
appShell = TypeMoq.Mock.ofType<IApplicationShell>();
4742
workspaceService = TypeMoq.Mock.ofType<IWorkspaceService>();

src/test/activation/excludeFiles.ls.test.ts

Lines changed: 0 additions & 94 deletions
This file was deleted.

src/test/analysisEngineTest.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as path from 'path';
77
process.env.CODE_TESTS_WORKSPACE = path.join(__dirname, '..', '..', 'src', 'test');
88
process.env.IS_CI_SERVER_TEST_DEBUGGER = '';
99
process.env.VSC_PYTHON_LANGUAGE_SERVER = '1';
10+
process.env.TEST_FILES_SUFFIX = 'ls.test';
1011

1112
function start() {
1213
console.log('*'.repeat(100));

0 commit comments

Comments
 (0)