Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fail with more info #175814

Merged
merged 2 commits into from Mar 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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
Expand All @@ -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`);

Expand Down