mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
fail with more info
This commit is contained in:
parent
61a2399c23
commit
869f18c010
|
@ -30,16 +30,25 @@ async function addCell(code: string, notebook: vscode.NotebookDocument) {
|
|||
const edit = vscode.NotebookEdit.insertCells(notebook.cellCount, [cell]);
|
||||
const workspaceEdit = new vscode.WorkspaceEdit();
|
||||
workspaceEdit.set(notebook.uri, [edit]);
|
||||
const event = asPromise(vscode.workspace.onDidChangeNotebookDocument);
|
||||
await vscode.workspace.applyEdit(workspaceEdit);
|
||||
await event;
|
||||
return notebook.cellAt(notebook.cellCount - 1);
|
||||
}
|
||||
|
||||
async function addCellAndRun(code: string, notebook: vscode.NotebookDocument, i: number) {
|
||||
async function addCellAndRun(code: string, notebook: vscode.NotebookDocument) {
|
||||
const initialCellCount = notebook.cellCount;
|
||||
const cell = await addCell(code, notebook);
|
||||
|
||||
const event = asPromise(vscode.workspace.onDidChangeNotebookDocument);
|
||||
await vscode.commands.executeCommand('notebook.cell.execute', { start: i, end: i + 1 }, notebook.uri);
|
||||
await event;
|
||||
assert.strictEqual(cell.outputs.length, 1, 'execute failed');
|
||||
await vscode.commands.executeCommand('notebook.cell.execute', { start: initialCellCount, end: initialCellCount + 1 }, notebook.uri);
|
||||
try {
|
||||
await event;
|
||||
} catch (e) {
|
||||
const result = notebook.cellAt(notebook.cellCount - 1);
|
||||
assert.fail(`Notebook change event was not triggered after executing newly added cell. Initial Cell count: ${initialCellCount}. Current cell count: ${notebook.cellCount}. execution summary: ${JSON.stringify(result.executionSummary)}`);
|
||||
}
|
||||
assert.strictEqual(cell.outputs.length, 1, `Executed cell has no output. Initial Cell count: ${initialCellCount}. Current cell count: ${notebook.cellCount}. execution summary: ${JSON.stringify(cell.executionSummary)}`);
|
||||
return cell;
|
||||
}
|
||||
|
||||
|
@ -86,7 +95,7 @@ async function addCellAndRun(code: string, notebook: vscode.NotebookDocument, i:
|
|||
|
||||
// Run and add a bunch of cells
|
||||
for (let i = 0; i < 10; i++) {
|
||||
await addCellAndRun(`print ${i}`, notebookEditor.notebook, i);
|
||||
await addCellAndRun(`print ${i}`, notebookEditor.notebook);
|
||||
}
|
||||
|
||||
// Verify visible range has the last cell
|
||||
|
@ -105,7 +114,7 @@ async function addCellAndRun(code: string, notebook: vscode.NotebookDocument, i:
|
|||
assert.ok(notebookEditor);
|
||||
|
||||
// Verify the kernel is the secondary one
|
||||
await addCellAndRun(`print`, notebookEditor.notebook, 0);
|
||||
await addCellAndRun(`print`, notebookEditor.notebook);
|
||||
|
||||
assert.strictEqual(secondKernel.associatedNotebooks.has(notebookEditor.notebook.uri.toString()), true, `Secondary kernel was not set as the kernel for the interactive window`);
|
||||
|
||||
|
|
Loading…
Reference in a new issue