Skip to content

Commit dba1f47

Browse files
authored
Re-enable support for source maps (#8687)
* Fix source map * Re-enable support for source maps * Fixes * Linter issues * Address review comments
1 parent d41e10d commit dba1f47

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

news/2 Fixes/8686.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Re-enable support for source-maps.

src/client/sourceMapSupport.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export class SourceMapSupport {
2626
return;
2727
}
2828
await this.enableSourceMaps(true);
29+
require('source-map-support').install();
2930
const localize = require('./common/utils/localize') as typeof import('./common/utils/localize');
3031
const disable = localize.Diagnostics.disableSourceMaps();
3132
this.vscode.window.showWarningMessage(localize.Diagnostics.warnSourceMaps(), disable).then(selection => {

src/test/sourceMapSupport.unit.test.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33

44
'use strict';
55

6-
// tslint:disable:no-any no-unused-expression chai-vague-errors no-unnecessary-override max-func-body-length max-classes-per-file
6+
// tslint:disable:no-unused-expression chai-vague-errors no-unnecessary-override max-func-body-length max-classes-per-file match-default-export-name
77

88
import { expect } from 'chai';
99
import * as path from 'path';
10+
import rewiremock from 'rewiremock';
11+
import * as sinon from 'sinon';
1012
import { ConfigurationTarget, Disposable } from 'vscode';
1113
import { Diagnostics } from '../client/common/utils/localize';
1214
import { EXTENSION_ROOT_DIR } from '../client/constants';
@@ -22,6 +24,7 @@ suite('Source Map Support', () => {
2224
};
2325
const vscode = {
2426
workspace: {
27+
// tslint:disable-next-line: no-any
2528
getConfiguration: (setting: string, _defaultValue: any) => {
2629
if (setting !== 'python.diagnostics') {
2730
return;
@@ -52,6 +55,7 @@ suite('Source Map Support', () => {
5255

5356
const disposables: Disposable[] = [];
5457
teardown(() => {
58+
rewiremock.disable();
5559
disposables.forEach(disposable => {
5660
try {
5761
disposable.dispose();
@@ -60,19 +64,26 @@ suite('Source Map Support', () => {
6064
});
6165
test('Test message is not displayed when source maps are not enabled', async () => {
6266
const stub = createVSCStub(false);
67+
// tslint:disable-next-line: no-any
6368
initialize(stub.vscode as any);
6469
await sleep(100);
6570
expect(stub.stubInfo.configValueRetrieved).to.be.equal(true, 'Config Value not retrieved');
6671
expect(stub.stubInfo.messageDisplayed).to.be.equal(false, 'Message displayed');
6772
});
68-
test('Test message is not displayed when source maps are not enabled', async () => {
73+
test('Test message is displayed when source maps are not enabled', async () => {
6974
const stub = createVSCStub(true);
7075
const instance = new class extends SourceMapSupport {
7176
protected async enableSourceMaps(_enable: boolean) {
7277
noop();
7378
}
79+
// tslint:disable-next-line: no-any
7480
}(stub.vscode as any);
81+
rewiremock.enable();
82+
const installStub = sinon.stub();
83+
rewiremock('source-map-support').with({ install: installStub });
7584
await instance.initialize();
85+
86+
expect(installStub.callCount).to.be.equal(1);
7687
expect(stub.stubInfo.configValueRetrieved).to.be.equal(true, 'Config Value not retrieved');
7788
expect(stub.stubInfo.messageDisplayed).to.be.equal(true, 'Message displayed');
7889
expect(stub.stubInfo.configValueUpdated).to.be.equal(false, 'Config Value updated');
@@ -83,6 +94,7 @@ suite('Source Map Support', () => {
8394
protected async enableSourceMaps(_enable: boolean) {
8495
noop();
8596
}
97+
// tslint:disable-next-line: no-any
8698
}(stub.vscode as any);
8799

88100
await instance.initialize();
@@ -102,6 +114,7 @@ suite('Source Map Support', () => {
102114
sourceFilesPassed.push(sourceFile);
103115
return Promise.resolve();
104116
}
117+
// tslint:disable-next-line: no-any
105118
}(stub.vscode as any);
106119

107120
await instance.enableSourceMaps(enableSourceMaps);

0 commit comments

Comments
 (0)