Skip to content

Commit 20689d5

Browse files
authored
Add smoke tests for webpack bundled extension (#3417)
For #3021
1 parent bcdc16e commit 20689d5

20 files changed

Lines changed: 313 additions & 125 deletions

.travis.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ matrix:
3030
- os: linux
3131
python: "3.7-dev"
3232
env: DEBUGGER_TEST_RELEASE=true
33-
- os: linux
34-
python: "3.7-dev"
35-
env: LANGUAGE_SERVER_TEST=true
3633
- os: linux
3734
python: "3.7-dev"
3835
env: SINGLE_WORKSPACE_TEST=true
3936
- os: linux
4037
python: "3.7-dev"
4138
env: MULTIROOT_WORKSPACE_TEST=true
39+
- os: linux
40+
python: "3.7-dev"
41+
env: BUNDLE=true
4242
before_install: |
4343
if [ $TRAVIS_OS_NAME == "linux" ]; then
4444
export CXX="g++-4.9" CC="gcc-4.9" DISPLAY=:99.0;
@@ -82,10 +82,6 @@ script:
8282
python -m pip install --upgrade -r functionalTestRequirements.txt;
8383
npm run test:functional;
8484
fi
85-
- if [ $LANGUAGE_SERVER_TEST == "true" ]; then
86-
npm run cover:enable;
87-
npm run testAnalysisEngine --silent;
88-
fi
8985
- if [ $SINGLE_WORKSPACE_TEST == "true" ]; then
9086
npm run cover:enable;
9187
npm run testSingleWorkspace --silent;
@@ -113,7 +109,14 @@ script:
113109
npm run clean;
114110
vsce package;
115111
azure storage blob upload python*.vsix $AZURE_STORAGE_CONTAINER ms-python-insiders.vsix --account-name $AZURE_STORAGE_ACCOUNT --account-key $AZURE_STORAGE_ACCESS_KEY --quiet;
112+
fi
113+
- if [[ $BUNDLE == "true" ]]; then
114+
npm run clean;
116115
npm run package;
116+
npx gulp clean:cleanExceptTests;
117+
npm run testSmoke;
118+
fi
119+
- if [[ $BUNDLE == "true" && $AZURE_STORAGE_ACCOUNT && "$TRAVIS_BRANCH" == "master" && "$TRAVIS_PULL_REQUEST" == "false" ]]; then
117120
azure storage blob upload python*.vsix $AZURE_STORAGE_CONTAINER ms-python-insiders-bundled.vsix --account-name $AZURE_STORAGE_ACCOUNT --account-key $AZURE_STORAGE_ACCESS_KEY --quiet;
118121
fi
119122
- if [[ $AZURE_STORAGE_ACCOUNT && "$TRAVIS_BRANCH" == release* && "$TRAVIS_PULL_REQUEST" == "false" ]]; then

.vscode/launch.json

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -94,28 +94,6 @@
9494
],
9595
"preLaunchTask": "Compile"
9696
},
97-
{
98-
"name": "Tests (Language Server)",
99-
"type": "extensionHost",
100-
"request": "launch",
101-
"runtimeExecutable": "${execPath}",
102-
"args": [
103-
"${workspaceFolder}/src/test",
104-
"--disable-extensions",
105-
"--extensionDevelopmentPath=${workspaceFolder}",
106-
"--extensionTestsPath=${workspaceFolder}/out/test"
107-
],
108-
"stopOnEntry": false,
109-
"sourceMaps": true,
110-
"outFiles": [
111-
"${workspaceFolder}/out/**/*.js"
112-
],
113-
"preLaunchTask": "Compile",
114-
"env": {
115-
"VSC_PYTHON_LANGUAGE_SERVER": "1",
116-
"TEST_FILES_SUFFIX": "ls.test"
117-
}
118-
},
11997
{
12098
"name": "Tests (VS Code, with code coverage, *.test.ts)",
12199
"type": "extensionHost",

.vscodeignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
!out/**/*.map
1+
!out/client/**/*.map
22
**/*.map
33
*.vsix
44
.appveyor.yml

build/existingFiles.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,6 @@
356356
"src/test/activation/languageServer/languageServerPackageService.test.ts",
357357
"src/test/activation/languageServer/languageServerPackageService.unit.test.ts",
358358
"src/test/activation/platformData.unit.test.ts",
359-
"src/test/analysisEngineTest.ts",
360359
"src/test/application/diagnostics/applicationDiagnostics.unit.test.ts",
361360
"src/test/application/diagnostics/checks/envPathVariable.unit.test.ts",
362361
"src/test/application/diagnostics/checks/invalidPythonPathInDebugger.unit.test.ts",
@@ -579,4 +578,4 @@
579578
"src/test/workspaceSymbols/common.ts",
580579
"src/test/workspaceSymbols/multiroot.test.ts",
581580
"src/test/workspaceSymbols/standard.test.ts"
582-
]
581+
]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
'use strict';
4+
Object.defineProperty(exports, "__esModule", { value: true });
5+
// tslint:disable:no-default-export no-invalid-this
6+
function default_1(source) {
7+
const code = 'var logic = path.join(__dirname, \'logic/\' + name + \'.js\')';
8+
if (source.indexOf(code) === -1) {
9+
throw new Error('Code to replace not found in getos');
10+
}
11+
source = source.replace(code, 'var logic = \'./logic/\' + name + \'.js\'');
12+
return source;
13+
}
14+
exports.default = default_1;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
'use strict';
5+
6+
// tslint:disable:no-default-export no-invalid-this
7+
export default function (source: string) {
8+
const code = 'var logic = path.join(__dirname, \'logic/\' + name + \'.js\')';
9+
if (source.indexOf(code) === -1) {
10+
throw new Error('Code to replace not found in getos');
11+
}
12+
source = source.replace(code, 'var logic = \'./logic/\' + name + \'.js\'');
13+
return source;
14+
}

build/webpack/webpack.extension.config.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
55
const glob = require("glob");
66
const path = require("path");
77
const tsconfig_paths_webpack_plugin_1 = require("tsconfig-paths-webpack-plugin");
8+
const webpack_1 = require("webpack");
89
const constants_1 = require("../constants");
910
const common_1 = require("./common");
1011
// tslint:disable-next-line:no-var-requires no-require-imports
@@ -32,13 +33,22 @@ const config = {
3233
rules: [
3334
{
3435
// JupyterServices imports node-fetch using `eval`.
35-
test: /@jupyterlab\/services\/.*js$/,
36+
test: /@jupyterlab[\\\/]services[\\\/].*js$/,
3637
use: [
3738
{
3839
loader: path.join(__dirname, 'loaders', 'fixEvalRequire.js')
3940
}
4041
]
4142
},
43+
{
44+
// Do not use __dirname in getos when using require.
45+
test: /getos[\\\/]index.js$/,
46+
use: [
47+
{
48+
loader: path.join(__dirname, 'loaders', 'fixGetosRequire.js')
49+
}
50+
]
51+
},
4252
{
4353
test: /\.ts$/,
4454
use: [
@@ -64,7 +74,8 @@ const config = {
6474
...existingModulesInOutDir
6575
],
6676
plugins: [
67-
...common_1.getDefaultPlugins('extension')
77+
...common_1.getDefaultPlugins('extension'),
78+
new webpack_1.ContextReplacementPlugin(/getos/, /logic\/.*.js/)
6879
],
6980
resolve: {
7081
extensions: ['.ts', '.js'],

build/webpack/webpack.extension.config.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import * as glob from 'glob';
77
import * as path from 'path';
88
import { TsconfigPathsPlugin } from 'tsconfig-paths-webpack-plugin';
9-
import * as webpack from 'webpack';
9+
import { Configuration, ContextReplacementPlugin } from 'webpack';
1010
import { ExtensionRootDir } from '../constants';
1111
import { getDefaultPlugins } from './common';
1212

@@ -22,7 +22,7 @@ function getListOfExistingModulesInOutDir() {
2222
return files.map(filePath => `./${filePath.slice(0, -3)}`);
2323
}
2424

25-
const config: webpack.Configuration = {
25+
const config: Configuration = {
2626
mode: 'production',
2727
target: 'node',
2828
entry: {
@@ -37,13 +37,22 @@ const config: webpack.Configuration = {
3737
rules: [
3838
{
3939
// JupyterServices imports node-fetch using `eval`.
40-
test: /@jupyterlab\/services\/.*js$/,
40+
test: /@jupyterlab[\\\/]services[\\\/].*js$/,
4141
use: [
4242
{
4343
loader: path.join(__dirname, 'loaders', 'fixEvalRequire.js')
4444
}
4545
]
4646
},
47+
{
48+
// Do not use __dirname in getos when using require.
49+
test: /getos[\\\/]index.js$/,
50+
use: [
51+
{
52+
loader: path.join(__dirname, 'loaders', 'fixGetosRequire.js')
53+
}
54+
]
55+
},
4756
{
4857
test: /\.ts$/,
4958
use: [
@@ -69,7 +78,8 @@ const config: webpack.Configuration = {
6978
...existingModulesInOutDir
7079
],
7180
plugins: [
72-
...getDefaultPlugins('extension')
81+
...getDefaultPlugins('extension'),
82+
new ContextReplacementPlugin(/getos/, /logic\/.*.js/)
7383
],
7484
resolve: {
7585
extensions: ['.ts', '.js'],

gulpfile.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,11 @@ gulp.task('cover:clean', () => del(['coverage', 'debug_coverage*']));
101101

102102
gulp.task('output:clean', () => del(['coverage', 'debug_coverage*']));
103103

104-
gulp.task('clean:cleanExceptTests', () => del(['out/client', 'out/datascience-ui', 'out/server']));
104+
gulp.task('clean:cleanExceptTests', () => del(['clean:vsix', 'out/client', 'out/datascience-ui', 'out/server']));
105+
gulp.task('clean:vsix', () => del(['*.vsix']));
105106
gulp.task('clean:out', () => del(['out']));
106107

107-
gulp.task('clean', gulp.parallel('output:clean', 'cover:clean'));
108+
gulp.task('clean', gulp.parallel('output:clean', 'cover:clean', 'clean:vsix'));
108109

109110
gulp.task('clean:ptvsd', () => del(['coverage', 'pythonFiles/experimental/ptvsd/*']));
110111

news/3 Code Health/3021.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add smoke tests for the extension.

0 commit comments

Comments
 (0)