Skip to content

Commit 6893903

Browse files
Fix Variable Nightly tests (microsoft#13085)
1 parent cf4f377 commit 6893903

File tree

4 files changed

+38
-28
lines changed

4 files changed

+38
-28
lines changed

news/3 Code Health/13075.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix broken nightly variable explorer tests.

src/client/datascience/interactive-window/identity.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Uri } from 'vscode';
66
import '../../common/extensions';
77
import * as localize from '../../common/utils/localize';
88

9-
const identities: string[] = [];
9+
let identities: string[] = [];
1010
let createCount = 0;
1111

1212
export function getDefaultInteractiveIdentity(): Uri {
@@ -17,6 +17,12 @@ export function getDefaultInteractiveIdentity(): Uri {
1717
return Uri.parse(`history://${identities[0]}`);
1818
}
1919

20+
// Between test runs reset our identity
21+
export function resetIdentity() {
22+
createCount = 0;
23+
identities = [];
24+
}
25+
2026
export function createInteractiveIdentity(): Uri {
2127
if (createCount > 0 || identities.length <= 0) {
2228
identities.push(uuid());

src/test/datascience/testInteractiveWindowProvider.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
import { createDeferred, Deferred } from '../../client/common/utils/async';
1919
import { InteractiveWindowMessageListener } from '../../client/datascience/interactive-common/interactiveWindowMessageListener';
2020
import { InteractiveWindowMessages } from '../../client/datascience/interactive-common/interactiveWindowTypes';
21+
import { resetIdentity } from '../../client/datascience/interactive-window/identity';
2122
import { InteractiveWindow } from '../../client/datascience/interactive-window/interactiveWindow';
2223
import { InteractiveWindowProvider } from '../../client/datascience/interactive-window/interactiveWindowProvider';
2324
import { IInteractiveWindow, IInteractiveWindowProvider } from '../../client/datascience/types';
@@ -52,6 +53,9 @@ export class TestInteractiveWindowProvider extends InteractiveWindowProvider imp
5253
@inject(IApplicationShell) appShell: IApplicationShell
5354
) {
5455
super(liveShare, container, asyncRegistry, disposables, fileSystem, configService, globalMemento, appShell);
56+
57+
// Reset our identity IDs when we create a new TestInteractiveWindowProvider
58+
resetIdentity();
5559
}
5660

5761
public getMountedWebView(window: IInteractiveWindow | undefined): IMountedWebView {

src/test/datascience/variableexplorer.functional.test.tsx

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ import pandas as pd
105105
value = 'hello world'`;
106106
const basicCode2: string = `value2 = 'hello world 2'`;
107107

108-
const mount = ioc.getInteractiveWebPanel(undefined);
108+
const { mount } = await getOrCreateInteractiveWindow(ioc);
109109
const wrapper = mount.wrapper;
110110

111111
openVariableExplorer(wrapper);
@@ -172,7 +172,7 @@ value = 'hello world'`;
172172
const basicCode: string = `value = 'hello world'`;
173173
const basicCode2: string = `value2 = 'hello world 2'`;
174174

175-
const mount = ioc.getInteractiveWebPanel(undefined);
175+
const { mount } = await getOrCreateInteractiveWindow(ioc);
176176
const wrapper = mount.wrapper;
177177

178178
openVariableExplorer(wrapper);
@@ -270,15 +270,16 @@ value = 'hello world'`;
270270
async () => {
271271
const basicCode: string = `myList = [1, 2, 3]
272272
mySet = set([42])
273-
myDict = {'a': 1}`;
273+
myDict = {'a': 1}
274+
myTuple = 1,2,3,4,5,6,7,8,9`;
274275

275-
const mount = ioc.getInteractiveWebPanel(undefined);
276+
const { mount } = await getOrCreateInteractiveWindow(ioc);
276277
const wrapper = mount.wrapper;
277278

278279
openVariableExplorer(wrapper);
279280

280281
await addCodeImpartial(wrapper, 'a=1\na');
281-
await addCodeImpartial(wrapper, basicCode, true);
282+
await addCodeImpartial(wrapper, basicCode, true, 2);
282283

283284
const targetVariables: IJupyterVariable[] = [
284285
{
@@ -322,6 +323,16 @@ myDict = {'a': 1}`;
322323
shape: '',
323324
count: 1,
324325
truncated: false
326+
},
327+
{
328+
name: 'myTuple',
329+
value: '(1, 2, 3, 4, 5, 6, 7, 8, 9)',
330+
supportsDataExplorer: false,
331+
type: 'tuple',
332+
size: 54,
333+
shape: '9',
334+
count: 0,
335+
truncated: false
325336
}
326337
];
327338
verifyVariables(wrapper, targetVariables);
@@ -371,9 +382,8 @@ myFloat = 9999.9999
371382
mynpArray = np.array([1.0, 2.0, 3.0])
372383
myDataframe = pd.DataFrame(mynpArray)
373384
mySeries = myDataframe[0]
374-
myTuple = 1,2,3,4,5,6,7,8,9
375385
`;
376-
const mount = ioc.getInteractiveWebPanel(undefined);
386+
const { mount } = await getOrCreateInteractiveWindow(ioc);
377387
const wrapper = mount.wrapper;
378388

379389
openVariableExplorer(wrapper);
@@ -449,16 +459,6 @@ Name: 0, dtype: float64`,
449459
count: 0,
450460
truncated: false
451461
},
452-
{
453-
name: 'myTuple',
454-
value: '(1, 2, 3, 4, 5, 6, 7, 8, 9)',
455-
supportsDataExplorer: false,
456-
type: 'tuple',
457-
size: 54,
458-
shape: '9',
459-
count: 0,
460-
truncated: false
461-
},
462462
{
463463
name: 'mynpArray',
464464
value: '[1. 2. 3.]',
@@ -474,7 +474,7 @@ Name: 0, dtype: float64`,
474474

475475
// Step into the first cell over again. Should have the same variables
476476
if (runByLine) {
477-
targetVariables[7].value = 'array([1., 2., 3.])'; // Debugger shows np array differently
477+
targetVariables[6].value = 'array([1., 2., 3.])'; // Debugger shows np array differently
478478
await verifyAfterStep(ioc, wrapper, () => {
479479
verifyVariables(wrapper, targetVariables);
480480
return Promise.resolve();
@@ -512,7 +512,7 @@ Name: 0, dtype: float64`,
512512
const basicCode: string = `for _i in range(1050):
513513
exec("var{}=[{} ** 2 % 17 for _l in range(100000)]".format(_i, _i))`;
514514

515-
const mount = t === 'native' ? ioc.getNativeWebPanel(undefined) : ioc.getInteractiveWebPanel(undefined);
515+
const { mount } = t === 'native' ? await createNewEditor(ioc) : await getOrCreateInteractiveWindow(ioc);
516516
const wrapper = mount.wrapper;
517517
openVariableExplorer(wrapper);
518518

@@ -523,13 +523,11 @@ Name: 0, dtype: float64`,
523523
.map(generateVar)
524524
.sort((a: IJupyterVariable, b: IJupyterVariable) => a.name.localeCompare(b.name));
525525

526-
const targetVariables = allVariables.slice(0, 16);
526+
const targetVariables = allVariables.slice(0, 14);
527527
verifyVariables(wrapper, targetVariables);
528528

529529
// Force a scroll to the bottom
530-
const complete = mount.waitForMessage(InteractiveWindowMessages.VariablesComplete, {
531-
numberOfTimes: 2
532-
});
530+
const complete = mount.waitForMessage(InteractiveWindowMessages.VariablesComplete);
533531
const grid = wrapper.find(AdazzleReactDataGrid);
534532
const viewPort = grid.find('Viewport').instance();
535533
const rowHeight = (viewPort.props as any).rowHeight as number;
@@ -540,7 +538,7 @@ Name: 0, dtype: float64`,
540538
await complete;
541539

542540
// Now we should have the bottom. For some reason only 10 come back here.
543-
const bottomVariables = allVariables.slice(1041, 1051);
541+
const bottomVariables = allVariables.slice(1041, 1050);
544542
verifyVariables(wrapper, bottomVariables);
545543

546544
// Step into the first cell over again. Should have the same variables
@@ -550,15 +548,15 @@ Name: 0, dtype: float64`,
550548
.map((v) => {
551549
return { ...v, value: undefined };
552550
})
553-
.slice(0, 10);
551+
.slice(0, 9);
554552
await verifyAfterStep(
555553
ioc,
556554
wrapper,
557555
() => {
558556
verifyVariables(wrapper, nonValued);
559557
return Promise.resolve();
560558
},
561-
3 // 3 refreshes because the variable explorer is scrolled to the bottom.
559+
2 // 2 refreshes because the variable explorer is scrolled to the bottom.
562560
);
563561
}
564562
},
@@ -576,7 +574,8 @@ mynpArray = np.array([1.0, 2.0, 3.0])
576574
myDataframe = pd.DataFrame(mynpArray)
577575
mySeries = myDataframe[0]
578576
`;
579-
const wrapper = ioc.getInteractiveWebPanel(undefined).wrapper;
577+
const { mount } = await getOrCreateInteractiveWindow(ioc);
578+
const wrapper = mount.wrapper;
580579

581580
openVariableExplorer(wrapper);
582581

0 commit comments

Comments
 (0)