mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-21 00:59:03 +01:00
Add test for new execution behavior
This commit is contained in:
@@ -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', () => {
|
||||
|
||||
Reference in New Issue
Block a user