* Return NotebookEditor from `interactive.open` command
This allows extensions to obtain a reference to the embedded
NotebookEditor at creation. Otherwise extensions must look
through window.visibleNotebookEditors to obtain a reference
to the NotebookEditor and call revealRange for scrolling,
and window.visibleNotebookEditors may change in future.
Co-authored-by: rebornix <penn.lv@gmail.com>
* process argument label
Co-authored-by: rebornix <penn.lv@gmail.com>
- rename TestController.createRunConfiguration to .createRunProfile, and associated types
- rename TestItemCollection.remove to TestItemCollection.delete
* first pass at adding api
(cherry picked from commit 8a583c52ee)
* add task2 remaining changes
* remove unnecessary changes
* modify tasks.json directly for test
* reset tasks in test
* Fix compilation errors
Co-authored-by: Alex Ross <alros@microsoft.com>
This changeset results from the discussion in and fixes#126987.
Migration for these changes should take about 15-20 minutes.
- `createTestItem` no longer takes a parent. Instead, it creates a free-
floating test item, which can be added as a child of a parent.
- The `TestItem.children` is now a `TestItemCollection`, a set-like
interface that also allows replacing items (intelligently diffing
them internally) wholesale. This removes the need for the "generation
counter" used in samples previously.
- There is no longer a `root` on the test controller, but instead an
`items` property which is the same `TestItemCollection`
- The `tests` in the `TestRunRequest` has been replaced with an `include`
property. If undefined, the extension should run all tests. (Since
there is no longer a root to reference).
Here's some example migrations:
- 3fad3d66c1
- 3aff746316
See https://github.com/microsoft/vscode/issues/126987#issuecomment-867031454
This commit makes the following changes:
- Keep the `resolveChildrenHandler`, and remove the CancellationToken parameter
- Remove `TestITem.status` and instead have `TestItem.canResolveChildren?: boolean`
- Add `TestItem.busy?: boolean`. Note that the UI would implicitly show
the item as busy while `resolve` is being called. (This is a new feature)
Upgrading to account for these changes should take around 10 to 20 minutes:
1. Where you previously set `item.status = vscode.TestItemStatus.Pending`,
instead set `item.canResolveChildren = true`.
2. If you used the cancellation token in resolveChildrenHandler, you no
longer need to do so. What you do here instead is up to you:
- If you set up global workspace watchers, add those to `context.subscriptions`
- You _probably_ don't need to set up watchers for "file" test items,
since you will receive updates via `vscode.workspace.onDidChangeTextDocument`
and/or any FileWatcher you have set up.
Example of an update: 7287c64bf7
Previously in the testing API, you called `registerTestProvider` with
your own instance of a TestController, and VS Code would request
workspace or document tests. This has been changed: now, you call
`createTestController`, which returns an object, and call
`createTestItem` to insert test nodes under the `controller.root`.
Extensions should generally decide themselves when to publish tests. For
example, when a file is opened in an editor, test extensions will want
to make sure tests for that file are available so that inline
decorations can be shown. This is pretty similar to what the editor
API does in diagnostics.
There is still a `resolveChildrenHandler` on the controller (rather than
the TestItem directly), which you should _set_ if the test extension
supports lazy discovery. Additionally, if you support running tests,
you'll also want a `runHandler` (migrating from the old `runTests` method).
Some of the existing test providers have been updated, you can check
them out here:
- https://github.com/microsoft/vscode-extension-samples/tree/main/test-provider-sample
- https://github.com/microsoft/vscode-selfhost-test-provider
In summary, to update to the new API:
- Call `vscode.test.createTestController` instead of `registerTestController`
- Move the contents of your `runTests` method to `controller.runHandler`
- Move your `TestItem.resolveHandler` to `controller.resolveChildrenHandler`,
which may involve adding some `instanceof` checks.
- If you lazily discovered tests in `createDocumentTestRoot`, you'll want
to trigger that logic based on `vscode.workspace.onDidOpenTextDocument`.
- If your test runner can deal with showing locations of unsaved changes,
listen for `vscode.workspace.onDidChangeTextDocument` to trigger those
changes in the tree.