Skip to content

Commit 82d9e5e

Browse files
Centralize timeout for running notebooks
1 parent 8e61eb7 commit 82d9e5e

9 files changed

Lines changed: 24 additions & 53 deletions
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/**
2+
* Default timeout, ms, for notebooks pause
3+
*/
4+
export const DEFAULT_RUNNER_NOTEBOOK_TIMEOUT = 250;

apps/client-e2e/src/tests/notebooks/helpers/run-notebook-and-compare-cells.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ import * as vscode from 'vscode';
88

99
import { CompareCellOutputs } from './compare-cells';
1010
import { ICompareCellOutputs } from './compare-cells.interface';
11-
12-
/**
13-
* Default timeout, ms
14-
*/
15-
export const DEFAULT_RUNNER_TIMEOUT = 250;
11+
import { DEFAULT_RUNNER_NOTEBOOK_TIMEOUT } from './notebook-timeout.interface';
1612

1713
/**
1814
* helper function to:
@@ -28,7 +24,6 @@ export async function RunNotebookAndCompareCells(
2824
file: string,
2925
cells: ICompareCellOutputs[],
3026
controller: IDLNotebookController,
31-
timeout: number,
3227
clear = true
3328
) {
3429
// nuke .idl folder if it exists
@@ -59,7 +54,7 @@ export async function RunNotebookAndCompareCells(
5954
// short pause based on the number of cells we have
6055
// sometimes the rendering takes too long to register (like complex maps)
6156
// so we need an extra pause
62-
await Sleep(timeout);
57+
await Sleep(DEFAULT_RUNNER_NOTEBOOK_TIMEOUT);
6358

6459
// compare cells
6560
await CompareCellOutputs(nb, cells);

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ import { GetExtensionPath } from '@idl/shared';
22

33
import { RunnerFunction } from '../runner.interface';
44
import { ICompareCellOutputs } from './helpers/compare-cells.interface';
5-
import {
6-
DEFAULT_RUNNER_TIMEOUT,
7-
RunNotebookAndCompareCells,
8-
} from './helpers/run-notebook-and-compare-cells';
5+
import { RunNotebookAndCompareCells } from './helpers/run-notebook-and-compare-cells';
96

107
/**
118
* Types of outputs from cells that we expect to have
@@ -59,7 +56,6 @@ export const RunENVIMessageListenerTestNotebook: RunnerFunction = async (
5956
'idl/test/client-e2e/notebooks/envi-message-listener.idlnb'
6057
),
6158
CELL_OUTPUT,
62-
init.notebooks.controller,
63-
DEFAULT_RUNNER_TIMEOUT
59+
init.notebooks.controller
6460
);
6561
};

apps/client-e2e/src/tests/notebooks/run-problem-notebooks.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import { GetExtensionPath } from '@idl/shared';
22

33
import { RunnerFunction } from '../runner.interface';
4-
import {
5-
DEFAULT_RUNNER_TIMEOUT,
6-
RunNotebookAndCompareCells,
7-
} from './helpers/run-notebook-and-compare-cells';
4+
import { RunNotebookAndCompareCells } from './helpers/run-notebook-and-compare-cells';
85

96
/**
107
* Function that verifies that we can do basic debugging of IDL sessions
@@ -38,8 +35,7 @@ export const RunProblemNotebooks: RunnerFunction = async (init) => {
3835
mimeTypes: [],
3936
},
4037
],
41-
init.notebooks.controller,
42-
DEFAULT_RUNNER_TIMEOUT
38+
init.notebooks.controller
4339
);
4440

4541
/**
@@ -55,8 +51,7 @@ export const RunProblemNotebooks: RunnerFunction = async (init) => {
5551
mimeTypes: [],
5652
},
5753
],
58-
init.notebooks.controller,
59-
DEFAULT_RUNNER_TIMEOUT
54+
init.notebooks.controller
6055
);
6156

6257
/**
@@ -78,8 +73,7 @@ export const RunProblemNotebooks: RunnerFunction = async (init) => {
7873
mimeTypes: [],
7974
},
8075
],
81-
init.notebooks.controller,
82-
DEFAULT_RUNNER_TIMEOUT
76+
init.notebooks.controller
8377
);
8478

8579
/**
@@ -102,7 +96,6 @@ export const RunProblemNotebooks: RunnerFunction = async (init) => {
10296
mimeTypes: [],
10397
},
10498
],
105-
init.notebooks.controller,
106-
DEFAULT_RUNNER_TIMEOUT
99+
init.notebooks.controller
107100
);
108101
};

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ import { IDL_NOTEBOOK_MIME_TYPE } from '@idl/types/notebooks';
33

44
import { RunnerFunction } from '../runner.interface';
55
import { ICompareCellOutputs } from './helpers/compare-cells.interface';
6-
import {
7-
DEFAULT_RUNNER_TIMEOUT,
8-
RunNotebookAndCompareCells,
9-
} from './helpers/run-notebook-and-compare-cells';
6+
import { RunNotebookAndCompareCells } from './helpers/run-notebook-and-compare-cells';
107

118
/**
129
* Types of outputs from cells that we expect to have
@@ -68,7 +65,6 @@ export const RunTestENVIMapNotebook: RunnerFunction = async (init) => {
6865
'idl/test/client-e2e/notebooks/test-notebook-envi-maps.idlnb'
6966
),
7067
CELL_OUTPUT,
71-
init.notebooks.controller,
72-
DEFAULT_RUNNER_TIMEOUT
68+
init.notebooks.controller
7369
);
7470
};

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ import { IDL_NOTEBOOK_MIME_TYPE } from '@idl/types/notebooks';
33

44
import { RunnerFunction } from '../runner.interface';
55
import { ICompareCellOutputs } from './helpers/compare-cells.interface';
6-
import {
7-
DEFAULT_RUNNER_TIMEOUT,
8-
RunNotebookAndCompareCells,
9-
} from './helpers/run-notebook-and-compare-cells';
6+
import { RunNotebookAndCompareCells } from './helpers/run-notebook-and-compare-cells';
107

118
/**
129
* Types of outputs from cells that we expect to have
@@ -86,7 +83,6 @@ export const RunTestENVINotebook: RunnerFunction = async (init) => {
8683
await RunNotebookAndCompareCells(
8784
GetExtensionPath('idl/test/client-e2e/notebooks/envi-test-notebook.idlnb'),
8885
CELL_OUTPUT,
89-
init.notebooks.controller,
90-
DEFAULT_RUNNER_TIMEOUT
86+
init.notebooks.controller
9187
);
9288
};

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ import { IDL_NOTEBOOK_MIME_TYPE } from '@idl/types/notebooks';
33

44
import { RunnerFunction } from '../runner.interface';
55
import { ICompareCellOutputs } from './helpers/compare-cells.interface';
6-
import {
7-
DEFAULT_RUNNER_TIMEOUT,
8-
RunNotebookAndCompareCells,
9-
} from './helpers/run-notebook-and-compare-cells';
6+
import { RunNotebookAndCompareCells } from './helpers/run-notebook-and-compare-cells';
107

118
/**
129
* Types of outputs from cells that we expect to have
@@ -96,7 +93,6 @@ export const RunTestNotebook: RunnerFunction = async (init) => {
9693
GetExtensionPath('idl/test/client-e2e/notebooks/test-notebook.idlnb'),
9794
CELL_OUTPUT,
9895
init.notebooks.controller,
99-
DEFAULT_RUNNER_TIMEOUT,
10096
false
10197
);
10298
};

apps/client-e2e/src/tests/notebooks/run-unsaved-notebook.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as vscode from 'vscode';
66
import { RunnerFunction } from '../runner.interface';
77
import { CompareCellOutputs } from './helpers/compare-cells';
88
import { ICompareCellOutputs } from './helpers/compare-cells.interface';
9-
import { DEFAULT_RUNNER_TIMEOUT } from './helpers/run-notebook-and-compare-cells';
9+
import { DEFAULT_RUNNER_NOTEBOOK_TIMEOUT } from './helpers/notebook-timeout.interface';
1010

1111
/**
1212
* Types of outputs from cells that we expect to have
@@ -42,7 +42,7 @@ export const RunUnsavedNotebook: RunnerFunction = async (init) => {
4242
);
4343

4444
// short pause
45-
await Sleep(DEFAULT_RUNNER_TIMEOUT);
45+
await Sleep(DEFAULT_RUNNER_NOTEBOOK_TIMEOUT);
4646

4747
// get active editor
4848
const editor = vscode.window.activeNotebookEditor;
@@ -65,7 +65,7 @@ export const RunUnsavedNotebook: RunnerFunction = async (init) => {
6565
// short pause based on the number of cells we have
6666
// sometimes the rendering takes too long to register (like complex maps)
6767
// so we need an extra pause
68-
await Sleep(DEFAULT_RUNNER_TIMEOUT);
68+
await Sleep(DEFAULT_RUNNER_NOTEBOOK_TIMEOUT);
6969

7070
// compare cells
7171
await CompareCellOutputs(nb, CELL_OUTPUT);

apps/client-e2e/src/tests/notebooks/verify-quiet-notebook-setting.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ import * as vscode from 'vscode';
66

77
import { RunnerFunction } from '../runner.interface';
88
import { ICompareCellOutputs } from './helpers/compare-cells.interface';
9-
import {
10-
DEFAULT_RUNNER_TIMEOUT,
11-
RunNotebookAndCompareCells,
12-
} from './helpers/run-notebook-and-compare-cells';
9+
import { RunNotebookAndCompareCells } from './helpers/run-notebook-and-compare-cells';
1310

1411
/**
1512
* Types of outputs from cells that we expect to have
@@ -51,8 +48,7 @@ export const VerifyQuietNotebookSetting: RunnerFunction = async (init) => {
5148
await RunNotebookAndCompareCells(
5249
GetExtensionPath('idl/test/client-e2e/notebooks/quiet-preference.idlnb'),
5350
QUIET_OUTPUT,
54-
init.notebooks.controller,
55-
DEFAULT_RUNNER_TIMEOUT
51+
init.notebooks.controller
5652
);
5753

5854
// turn off
@@ -75,8 +71,7 @@ export const VerifyQuietNotebookSetting: RunnerFunction = async (init) => {
7571
await RunNotebookAndCompareCells(
7672
GetExtensionPath('idl/test/client-e2e/notebooks/quiet-preference.idlnb'),
7773
NOT_QUIET_OUTPUT,
78-
init.notebooks.controller,
79-
DEFAULT_RUNNER_TIMEOUT
74+
init.notebooks.controller
8075
);
8176

8277
// turn on again

0 commit comments

Comments
 (0)