Skip to content

Commit 2b21593

Browse files
pokeypre-commit-ci[bot]AndreasArvidsson
authored
Add cursorless-talon-dev (#1017)
* Add cursorless-talon-dev * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Tweaks * More tweaks * Woops Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Andreas Arvidsson <andreas.arvidsson87@gmail.com>
1 parent 76df94a commit 2b21593

File tree

7 files changed

+112
-58
lines changed

7 files changed

+112
-58
lines changed

.vscode/tasks.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,21 @@
5050
"cwd": "cursorless-nx"
5151
},
5252
"problemMatcher": []
53+
},
54+
{
55+
"label": "Install local",
56+
"type": "shell",
57+
"command": "vsce package -o bundle.vsix && code --install-extension bundle.vsix",
58+
"presentation": {
59+
"focus": true
60+
},
61+
"problemMatcher": []
62+
},
63+
{
64+
"label": "Run pre commit",
65+
"type": "shell",
66+
"command": "pre-commit run",
67+
"presentation": {}
5368
}
5469
]
5570
}

cursorless-talon-dev/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# `cursorless-talon-dev`
2+
3+
This directory contains voice commands to use while developing Cursorless. See https://www.cursorless.org/docs/contributing/ for more about how to contribute to Cursorless.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from talon import Module, actions
2+
3+
mod = Module()
4+
5+
6+
@mod.action_class
7+
class Actions:
8+
def cursorless_record_navigation_test():
9+
"""Start / stop recording Cursorless navigation tests"""
10+
actions.user.run_rpc_command(
11+
"cursorless.recordTestCase", {"isHatTokenMapTest": True}
12+
)
13+
14+
def cursorless_record_error_test():
15+
"""Start recording Cursorless error tests"""
16+
actions.user.run_rpc_command(
17+
"cursorless.recordTestCase", {"recordErrors": True}
18+
)
19+
20+
def cursorless_record_highlights_test():
21+
"""Start recording Cursorless decoration tests"""
22+
actions.user.run_rpc_command(
23+
"cursorless.recordTestCase", {"isDecorationsTest": True}
24+
)
25+
26+
def cursorless_record_that_mark_test():
27+
"""Start recording Cursorless that mark tests"""
28+
actions.user.run_rpc_command(
29+
"cursorless.recordTestCase", {"captureFinalThatMark": True}
30+
)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
tag: user.cursorless
2+
-
3+
4+
{user.cursorless_homophone} record: user.run_rpc_command("cursorless.recordTestCase")
5+
{user.cursorless_homophone} pause: user.run_rpc_command("cursorless.pauseRecording")
6+
{user.cursorless_homophone} resume: user.run_rpc_command("cursorless.resumeRecording")
7+
8+
{user.cursorless_homophone} record navigation:
9+
user.cursorless_record_navigation_test()
10+
{user.cursorless_homophone} record error: user.cursorless_record_error_test()
11+
{user.cursorless_homophone} record highlights:
12+
user.cursorless_record_highlights_test()
13+
{user.cursorless_homophone} record that mark:
14+
15+
{user.cursorless_homophone} update cheatsheet:
16+
user.cursorless_cheat_sheet_update_json()
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
app: vscode
2+
-
3+
^install local$:
4+
user.vscode_with_plugin("workbench.action.tasks.runTask", "Install local")
5+
^pre commit run$:
6+
user.vscode_with_plugin("workbench.action.tasks.runTask", "Run pre commit")
7+
8+
^serve start$:
9+
user.vscode_with_plugin("workbench.action.tasks.runTask", "Serve cursorless.org")
10+
^serve stop$:
11+
user.vscode("workbench.action.tasks.terminate")
12+
insert("Serve")
13+
key(enter)

docs/contributing/CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ extension](#running--testing-extension-locally), you may want to check out the
2727

2828
The `yarn init-launch-sandbox` command creates a local sandbox containing a specific set of VSCode extensions that will be run alongside Cursorless when you launch Cursorless in debug or test mode. Please file an issue if you'd like to use additional extensions when debugging locally.
2929

30+
4. Copy / symlink `cursorless-talon-dev` into your Talon user directory for some useful voice commands for developing Cursorless.
31+
3032
## Running / testing extension locally
3133

3234
In order to test out your local version of the extension or to run unit tests

docs/contributing/test-case-recorder.md

Lines changed: 33 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -8,70 +8,13 @@ recording the initial state of the file including cursor position(s), the
88
command run, and the final state, all in the form of a yaml document. See
99
[existing test cases](../../src/test/suite/fixtures/recorded) for example outputs.
1010

11-
## Initial setup
12-
13-
Add a voice command for recording to your personal talon files:
14-
15-
```talon
16-
cursorless record: user.vscode("cursorless.recordTestCase")
17-
```
18-
19-
We don't want to commit this so please add it to your own Talon user file set.
20-
21-
### Configuring the test case Recorder
22-
23-
The test case recorder has several additional configuration options. The default configuration works for most tests, but you may find the following useful. For a full list of supported configuration options, see [the api docs](../api/interfaces/testutil_testcaserecorder.internal.recordtestcasecommandarg/).
24-
25-
#### Testing the hat map
26-
27-
We have a way to test that the hats in the hat map update correctly during the course of a single phrase. These tests are also how we usually test our [range updating code](../api/modules/core_updateSelections_updateSelections).
28-
29-
Any tests recorded in the `hatTokenMap` directory will automatically be treated as hat token map tests. To initiate a series of hat token map tests in another directory, please add the following to your personal talon files:
30-
31-
- https://github.com/pokey/pokey_talon/blob/9298c25dd6d28fd9fcf5ed39f305bc6b93e5f229/apps/vscode/vscode.talon#L468
32-
- https://github.com/pokey/pokey_talon/blob/49643bfa8f62cbec18b5ddad1658f5a28785eb01/apps/vscode/vscode.py#L203-L205
33-
34-
When recording each test case for the hat token map, you'll need to proceed as described in [Navigation map tests](#navigation-map-tests).
35-
36-
#### Capturing errors
37-
38-
We support recording tests where the expected result is an error
39-
40-
Please add a command to your personal talon files. See the two files links above for context. Add the command below to your to your `vscode.py` and ensure that there is a matching Talon command.
41-
42-
```
43-
actions.user.vscode_with_plugin("cursorless.recordTestCase", {"recordErrors": True})
44-
```
45-
46-
#### Testing decoration highlights
47-
48-
We support testing our decoration highlights, eg the flash of red when something is deleted. If you record tests into the `decorations/` directory, these will automatically be captured.
49-
50-
If you'd like to record decorations when recording into a different directory, please add another command to your personal talon files. See the two files links above for context. Add the command below to your to your `vscode.py` and ensure that there is a matching Talon command.
51-
52-
```
53-
actions.user.vscode_with_plugin("cursorless.recordTestCase", {"isDecorationsTest": True})
54-
```
55-
56-
#### Testing the returned `that` mark
57-
58-
By default, we don't capture the `that` mark returned by a command, unless the test is being recorded in the `actions/` directory of the recorded tests. If you'd like to capture the returned `that` mark when recording a test somewhere else, you can do something like
59-
60-
```
61-
actions.user.vscode_with_plugin("cursorless.recordTestCase", {"captureFinalThatMark": True})
62-
```
63-
64-
### Default config per test case directory
65-
66-
Any test case directory that contains a `config.json` will set default configuration for all tests recorded in any descendant directory. For example, the file [`actions/config.json`](../../src/test/suite/fixtures/recorded/actions/config.json) makes it so that all our action tests will capture the final `that` mark. For a full list of keys supported in this json, see [the api docs](../api/interfaces/testutil_testcaserecorder.internal.recordtestcasecommandarg/).
67-
6811
## Recording new tests
6912

7013
1. Start debugging (F5)
7114
1. Create a minimal file to use for recording tests. And position your cursor
7215
where you'd like. Check out the `initialState.documentContents` field of
7316
[existing test cases](../../src/test/suite/fixtures/recorded) for examples.
74-
1. Issue the `"cursorless record"` command
17+
1. Issue the `"cursorless record"` command. Alternately, issue one of the special recording commands listed in
7518
- List of target directories is shown. All test cases will be put into the
7619
given subdirectory of `src/test/suite/fixtures/recorded`
7720
1. Select existing directory or create new one
@@ -90,6 +33,38 @@ Any test case directory that contains a `config.json` will set default configura
9033
- `Stopped recording test cases` is shown
9134
- You can also just stop the debugger or close the debug window
9235

36+
## Test case recorder options
37+
38+
The test case recorder has several additional configuration options. The default configuration works for most tests, but you may find the following useful. For a full list of supported configuration options, see [the api docs](../api/interfaces/testutil_testcaserecorder.internal.recordtestcasecommandarg/).
39+
40+
### The options
41+
42+
#### Capturing errors
43+
44+
We support recording tests where the expected result is an error. This can be done using the command `"cursorless record error"`.
45+
46+
#### Testing decoration highlights
47+
48+
We support testing our decoration highlights, eg the flash of red when something is deleted. If you record tests into the `decorations/` directory, these will automatically be captured.
49+
50+
If you'd like to record decorations when recording into a different directory, you can say `"cursorless record highlights"`.
51+
52+
#### Testing the returned `that` mark
53+
54+
By default, we don't capture the `that` mark returned by a command, unless the test is being recorded in the `actions/` directory of the recorded tests. If you'd like to capture the returned `that` mark when recording a test somewhere else, you can say `"cursorless record that mark"`.
55+
56+
#### Testing the hat map
57+
58+
We have a way to test that the hats in the hat map update correctly during the course of a single phrase. These tests are also how we usually test our [range updating code](../api/modules/core_updateSelections_updateSelections).
59+
60+
Any tests recorded in the `hatTokenMap` directory will automatically be treated as hat token map tests. To initiate a series of hat token map tests in another directory, say `"cursorless record navigation"`.
61+
62+
Then each time you record a test, you need to issue two commands. The second command should be of the form `"take air"` (or another decorated mark), and will tell the test case recorder which decorated mark you're checking.
63+
64+
### Default config per test case directory
65+
66+
Any test case directory that contains a `config.json` will set default configuration for all tests recorded in any descendant directory. For example, the file [`actions/config.json`](../../src/test/suite/fixtures/recorded/actions/config.json) makes it so that all our action tests will capture the final `that` mark. For a full list of keys supported in this json, see [the api docs](../api/interfaces/testutil_testcaserecorder.internal.recordtestcasecommandarg/).
67+
9368
### Navigation map tests
9469

9570
If you want to check how the navigation map gets updated in response to changes, you can instead say "cursorless record navigation", and then you need to issue two commands in one phrase each time. The second command should be of the form "take air" (or another decorated mark), and will tell the test case recorder which decorated mark we're checking.

0 commit comments

Comments
 (0)