Add test for new execution behavior

This commit is contained in:
Rob Lourens
2021-12-17 14:57:41 -08:00
parent 73bd5f437a
commit 962a6c85e8

View File

@@ -872,6 +872,63 @@ suite('Notebook API tests', function () {
assert.strictEqual(cell.executionSummary?.timing?.endTime, 20);
});
test.skip('execution cancelled when delete while executing', async () => {
const document = await openRandomNotebookDocument();
const cell = document.cellAt(0);
let executionWasCancelled = false;
const cancelledKernel = new class extends Kernel {
constructor() {
super('cancelledKernel', '');
}
override async _execute(cells: vscode.NotebookCell[]) {
console.log(`execute`);
const [cell] = cells;
const exe = this.controller.createNotebookCellExecution(cell);
exe.token.onCancellationRequested(() => executionWasCancelled = true);
}
};
const notebook = await openRandomNotebookDocument();
await vscode.window.showNotebookDocument(notebook);
await assertKernel(cancelledKernel, notebook);
await vscode.commands.executeCommand('notebook.cell.execute');
// Delete executing cell
const edit = new vscode.WorkspaceEdit();
edit.replaceNotebookCells(cell!.notebook.uri, new vscode.NotebookRange(cell!.index, cell!.index + 1), []);
await vscode.workspace.applyEdit(edit);
assert.strictEqual(executionWasCancelled, true);
});
test('execution cancelled when kernel changed', async () => {
await openRandomNotebookDocument();
let executionWasCancelled = false;
const cancelledKernel = new class extends Kernel {
constructor() {
super('cancelledKernel', '');
}
override async _execute(cells: vscode.NotebookCell[]) {
console.log(`execute`);
const [cell] = cells;
const exe = this.controller.createNotebookCellExecution(cell);
exe.token.onCancellationRequested(() => executionWasCancelled = true);
}
};
const notebook = await openRandomNotebookDocument();
await vscode.window.showNotebookDocument(notebook);
await assertKernel(cancelledKernel, notebook);
await vscode.commands.executeCommand('notebook.cell.execute');
const newKernel = new Kernel('newKernel', 'kernel');
await assertKernel(newKernel, notebook);
assert.strictEqual(executionWasCancelled, true);
});
});
suite('statusbar', () => {