Skip to content

Commit a649233

Browse files
Fix ENVI plots not working, tweak execution logic, update tests
1 parent 4dff6e6 commit a649233

24 files changed

Lines changed: 478 additions & 68 deletions

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Remove a false error report when you stop IDL (terminate the process) while it i
2222

2323
Fixed an error where we were not automatically returning from the main level when you compiled a main level program.
2424

25+
Fixed an issue in IDL Notebooks where, once ENVI is started, a notebook no longer can embed multiple graphics in a single notebook cell.
26+
2527
## 4.5.0 - May 2024
2628

2729
New-and improved IDL Notebook user experience!

apps/client-e2e/src/tests/notebooks/_notebook-runner.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import { OpenENVINotebookExample } from './open-envi-notebook-example';
2020
import { OpenIDLNotebookExample } from './open-idl-notebook-example';
2121
import { ResetNotebookExamples } from './reset-notebook-examples';
2222
import { RunENVIMessageListenerTestNotebook } from './run-envi-message-listener-test-notebook';
23+
import { RunENVIMultiPlotNotebook } from './run-envi-multi-plot-notebook';
24+
import { RunPlotRegressionNotebook } from './run-plot-regression-notebook';
2325
import { RunProblemNotebooks } from './run-problem-notebooks';
2426
import { RunTestENVIMapNotebook } from './run-test-envi-map-notebook';
2527
import { RunTestENVINotebook } from './run-test-envi-notebook';
@@ -162,8 +164,25 @@ NOTEBOOK_RUNNER.addTest({
162164
],
163165
});
164166

167+
// can get multiple graphics when ENVI has started
165168
NOTEBOOK_RUNNER.addTest({
166-
name: 'Stack trace decorations on execution halted 1',
169+
name: 'Notebooks can display more than one plot when ENVI has started',
170+
fn: RunENVIMultiPlotNotebook,
171+
excludeOS: [
172+
{
173+
os: ['darwin'],
174+
architecture: ['arm', 'arm64'],
175+
},
176+
],
177+
});
178+
179+
NOTEBOOK_RUNNER.addTest({
180+
name: 'Regression test to re-embed graphics on property changes',
181+
fn: RunPlotRegressionNotebook,
182+
});
183+
184+
NOTEBOOK_RUNNER.addTest({
185+
name: 'Stack trace decorations on execution halted #1',
167186
fn: NotebookCallStackDecorationsOnExecutionHalted1,
168187
});
169188

apps/client-e2e/src/tests/notebooks/run-envi-message-listener-test-notebook.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const CELL_OUTPUT: ICompareCellOutputs[] = [
1111
{
1212
idx: 0,
1313
success: true,
14-
mimeTypes: [],
14+
mimeTypes: ['text/plain'],
1515
},
1616
{
1717
idx: 1,
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { GetExtensionPath } from '@idl/shared';
2+
import { IDL_NOTEBOOK_MIME_TYPE } from '@idl/types/notebooks';
3+
4+
import { RunnerFunction } from '../runner.interface';
5+
import { ICompareCellOutputs } from './helpers/compare-cells.interface';
6+
import { RunNotebookAndCompareCells } from './helpers/run-notebook-and-compare-cells';
7+
8+
/**
9+
* Types of outputs from cells that we expect to have
10+
*/
11+
export const CELL_OUTPUT: ICompareCellOutputs[] = [
12+
{
13+
idx: 0,
14+
success: true,
15+
mimeTypes: [],
16+
},
17+
{
18+
idx: 1,
19+
success: true,
20+
mimeTypes: [IDL_NOTEBOOK_MIME_TYPE, IDL_NOTEBOOK_MIME_TYPE],
21+
},
22+
{
23+
idx: 2,
24+
success: true,
25+
mimeTypes: [IDL_NOTEBOOK_MIME_TYPE],
26+
},
27+
{
28+
idx: 3,
29+
success: true,
30+
mimeTypes: ['text/plain'],
31+
},
32+
{
33+
idx: 4,
34+
success: true,
35+
mimeTypes: [],
36+
},
37+
];
38+
39+
/**
40+
* Function that makes sure we can embed multiple graphics from one
41+
* cell when we start ENVI
42+
*
43+
* Also makes sure we embed direct graphics when the ENVI Ui is hidden
44+
*/
45+
export const RunENVIMultiPlotNotebook: RunnerFunction = async (init) => {
46+
await RunNotebookAndCompareCells(
47+
GetExtensionPath('idl/test/client-e2e/notebooks/envi-multi-plot.idlnb'),
48+
CELL_OUTPUT,
49+
init.notebooks.controller
50+
);
51+
};
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { GetExtensionPath } from '@idl/shared';
2+
import { IDL_NOTEBOOK_MIME_TYPE } from '@idl/types/notebooks';
3+
4+
import { RunnerFunction } from '../runner.interface';
5+
import { ICompareCellOutputs } from './helpers/compare-cells.interface';
6+
import { RunNotebookAndCompareCells } from './helpers/run-notebook-and-compare-cells';
7+
8+
/**
9+
* Types of outputs from cells that we expect to have
10+
*/
11+
export const CELL_OUTPUT: ICompareCellOutputs[] = [
12+
{
13+
idx: 0,
14+
success: true,
15+
mimeTypes: [IDL_NOTEBOOK_MIME_TYPE],
16+
},
17+
{
18+
idx: 1,
19+
success: true,
20+
mimeTypes: [IDL_NOTEBOOK_MIME_TYPE],
21+
},
22+
];
23+
24+
/**
25+
* Function that makes sure plots behave as we expect and get re-embedded
26+
* on property change
27+
*/
28+
export const RunPlotRegressionNotebook: RunnerFunction = async (init) => {
29+
await RunNotebookAndCompareCells(
30+
GetExtensionPath('idl/test/client-e2e/notebooks/plot-regression.idlnb'),
31+
CELL_OUTPUT,
32+
init.notebooks.controller
33+
);
34+
};

apps/client-e2e/src/tests/notebooks/run-test-envi-map-notebook.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const CELL_OUTPUT: ICompareCellOutputs[] = [
1212
{
1313
idx: 0,
1414
success: true,
15-
mimeTypes: [],
15+
mimeTypes: ['text/plain'],
1616
},
1717
{
1818
idx: 1,

apps/client-e2e/src/tests/runner.class.ts

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Logger } from '@idl/logger';
22
import { Sleep } from '@idl/shared';
33
import { GetWorkspaceConfig } from '@idl/vscode/config';
44
import { arch, platform } from 'os';
5+
import { performance } from 'perf_hooks';
56
import * as vscode from 'vscode';
67

78
import { ACTIVATION_RESULT } from '../main';
@@ -77,6 +78,15 @@ export class Runner {
7778
// get the current workspace config
7879
const config = GetWorkspaceConfig();
7980

81+
/** Get start time */
82+
const t0 = performance.now();
83+
84+
/** Get the number of tests */
85+
const nTests = this.tests.length;
86+
87+
// alert user
88+
this.logger.info(`Preparing to run ${nTests} tests`);
89+
8090
// run all of our tests
8191
for (let i = 0; i < this.tests.length; i++) {
8292
try {
@@ -87,7 +97,7 @@ export class Runner {
8797
}
8898

8999
// log test we are starting
90-
this.logger.info(this.tests[i].name);
100+
this.logger.info(`(${i + 1}/${nTests}) ${this.tests[i].name}`);
91101

92102
// attempt to run test
93103
await this.tests[i].fn(ACTIVATION_RESULT);
@@ -131,6 +141,14 @@ export class Runner {
131141
}
132142
}
133143

144+
// alert users
145+
this.logger.info([
146+
`Finished running tests in ${Math.ceil(
147+
(performance.now() - t0) / 1000
148+
)} seconds with ${failures} failed tests`,
149+
'',
150+
]);
151+
134152
return failures;
135153
}
136154

@@ -141,11 +159,35 @@ export class Runner {
141159
/** Initialize failures */
142160
let failures = 0;
143161

162+
/** Track total tests */
163+
let total = 0;
164+
165+
/** Get start time */
166+
const t0 = performance.now();
167+
168+
// alert user
169+
this.logger.info([
170+
`Running tests for ${this.runners.length} test runners`,
171+
'',
172+
]);
173+
144174
// run all of our tests - no need for try/catch, handled internally below
145175
for (let i = 0; i < this.runners.length; i++) {
176+
// update total
177+
total += this.runners[i].tests.length;
178+
179+
// run and track failures
146180
failures += await this.runners[i].runOurTests();
147181
}
148182

183+
// alert user
184+
this.logger.info([
185+
`Finished running all tests in ${Math.ceil(
186+
(performance.now() - t0) / 1000
187+
)} seconds with ${failures} failed tests`,
188+
{ total, failures },
189+
]);
190+
149191
return failures;
150192
}
151193
}

apps/vscode-e2e-runner/src/main.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import { runTests } from '@vscode/test-electron';
22
import { join } from 'path';
3-
import { performance } from 'perf_hooks';
43

54
async function go() {
6-
/** Get start time */
7-
const t0 = performance.now();
8-
95
try {
106
/** Development folder, hover help below in runTests */
117
const extensionDevelopmentPath = process.cwd();
@@ -26,9 +22,7 @@ async function go() {
2622
extensionDevelopmentPath,
2723
extensionTestsPath,
2824
});
29-
console.log(`Finished running tests in ${performance.now() - t0} ms`);
3025
} catch (err) {
31-
console.log(`Finished running tests in ${performance.now() - t0} ms`);
3226
console.error('Failed to run tests');
3327
process.exit(1);
3428
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"version": "2.0.0",
3+
"cells": [
4+
{
5+
"type": "code",
6+
"content": [
7+
"; start ENVI headlessly",
8+
"e = envi(/headless)"
9+
],
10+
"metadata": {},
11+
"outputs": []
12+
},
13+
{
14+
"type": "code",
15+
"content": [
16+
"p = plot(/test)",
17+
"p = plot(/test)"
18+
],
19+
"metadata": {},
20+
"outputs": []
21+
},
22+
{
23+
"type": "code",
24+
"content": [
25+
"plot, findgen(10)"
26+
],
27+
"metadata": {},
28+
"outputs": []
29+
},
30+
{
31+
"type": "code",
32+
"content": [
33+
"; close ENVI and re-open the UI",
34+
"e.close",
35+
"e = envi()"
36+
],
37+
"metadata": {},
38+
"outputs": []
39+
},
40+
{
41+
"type": "code",
42+
"content": [
43+
"; dont embed direct graphics",
44+
"plot, findgen(10)"
45+
],
46+
"metadata": {},
47+
"outputs": []
48+
}
49+
]
50+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"version": "2.0.0",
3+
"cells": [
4+
{
5+
"type": "code",
6+
"content": [
7+
"p = plot(/test)"
8+
],
9+
"metadata": {},
10+
"outputs": []
11+
},
12+
{
13+
"type": "code",
14+
"content": [
15+
"; re-embed graphic when it chagnes",
16+
"p.color = 'red'"
17+
],
18+
"metadata": {},
19+
"outputs": []
20+
}
21+
]
22+
}

0 commit comments

Comments
 (0)