retrovim 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (218) hide show
  1. package/.conda/retrovim.yaml +259 -0
  2. package/.conda/terax.icns +0 -0
  3. package/.conda/terax.ico +0 -0
  4. package/.conda/terax.png +0 -0
  5. package/.github/workflows/release.yml +95 -0
  6. package/.gitmodules +3 -0
  7. package/.npm/kanata_touchcursor.js +28 -0
  8. package/.npm/nvim.js +26 -0
  9. package/.npm/yazi.js +26 -0
  10. package/.npm/zsh.js +17 -0
  11. package/.pip/kanata_touchcursor/__init__.py +28 -0
  12. package/.pip/nvim/__init__.py +31 -0
  13. package/.pip/yazi/__init__.py +31 -0
  14. package/.pip/zsh/__init__.py +22 -0
  15. package/CHANGELOG.md +26 -0
  16. package/LICENSE +674 -0
  17. package/README.md +336 -0
  18. package/kanata/touchcursor.kbd +164 -0
  19. package/nvim/init.lua +813 -0
  20. package/nvim/plugins/mini.nvim/.github/DISCUSSION_TEMPLATE/q-a.yml +72 -0
  21. package/nvim/plugins/mini.nvim/.github/ISSUE_TEMPLATE/bug-report.yml +136 -0
  22. package/nvim/plugins/mini.nvim/.github/ISSUE_TEMPLATE/config.yml +5 -0
  23. package/nvim/plugins/mini.nvim/.github/ISSUE_TEMPLATE/feature-request.yml +75 -0
  24. package/nvim/plugins/mini.nvim/.github/PULL_REQUEST_TEMPLATE.md +2 -0
  25. package/nvim/plugins/mini.nvim/.github/workflows/quality-control.yml +150 -0
  26. package/nvim/plugins/mini.nvim/.pre-commit-config.yaml +20 -0
  27. package/nvim/plugins/mini.nvim/.stylua.toml +7 -0
  28. package/nvim/plugins/mini.nvim/.styluaignore +1 -0
  29. package/nvim/plugins/mini.nvim/CHANGELOG.md +1894 -0
  30. package/nvim/plugins/mini.nvim/CODE_OF_CONDUCT.md +132 -0
  31. package/nvim/plugins/mini.nvim/CONTRIBUTING.md +331 -0
  32. package/nvim/plugins/mini.nvim/LICENSE +21 -0
  33. package/nvim/plugins/mini.nvim/MAINTAINING.md +330 -0
  34. package/nvim/plugins/mini.nvim/Makefile +51 -0
  35. package/nvim/plugins/mini.nvim/README.md +261 -0
  36. package/nvim/plugins/mini.nvim/TESTING.md +1011 -0
  37. package/nvim/plugins/mini.nvim/benchmarks/starter/README.md +35 -0
  38. package/nvim/plugins/mini.nvim/benchmarks/starter/benchmark.sh +56 -0
  39. package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_dashboard-alpha.lua +21 -0
  40. package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_dashboard-original.lua +17 -0
  41. package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_dashboard-starter.lua +18 -0
  42. package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_empty.lua +4 -0
  43. package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_starter-default.lua +7 -0
  44. package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_startify-alpha.lua +10 -0
  45. package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_startify-original.lua +7 -0
  46. package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_startify-starter.lua +20 -0
  47. package/nvim/plugins/mini.nvim/benchmarks/starter/install.sh +10 -0
  48. package/nvim/plugins/mini.nvim/benchmarks/starter/make_summary.py +68 -0
  49. package/nvim/plugins/mini.nvim/benchmarks/starter/startup-summary.md +10 -0
  50. package/nvim/plugins/mini.nvim/colors/miniautumn.lua +55 -0
  51. package/nvim/plugins/mini.nvim/colors/minicyan.lua +95 -0
  52. package/nvim/plugins/mini.nvim/colors/minischeme.lua +95 -0
  53. package/nvim/plugins/mini.nvim/colors/minispring.lua +53 -0
  54. package/nvim/plugins/mini.nvim/colors/minisummer.lua +49 -0
  55. package/nvim/plugins/mini.nvim/colors/miniwinter.lua +51 -0
  56. package/nvim/plugins/mini.nvim/colors/randomhue.lua +16 -0
  57. package/nvim/plugins/mini.nvim/doc/mini-ai.txt +889 -0
  58. package/nvim/plugins/mini.nvim/doc/mini-align.txt +923 -0
  59. package/nvim/plugins/mini.nvim/doc/mini-animate.txt +937 -0
  60. package/nvim/plugins/mini.nvim/doc/mini-base16.txt +285 -0
  61. package/nvim/plugins/mini.nvim/doc/mini-basics.txt +359 -0
  62. package/nvim/plugins/mini.nvim/doc/mini-bracketed.txt +622 -0
  63. package/nvim/plugins/mini.nvim/doc/mini-bufremove.txt +123 -0
  64. package/nvim/plugins/mini.nvim/doc/mini-clue.txt +760 -0
  65. package/nvim/plugins/mini.nvim/doc/mini-cmdline.txt +392 -0
  66. package/nvim/plugins/mini.nvim/doc/mini-colors.txt +880 -0
  67. package/nvim/plugins/mini.nvim/doc/mini-comment.txt +230 -0
  68. package/nvim/plugins/mini.nvim/doc/mini-completion.txt +477 -0
  69. package/nvim/plugins/mini.nvim/doc/mini-cursorword.txt +105 -0
  70. package/nvim/plugins/mini.nvim/doc/mini-deps.txt +590 -0
  71. package/nvim/plugins/mini.nvim/doc/mini-diff.txt +661 -0
  72. package/nvim/plugins/mini.nvim/doc/mini-doc.txt +434 -0
  73. package/nvim/plugins/mini.nvim/doc/mini-extra.txt +856 -0
  74. package/nvim/plugins/mini.nvim/doc/mini-files.txt +1018 -0
  75. package/nvim/plugins/mini.nvim/doc/mini-fuzzy.txt +160 -0
  76. package/nvim/plugins/mini.nvim/doc/mini-git.txt +425 -0
  77. package/nvim/plugins/mini.nvim/doc/mini-hipatterns.txt +489 -0
  78. package/nvim/plugins/mini.nvim/doc/mini-hues.txt +420 -0
  79. package/nvim/plugins/mini.nvim/doc/mini-icons.txt +508 -0
  80. package/nvim/plugins/mini.nvim/doc/mini-indentscope.txt +485 -0
  81. package/nvim/plugins/mini.nvim/doc/mini-input.txt +932 -0
  82. package/nvim/plugins/mini.nvim/doc/mini-jump.txt +202 -0
  83. package/nvim/plugins/mini.nvim/doc/mini-jump2d.txt +525 -0
  84. package/nvim/plugins/mini.nvim/doc/mini-keymap.txt +449 -0
  85. package/nvim/plugins/mini.nvim/doc/mini-map.txt +717 -0
  86. package/nvim/plugins/mini.nvim/doc/mini-misc.txt +431 -0
  87. package/nvim/plugins/mini.nvim/doc/mini-move.txt +181 -0
  88. package/nvim/plugins/mini.nvim/doc/mini-notify.txt +434 -0
  89. package/nvim/plugins/mini.nvim/doc/mini-nvim.txt +431 -0
  90. package/nvim/plugins/mini.nvim/doc/mini-operators.txt +472 -0
  91. package/nvim/plugins/mini.nvim/doc/mini-pairs.txt +346 -0
  92. package/nvim/plugins/mini.nvim/doc/mini-pick.txt +1535 -0
  93. package/nvim/plugins/mini.nvim/doc/mini-sessions.txt +239 -0
  94. package/nvim/plugins/mini.nvim/doc/mini-snippets.txt +1291 -0
  95. package/nvim/plugins/mini.nvim/doc/mini-splitjoin.txt +536 -0
  96. package/nvim/plugins/mini.nvim/doc/mini-starter.txt +618 -0
  97. package/nvim/plugins/mini.nvim/doc/mini-statusline.txt +361 -0
  98. package/nvim/plugins/mini.nvim/doc/mini-surround.txt +863 -0
  99. package/nvim/plugins/mini.nvim/doc/mini-tabline.txt +151 -0
  100. package/nvim/plugins/mini.nvim/doc/mini-test.txt +966 -0
  101. package/nvim/plugins/mini.nvim/doc/mini-trailspace.txt +91 -0
  102. package/nvim/plugins/mini.nvim/doc/mini-visits.txt +937 -0
  103. package/nvim/plugins/mini.nvim/logo.png +0 -0
  104. package/nvim/plugins/mini.nvim/lua/mini/ai.lua +2244 -0
  105. package/nvim/plugins/mini.nvim/lua/mini/align.lua +2076 -0
  106. package/nvim/plugins/mini.nvim/lua/mini/animate.lua +2127 -0
  107. package/nvim/plugins/mini.nvim/lua/mini/base16.lua +1752 -0
  108. package/nvim/plugins/mini.nvim/lua/mini/basics.lua +772 -0
  109. package/nvim/plugins/mini.nvim/lua/mini/bracketed.lua +2013 -0
  110. package/nvim/plugins/mini.nvim/lua/mini/bufremove.lua +283 -0
  111. package/nvim/plugins/mini.nvim/lua/mini/clue.lua +2096 -0
  112. package/nvim/plugins/mini.nvim/lua/mini/cmdline.lua +1182 -0
  113. package/nvim/plugins/mini.nvim/lua/mini/colors.lua +2483 -0
  114. package/nvim/plugins/mini.nvim/lua/mini/comment.lua +586 -0
  115. package/nvim/plugins/mini.nvim/lua/mini/completion.lua +2094 -0
  116. package/nvim/plugins/mini.nvim/lua/mini/cursorword.lua +311 -0
  117. package/nvim/plugins/mini.nvim/lua/mini/deps.lua +1660 -0
  118. package/nvim/plugins/mini.nvim/lua/mini/diff.lua +1938 -0
  119. package/nvim/plugins/mini.nvim/lua/mini/doc.lua +1371 -0
  120. package/nvim/plugins/mini.nvim/lua/mini/extra.lua +2290 -0
  121. package/nvim/plugins/mini.nvim/lua/mini/files.lua +3145 -0
  122. package/nvim/plugins/mini.nvim/lua/mini/fuzzy.lua +356 -0
  123. package/nvim/plugins/mini.nvim/lua/mini/git.lua +1737 -0
  124. package/nvim/plugins/mini.nvim/lua/mini/hipatterns.lua +1042 -0
  125. package/nvim/plugins/mini.nvim/lua/mini/hues.lua +2088 -0
  126. package/nvim/plugins/mini.nvim/lua/mini/icons.lua +2254 -0
  127. package/nvim/plugins/mini.nvim/lua/mini/indentscope.lua +1158 -0
  128. package/nvim/plugins/mini.nvim/lua/mini/init.lua +427 -0
  129. package/nvim/plugins/mini.nvim/lua/mini/input.lua +2183 -0
  130. package/nvim/plugins/mini.nvim/lua/mini/jump.lua +609 -0
  131. package/nvim/plugins/mini.nvim/lua/mini/jump2d.lua +1244 -0
  132. package/nvim/plugins/mini.nvim/lua/mini/keymap.lua +880 -0
  133. package/nvim/plugins/mini.nvim/lua/mini/map.lua +1709 -0
  134. package/nvim/plugins/mini.nvim/lua/mini/misc.lua +969 -0
  135. package/nvim/plugins/mini.nvim/lua/mini/move.lua +509 -0
  136. package/nvim/plugins/mini.nvim/lua/mini/notify.lua +938 -0
  137. package/nvim/plugins/mini.nvim/lua/mini/operators.lua +1349 -0
  138. package/nvim/plugins/mini.nvim/lua/mini/pairs.lua +657 -0
  139. package/nvim/plugins/mini.nvim/lua/mini/pick.lua +3876 -0
  140. package/nvim/plugins/mini.nvim/lua/mini/sessions.lua +689 -0
  141. package/nvim/plugins/mini.nvim/lua/mini/snippets.lua +2828 -0
  142. package/nvim/plugins/mini.nvim/lua/mini/splitjoin.lua +1132 -0
  143. package/nvim/plugins/mini.nvim/lua/mini/starter.lua +1599 -0
  144. package/nvim/plugins/mini.nvim/lua/mini/statusline.lua +686 -0
  145. package/nvim/plugins/mini.nvim/lua/mini/surround.lua +2388 -0
  146. package/nvim/plugins/mini.nvim/lua/mini/tabline.lua +564 -0
  147. package/nvim/plugins/mini.nvim/lua/mini/test.lua +2516 -0
  148. package/nvim/plugins/mini.nvim/lua/mini/trailspace.lua +215 -0
  149. package/nvim/plugins/mini.nvim/lua/mini/visits.lua +1577 -0
  150. package/nvim/plugins/mini.nvim/readmes/mini-ai.md +190 -0
  151. package/nvim/plugins/mini.nvim/readmes/mini-align.md +203 -0
  152. package/nvim/plugins/mini.nvim/readmes/mini-animate.md +214 -0
  153. package/nvim/plugins/mini.nvim/readmes/mini-base16.md +198 -0
  154. package/nvim/plugins/mini.nvim/readmes/mini-basics.md +184 -0
  155. package/nvim/plugins/mini.nvim/readmes/mini-bracketed.md +193 -0
  156. package/nvim/plugins/mini.nvim/readmes/mini-bufremove.md +139 -0
  157. package/nvim/plugins/mini.nvim/readmes/mini-clue.md +260 -0
  158. package/nvim/plugins/mini.nvim/readmes/mini-cmdline.md +183 -0
  159. package/nvim/plugins/mini.nvim/readmes/mini-colors.md +169 -0
  160. package/nvim/plugins/mini.nvim/readmes/mini-comment.md +183 -0
  161. package/nvim/plugins/mini.nvim/readmes/mini-completion.md +217 -0
  162. package/nvim/plugins/mini.nvim/readmes/mini-cursorword.md +137 -0
  163. package/nvim/plugins/mini.nvim/readmes/mini-deps.md +271 -0
  164. package/nvim/plugins/mini.nvim/readmes/mini-diff.md +289 -0
  165. package/nvim/plugins/mini.nvim/readmes/mini-doc.md +198 -0
  166. package/nvim/plugins/mini.nvim/readmes/mini-extra.md +158 -0
  167. package/nvim/plugins/mini.nvim/readmes/mini-files.md +247 -0
  168. package/nvim/plugins/mini.nvim/readmes/mini-fuzzy.md +134 -0
  169. package/nvim/plugins/mini.nvim/readmes/mini-git.md +168 -0
  170. package/nvim/plugins/mini.nvim/readmes/mini-hipatterns.md +176 -0
  171. package/nvim/plugins/mini.nvim/readmes/mini-hues.md +285 -0
  172. package/nvim/plugins/mini.nvim/readmes/mini-icons.md +183 -0
  173. package/nvim/plugins/mini.nvim/readmes/mini-indentscope.md +191 -0
  174. package/nvim/plugins/mini.nvim/readmes/mini-input.md +163 -0
  175. package/nvim/plugins/mini.nvim/readmes/mini-jump.md +161 -0
  176. package/nvim/plugins/mini.nvim/readmes/mini-jump2d.md +197 -0
  177. package/nvim/plugins/mini.nvim/readmes/mini-keymap.md +205 -0
  178. package/nvim/plugins/mini.nvim/readmes/mini-map.md +191 -0
  179. package/nvim/plugins/mini.nvim/readmes/mini-misc.md +145 -0
  180. package/nvim/plugins/mini.nvim/readmes/mini-move.md +163 -0
  181. package/nvim/plugins/mini.nvim/readmes/mini-notify.md +175 -0
  182. package/nvim/plugins/mini.nvim/readmes/mini-operators.md +193 -0
  183. package/nvim/plugins/mini.nvim/readmes/mini-pairs.md +158 -0
  184. package/nvim/plugins/mini.nvim/readmes/mini-pick.md +340 -0
  185. package/nvim/plugins/mini.nvim/readmes/mini-sessions.md +164 -0
  186. package/nvim/plugins/mini.nvim/readmes/mini-snippets.md +373 -0
  187. package/nvim/plugins/mini.nvim/readmes/mini-splitjoin.md +194 -0
  188. package/nvim/plugins/mini.nvim/readmes/mini-starter.md +176 -0
  189. package/nvim/plugins/mini.nvim/readmes/mini-statusline.md +155 -0
  190. package/nvim/plugins/mini.nvim/readmes/mini-surround.md +190 -0
  191. package/nvim/plugins/mini.nvim/readmes/mini-tabline.md +156 -0
  192. package/nvim/plugins/mini.nvim/readmes/mini-test.md +175 -0
  193. package/nvim/plugins/mini.nvim/readmes/mini-trailspace.md +137 -0
  194. package/nvim/plugins/mini.nvim/readmes/mini-visits.md +243 -0
  195. package/nvim/plugins/mini.nvim/scripts/dual_log.sh +13 -0
  196. package/nvim/plugins/mini.nvim/scripts/dual_push.sh +15 -0
  197. package/nvim/plugins/mini.nvim/scripts/dual_release.sh +102 -0
  198. package/nvim/plugins/mini.nvim/scripts/dual_sync.sh +115 -0
  199. package/nvim/plugins/mini.nvim/scripts/init-deps-example.lua +59 -0
  200. package/nvim/plugins/mini.nvim/scripts/lint-filename-length.sh +16 -0
  201. package/nvim/plugins/mini.nvim/scripts/lintcommit-ci.sh +18 -0
  202. package/nvim/plugins/mini.nvim/scripts/lintcommit.lua +393 -0
  203. package/nvim/plugins/mini.nvim/scripts/minidoc.lua +57 -0
  204. package/nvim/plugins/mini.nvim/scripts/minimal_init.lua +28 -0
  205. package/nvim/plugins/mini.nvim/scripts/minitest.lua +4 -0
  206. package/package.json +16 -0
  207. package/pyproject.toml +43 -0
  208. package/yazi/init.lua +12 -0
  209. package/yazi/keymap.toml +114 -0
  210. package/yazi/lesskey +5 -0
  211. package/yazi/plugins/bookmarks.yazi/main.lua +86 -0
  212. package/yazi/plugins/cd-git-root.yazi/main.lua +31 -0
  213. package/yazi/plugins/smart-enter.yazi/main.lua +11 -0
  214. package/yazi/theme.toml +26 -0
  215. package/yazi/yazi.toml +15 -0
  216. package/zsh/.zshrc +145 -0
  217. package/zsh/starship.toml +20 -0
  218. package/zsh/zsh-patina.toml +2 -0
@@ -0,0 +1,966 @@
1
+ *mini.test* Test Neovim plugins
2
+
3
+ MIT License Copyright (c) 2022 Evgeni Chasnovski
4
+
5
+ ------------------------------------------------------------------------------
6
+ *MiniTest*
7
+ Features:
8
+ - Test action is defined as a named callable entry of a table.
9
+
10
+ - Helper for creating child Neovim process which is designed to be used in
11
+ tests (including taking and verifying screenshots). See
12
+ |MiniTest.new_child_neovim()| and |MiniTest.expect.reference_screenshot()|.
13
+
14
+ - Hierarchical organization of tests with custom hooks, parametrization,
15
+ and user data. See |MiniTest.new_set()|.
16
+
17
+ - Emulation of [lunarmodules/busted](https://github.com/lunarmodules/busted)
18
+ interface (`describe`, `it`, etc.).
19
+
20
+ - Predefined small yet usable set of expectations (`assert`-like functions).
21
+ See |MiniTest.expect|.
22
+
23
+ - Customizable definition of what files should be tested.
24
+
25
+ - Test case filtering. There are predefined wrappers for testing a file
26
+ (|MiniTest.run_file()|) and case at a location like current cursor position
27
+ (|MiniTest.run_at_location()|).
28
+
29
+ - Customizable reporter of output results. There are two predefined ones:
30
+ - |MiniTest.gen_reporter.buffer()| for interactive usage.
31
+ - |MiniTest.gen_reporter.stdout()| for headless Neovim.
32
+
33
+ - Customizable project specific testing script.
34
+
35
+ - Works on Unix (Linux, MacOS, etc.) and Windows.
36
+
37
+ What it doesn't support:
38
+ - Parallel execution. Due to idea of limiting implementation complexity.
39
+
40
+ - Mocks, stubs, etc. Use child Neovim process and manually override what is
41
+ needed. Reset child process it afterwards.
42
+
43
+ - "Overly specific" expectations. Tests for (no) equality and (absence of)
44
+ errors usually cover most of the needs. Adding new expectations is a
45
+ subject to weighing its usefulness against additional implementation
46
+ complexity. Use |MiniTest.new_expectation()| to create custom ones.
47
+
48
+ For more information see:
49
+ - `TESTING.md` file for a hands-on introduction based on examples.
50
+
51
+ - Code of this plugin's tests. Consider it to be an example of intended
52
+ way to use |mini.test| for test organization and creation.
53
+
54
+ # Workflow ~
55
+
56
+ - Organize tests in separate files. Each test file should return a test set
57
+ (explicitly or implicitly by using "busted" style functions).
58
+
59
+ - Write test actions as callable entries of test set. Use child process
60
+ inside test actions (see |MiniTest.new_child_neovim()|) and builtin
61
+ expectations (see |MiniTest.expect|).
62
+
63
+ - Run tests. This does two steps:
64
+ - Collect. This creates single hierarchical test set, flattens into
65
+ array of test cases (see |MiniTest-test-case|) while expanding with
66
+ parametrization, and possibly filters them.
67
+ - Execute. This safely calls hooks and main test actions in specified
68
+ order while allowing reporting progress in asynchronous fashion.
69
+ Detected errors means test case fail; otherwise - pass.
70
+
71
+ # Setup ~
72
+
73
+ This module needs a setup with `require('mini.test').setup({})` (replace
74
+ `{}` with your `config` table). It will create global Lua table `MiniTest`
75
+ which you can use for scripting or manually (with `:lua MiniTest.*`).
76
+
77
+ See |MiniTest.config| for available config settings.
78
+
79
+ You can override runtime config settings locally to buffer inside
80
+ `vim.b.minitest_config` which should have same structure as `MiniTest.config`.
81
+ See |mini.nvim-buffer-local-config| for more details.
82
+
83
+ To stop module from showing non-error feedback, set `config.silent = true`.
84
+
85
+ # Comparisons ~
86
+
87
+ - Testing infrastructure from
88
+ [nvim-lua/plenary.nvim](https://github.com/nvim-lua/plenary.nvim):
89
+ - Executes each file in separate headless Neovim process with customizable
90
+ `init.vim` file. While |mini.test| executes everything in current
91
+ Neovim process encouraging writing tests with help of manually
92
+ managed child Neovim process (see |MiniTest.new_child_neovim()|).
93
+ - Tests are expected to be written with embedded simplified versions of
94
+ `lunarmodules/busted` and `lunarmodules/luassert`. While |mini.test|
95
+ uses concepts of test set (see |MiniTest.new_set()|) and test case
96
+ (see |MiniTest-test-case|). It also can emulate bigger part of
97
+ "busted" framework.
98
+ - Has single way of reporting progress (shows result after every case
99
+ without summary). While |mini.test| can have customized reporters
100
+ with defaults for interactive and headless usage (provide more
101
+ compact and user-friendly summaries).
102
+ - Allows parallel execution, while |mini.test| does not.
103
+ - Allows making mocks, stubs, and spies, while |mini.test| does not in
104
+ favor of manually overwriting functionality in child Neovim process.
105
+
106
+ Although |mini.test| supports emulation of "busted style" testing, it will
107
+ be more stable to use its designed approach of defining tests (with
108
+ `MiniTest.new_set()` and explicit table fields). Couple of reasons:
109
+ - "Busted" syntax doesn't support full capabilities offered by |mini.test|.
110
+ Mainly it is about parametrization and supplying user data to test sets.
111
+ - It is an emulation, not full support. So some subtle things might not
112
+ work the way you expect.
113
+
114
+ Some hints for converting from `plenary.nvim` tests to |mini.test|:
115
+ - Rename files from `***_spec.lua` to `test_***.lua` and put them in
116
+ "tests" directory.
117
+ - Replace `assert` calls with |mini.test| expectations. See |MiniTest.expect|.
118
+ - Create main test set `T = MiniTest.new_set()` and eventually return it.
119
+ - Make new sets (|MiniTest.new_set()|) from `describe` blocks. Convert
120
+ `before_each()` and `after_each` to `pre_case` and `post_case` hooks.
121
+ - Make test cases from `it` blocks.
122
+
123
+ # Highlight groups ~
124
+ *MiniTest-hl-groups*
125
+
126
+ - `MiniTestEmphasis` - emphasis highlighting. By default it is a bold text.
127
+ - `MiniTestFail` - highlighting of failed cases. By default it is a bold
128
+ text with `vim.g.terminal_color_1` color (red).
129
+ - `MiniTestPass` - highlighting of passed cases. By default it is a bold
130
+ text with `vim.g.terminal_color_2` color (green).
131
+
132
+ To change any highlight group, set it directly with |nvim_set_hl()|.
133
+
134
+ # Disabling ~
135
+
136
+ To disable, set `vim.g.minitest_disable` (globally) or `vim.b.minitest_disable`
137
+ (for a buffer) to `true`. Considering high number of different scenarios
138
+ and customization intentions, writing exact rules for disabling module's
139
+ functionality is left to user. See |mini.nvim-disabling-recipes| for common
140
+ recipes.
141
+
142
+ ------------------------------------------------------------------------------
143
+ *MiniTest.setup()*
144
+ `MiniTest.setup`({config})
145
+ Module setup
146
+
147
+ Parameters ~
148
+ {config} `(table|nil)` Module config table. See |MiniTest.config|.
149
+
150
+ Usage ~
151
+ >lua
152
+ require('mini.test').setup() -- use default config
153
+ -- OR
154
+ require('mini.test').setup({}) -- replace {} with your config table
155
+ <
156
+ ------------------------------------------------------------------------------
157
+ *MiniTest.config*
158
+ `MiniTest.config`
159
+ Defaults ~
160
+ >lua
161
+ MiniTest.config = {
162
+ -- Options for collection of test cases. See `:h MiniTest.collect()`.
163
+ collect = {
164
+ -- Temporarily emulate functions from 'busted' testing framework
165
+ -- (`describe`, `it`, `before_each`, `after_each`, and more)
166
+ emulate_busted = true,
167
+
168
+ -- Function returning array of file paths to be collected.
169
+ -- Default: all Lua files in 'tests' directory starting with 'test_'.
170
+ find_files = function()
171
+ return vim.fn.globpath('tests', '**/test_*.lua', true, true)
172
+ end,
173
+
174
+ -- Predicate function indicating if test case should be executed
175
+ filter_cases = function(case) return true end,
176
+ },
177
+
178
+ -- Options for execution of test cases. See `:h MiniTest.execute()`.
179
+ execute = {
180
+ -- Table with callable fields `start()`, `update()`, and `finish()`
181
+ reporter = nil,
182
+
183
+ -- Whether to stop execution after first error
184
+ stop_on_error = false,
185
+ },
186
+
187
+ -- Path (relative to current directory) to script which handles project
188
+ -- specific test running
189
+ script_path = 'scripts/minitest.lua',
190
+
191
+ -- Whether to disable showing non-error feedback
192
+ silent = false,
193
+ }
194
+ <
195
+ ------------------------------------------------------------------------------
196
+ *MiniTest.current*
197
+ `MiniTest.current`
198
+ Table with information about current state of test execution
199
+
200
+ Use it to examine result of |MiniTest.execute()|. It is reset at the
201
+ beginning of every call.
202
+
203
+ At least these keys are supported:
204
+ - <all_cases> - array with all cases being currently executed. Basically,
205
+ an input of `MiniTest.execute()`.
206
+ - <case> - currently executed test case. See |MiniTest-test-case|. Use it
207
+ to customize execution output (like adding custom notes, etc).
208
+
209
+ ------------------------------------------------------------------------------
210
+ *MiniTest.new_set()*
211
+ `MiniTest.new_set`({opts}, {tbl})
212
+ Create test set
213
+
214
+ Test set is one of the two fundamental data structures. It is a table that
215
+ defines hierarchical test organization as opposed to sequential
216
+ organization with |MiniTest-test-case|.
217
+
218
+ All its elements are one of three categories:
219
+ - A callable (object that can be called; function or table with `__call`
220
+ metatble entry) is considered to define a test action. It will be called
221
+ with "current arguments" (result of all nested `parametrize` values, read
222
+ further). If it throws error, test has failed.
223
+ - A test set (output of this function) defines nested structure. Its
224
+ options during collection (see |MiniTest.collect()|) will be extended
225
+ with options of this (parent) test set.
226
+ - Any other elements are considered helpers and don't directly participate
227
+ in test structure.
228
+
229
+ Set options allow customization of test collection and execution (more
230
+ details in `opts` description):
231
+ - `hooks` - table with elements that will be called without arguments at
232
+ predefined stages of test execution.
233
+ - `parametrize` - array defining different arguments with which main test
234
+ actions will be called. Any non-trivial parametrization will lead to
235
+ every element (even nested) be "multiplied" and processed with every
236
+ element of `parametrize`. This allows handling many different combination
237
+ of tests with little effort.
238
+ - `data` - table with user data that will be forwarded to cases. Primary
239
+ objective is to be used for customized case filtering.
240
+
241
+ Notes:
242
+ - Preferred way of adding elements is by using syntax `T[name] = element`.
243
+ This way order of added elements will be preserved. Any other way won't
244
+ guarantee any order.
245
+ - Supplied options `opts` are stored in `opts` field of metatable
246
+ (`getmetatable(set).opts`).
247
+
248
+ Parameters ~
249
+ {opts} `(table|nil)` Allowed options:
250
+ - <hooks> - table with fields:
251
+ - <pre_once> - executed before first filtered node.
252
+ - <pre_case> - executed before each case (even nested).
253
+ - <post_case> - executed after each case (even nested).
254
+ - <post_once> - executed after last filtered node.
255
+ - <parametrize> - array where each element is itself an array of
256
+ parameters to be appended to "current parameters" of callable fields.
257
+ Note: don't use plain `{}` as it is equivalent to "parametrization into
258
+ zero cases", so no cases will be collected from this set. Calling test
259
+ actions with no parameters is equivalent to `{{}}` or not supplying
260
+ `parametrize` option at all.
261
+ - <data> - user data to be forwarded to cases. Can be used for a more
262
+ granular filtering.
263
+ - <n_retry> - number of times to retry each case until success.
264
+ Default: 1.
265
+ {tbl} `(table|nil)` Initial test items (possibly nested). Will be executed
266
+ without any guarantees on order.
267
+
268
+ Return ~
269
+ `(table)` A single test set.
270
+
271
+ Usage ~
272
+ >lua
273
+ -- Use with defaults
274
+ T = MiniTest.new_set()
275
+ T['works'] = function() MiniTest.expect.equality(1, 1) end
276
+
277
+ -- Use with custom options. This will result into two actual cases: first
278
+ -- will pass, second - fail after two attempts.
279
+ T['nested'] = MiniTest.new_set({
280
+ hooks = { pre_case = function() _G.x = 1 end },
281
+ parametrize = { { 1 }, { 2 } },
282
+ n_retry = 2,
283
+ })
284
+
285
+ T['nested']['works'] = function(x) MiniTest.expect.equality(_G.x, x) end
286
+ <
287
+ ------------------------------------------------------------------------------
288
+ *MiniTest-test-case*
289
+ Test case
290
+
291
+ An item of sequential test organization, as opposed to hierarchical with
292
+ test set (see |MiniTest.new_set()|). It is created as result of test
293
+ collection with |MiniTest.collect()| to represent all necessary information
294
+ of test execution.
295
+
296
+ Execution of test case goes by the following rules:
297
+ - Call functions in order:
298
+ - All elements of `hooks.pre` from first to last without arguments.
299
+ - Field `test` with arguments unpacked from `args`. If execution fails,
300
+ retry it (along with hooks that come from `pre_case` and `post_case`)
301
+ at most `n_retry` times until first success (if any).
302
+ - All elements of `hooks.post` from first to last without arguments.
303
+ - Error in any call gets appended to `exec.fails`, meaning error in any
304
+ hook will lead to test fail.
305
+ - State (`exec.state`) is changed before every call and after last call.
306
+
307
+ Class ~
308
+ {Test-case}
309
+
310
+ Fields ~
311
+ {args} `(table)` Array of arguments with which `test` will be called.
312
+ {data} `(table)` User data: all fields of `opts.data` from nested test sets.
313
+ {desc} `(table)` Description: array of fields from nested test sets.
314
+ {exec} `(table|nil)` Information about test case execution. Value of `nil` means
315
+ that this particular case was not (yet) executed. Has following fields:
316
+ - <fails> - array of strings with failing information.
317
+ - <notes> - array of strings with non-failing information.
318
+ - <state> - state of test execution. One of:
319
+ - `'Executing <name of what is being executed>'` (during execution).
320
+ - `'Pass'` (no fails, no notes).
321
+ - `'Pass with notes'` (no fails, some notes).
322
+ - `'Fail'` (some fails, no notes).
323
+ - `'Fail with notes'` (some fails, some notes).
324
+ {hooks} `(table)` Hooks to be executed as part of test case. Has fields:
325
+ - <pre> and <post> - arrays of functions to be consecutively executed
326
+ before and after every execution of `test`.
327
+ - <pre_source> and <post_source> - arrays of strings with sources of
328
+ corresponding elements in <pre> and <post> arrays. Source is one of
329
+ `"once"` (for `pre_once` and `post_once` hooks) and
330
+ `"case"` (for `pre_case` and `post_case` hooks).
331
+ {test} `(function|table)` Main callable object representing test action.
332
+
333
+ ------------------------------------------------------------------------------
334
+ *MiniTest.skip()*
335
+ `MiniTest.skip`({msg})
336
+ Skip the rest of current case
337
+
338
+ Notes:
339
+ - When called inside test case, stops execution while adding message to notes.
340
+ - When called inside `pre_case` hook, registers skip at the start of its
341
+ test case. Calling in other hooks has no effect.
342
+ - Currently implemented as a specially handled type of error.
343
+
344
+ Parameters ~
345
+ {msg} `(string|nil)` Message to be added to current case notes.
346
+
347
+ ------------------------------------------------------------------------------
348
+ *MiniTest.add_note()*
349
+ `MiniTest.add_note`({msg})
350
+ Add note to currently executed test case
351
+
352
+ Appends `msg` to `exec.notes` field of `case` in |MiniTest.current|.
353
+
354
+ Parameters ~
355
+ {msg} `(string)` Note to add.
356
+
357
+ ------------------------------------------------------------------------------
358
+ *MiniTest.finally()*
359
+ `MiniTest.finally`({f})
360
+ Register callable execution after current callable
361
+
362
+ Can be used several times inside hooks and main test callable of test case.
363
+
364
+ Parameters ~
365
+ {f} `(function|table)` Callable to be executed after current callable is
366
+ finished executing (regardless of whether it ended with error or not).
367
+
368
+ ------------------------------------------------------------------------------
369
+ *MiniTest.run()*
370
+ `MiniTest.run`({opts})
371
+ Run tests
372
+
373
+ - Try executing project specific script at path `opts.script_path`. If
374
+ successful (no errors), then stop.
375
+ - Collect cases with |MiniTest.collect()| and `opts.collect`.
376
+ - Execute collected cases with |MiniTest.execute()| and `opts.execute`.
377
+
378
+ Parameters ~
379
+ {opts} `(table|nil)` Options with structure similar to |MiniTest.config|.
380
+ Absent values are inferred from there.
381
+
382
+ ------------------------------------------------------------------------------
383
+ *MiniTest.run_file()*
384
+ `MiniTest.run_file`({file}, {opts})
385
+ Run specific test file
386
+
387
+ Basically a |MiniTest.run()| wrapper with custom `collect.find_files` option.
388
+
389
+ Parameters ~
390
+ {file} `(string|nil)` Path to test file. By default a path of current buffer.
391
+ {opts} `(table|nil)` Options for |MiniTest.run()|.
392
+
393
+ ------------------------------------------------------------------------------
394
+ *MiniTest.run_at_location()*
395
+ `MiniTest.run_at_location`({location}, {opts})
396
+ Run case(s) covering location
397
+
398
+ Try filtering case(s) covering location, meaning that definition of its
399
+ main `test` action (as taken from builtin `debug.getinfo`) is located in
400
+ specified file and covers specified line. Note that it can result in
401
+ multiple cases if they come from parametrized test set (see `parametrize`
402
+ option in |MiniTest.new_set()|).
403
+
404
+ Basically a |MiniTest.run()| wrapper with custom `collect.find_files` option.
405
+
406
+ Parameters ~
407
+ {location} `(table|nil)` Table with fields <file> (path to file) and <line>
408
+ (line number in that file). Default is taken from current cursor position.
409
+
410
+ ------------------------------------------------------------------------------
411
+ *MiniTest.collect()*
412
+ `MiniTest.collect`({opts})
413
+ Collect test cases
414
+
415
+ Overview of collection process:
416
+ - If `opts.emulate_busted` is `true`, temporary make special global
417
+ functions (removed at the end of collection). They can be used inside
418
+ test files to create hierarchical structure of test cases.
419
+ - Source each file from array output of `opts.find_files`. It should output
420
+ a test set (see |MiniTest.new_set()|) or `nil` (if "busted" style is used;
421
+ test set is created implicitly).
422
+ - Combine all test sets into single set with fields equal to its file path.
423
+ - Convert from hierarchical test configuration to sequential: from single
424
+ test set to array of test cases (see |MiniTest-test-case|). Conversion is
425
+ done in the form of "for every table element do: for every `parametrize`
426
+ element do: ...". Details:
427
+ - If element is a callable, construct test case with it being main
428
+ `test` action. Description is appended with key of element in current
429
+ test set table. Hooks, arguments, and data are taken from "current
430
+ nested" ones. Add case to output array.
431
+ - If element is a test set, process it in similar, recursive fashion.
432
+ The "current nested" information is expanded:
433
+ - `args` is extended with "current element" from `parametrize`.
434
+ - `desc` is appended with element key.
435
+ - `hooks` are appended to their appropriate places. `*_case` hooks
436
+ will be inserted closer to all child cases than hooks from parent
437
+ test sets: `pre_case` at end, `post_case` at start.
438
+ - `data` is extended via |vim.tbl_deep_extend()|.
439
+ - Any other element is not processed.
440
+ - Filter array with `opts.filter_cases`. Note that input case doesn't contain
441
+ all hooks, as `*_once` hooks will be added after filtration.
442
+ - Add `*_once` hooks to appropriate cases.
443
+
444
+ Parameters ~
445
+ {opts} `(table|nil)` Options controlling case collection. Possible fields:
446
+ - <emulate_busted> - whether to emulate `lunarmodules/busted` interface.
447
+ It emulates these global functions: `describe`, `it`, `setup`, `teardown`,
448
+ `before_each`, `after_each`. Use |MiniTest.skip()| instead of `pending()`
449
+ and |MiniTest.finally()| instead of `finally`.
450
+ - <find_files> - function which when called without arguments returns
451
+ array with file paths. Each file should be a Lua file returning single
452
+ test set or `nil`.
453
+ - <filter_cases> - function which when called with single test case
454
+ (see |MiniTest-test-case|) returns `false` if this case should be filtered
455
+ out; `true` otherwise.
456
+
457
+ Return ~
458
+ `(table)` Array of test cases ready to be used by |MiniTest.execute()|.
459
+
460
+ ------------------------------------------------------------------------------
461
+ *MiniTest.execute()*
462
+ `MiniTest.execute`({cases}, {opts})
463
+ Execute array of test cases
464
+
465
+ Overview of execution process:
466
+ - Reset `all_cases` in |MiniTest.current| with `cases` input.
467
+ - Call `reporter.start(cases)` (if present).
468
+ - Execute each case in natural array order (aligned with their integer
469
+ keys). Set `MiniTest.current.case` to currently executed case. Detailed
470
+ test case execution is described in |MiniTest-test-case|. After any state
471
+ change (including case retry attempts), call `reporter.update(case_num)`
472
+ (if present), where `case_num` is an integer key of current test case.
473
+ - Call `reporter.finish()` (if present).
474
+
475
+ Notes:
476
+ - Execution is done in asynchronous fashion with scheduling. This allows
477
+ making meaningful progress report during execution.
478
+ - This function doesn't return anything. Instead, it updates `cases` in
479
+ place with proper `exec` field. Use `all_cases` at |MiniTest.current| to
480
+ look at execution result.
481
+
482
+ Parameters ~
483
+ {cases} `(table)` Array of test cases (see |MiniTest-test-case|).
484
+ {opts} `(table|nil)` Options controlling case collection. Possible fields:
485
+ - <reporter> - table with possible callable fields `start`, `update`,
486
+ `finish`. Default: |MiniTest.gen_reporter.buffer()| in interactive
487
+ usage and |MiniTest.gen_reporter.stdout()| in headless usage.
488
+ - <stop_on_error> - whether to stop execution (see |MiniTest.stop()|)
489
+ after first error. Default: `false`.
490
+
491
+ ------------------------------------------------------------------------------
492
+ *MiniTest.stop()*
493
+ `MiniTest.stop`({opts})
494
+ Stop test execution
495
+
496
+ Parameters ~
497
+ {opts} `(table|nil)` Options with fields:
498
+ - <close_all_child_neovim> - whether to close all child neovim processes
499
+ created with |MiniTest.new_child_neovim()|. Default: `true`.
500
+
501
+ ------------------------------------------------------------------------------
502
+ *MiniTest.is_executing()*
503
+ `MiniTest.is_executing`()
504
+ Check if tests are being executed
505
+
506
+ Return ~
507
+ `(boolean)`
508
+
509
+ ------------------------------------------------------------------------------
510
+ *MiniTest.expect*
511
+ `MiniTest.expect`
512
+ Table with expectation functions
513
+
514
+ Each function has the following behavior:
515
+ - Silently returns `true` if expectation is fulfilled.
516
+ - Throws an informative error with information helpful for debugging.
517
+ Allows customizable fail reason to provide more context.
518
+
519
+ Mostly designed to be used within |mini.test| framework.
520
+
521
+ Usage ~
522
+ >lua
523
+ local x = 1 + 1
524
+ MiniTest.expect.equality(x, 2) -- passes
525
+ MiniTest.expect.equality(x, 1, { fail_reason = 'Not equal' }) -- fails
526
+ <
527
+ ------------------------------------------------------------------------------
528
+ *MiniTest.expect.equality()*
529
+ `MiniTest.expect.equality`({left}, {right}, {opts})
530
+ Expect equality of two objects
531
+
532
+ Equality is tested via |vim.deep_equal()|. It also tries to compute more
533
+ detailed cause for equality (for easier spotting the difference):
534
+ - If they have different types.
535
+ - For strings if they have different length or if some character is different.
536
+ - For tables it shows a "key branch" at which values are different along with
537
+ the actual values. A single difference is shown, there might be more.
538
+ For not nested tables key branch is just a key. If the difference is inside
539
+ nested tables, the key branch shows a "path through nested tables" to
540
+ a different value. Examples: >lua
541
+
542
+ local eq = MiniTest.expect.equality
543
+ eq({ 1, 2 }, { 1, 3 }) -- Key branch is `2`
544
+ eq({ 1, { 2 } }, { 1, 'c' }) -- Key branch is `2` ('c' is not a table)
545
+ eq({ 1, { 2 } }, { 1, { 3 } }) -- Key branch is `2->1`
546
+
547
+ -- Key branch is either `1->1->"a"` or `1->1->"b"`
548
+ eq({ { { a = 1 } } }, { { { b = 2 } } })
549
+ <
550
+ Parameters ~
551
+ {left} `(any)` First object.
552
+ {right} `(any)` Second object.
553
+ {opts} `(table|nil)` Options. Possible fields:
554
+ - <fail_reason> `(string|function)` - reason for failing expectation.
555
+ a function is called with expectation input and should return a string.
556
+ Default: `nil` for default reason like "Failed expectation for ...".
557
+
558
+ ------------------------------------------------------------------------------
559
+ *MiniTest.expect.no_equality()*
560
+ `MiniTest.expect.no_equality`({left}, {right}, {opts})
561
+ Expect no equality of two objects
562
+
563
+ Equality is tested via |vim.deep_equal()|.
564
+
565
+ Parameters ~
566
+ {left} `(any)` First object.
567
+ {right} `(any)` Second object.
568
+ {opts} `(table|nil)` Options. Possible fields:
569
+ - <fail_reason> `(string|function)` - reason for failing expectation.
570
+ a function is called with expectation input and should return a string.
571
+ Default: `nil` for default reason like "Failed expectation for ...".
572
+
573
+ ------------------------------------------------------------------------------
574
+ *MiniTest.expect.error()*
575
+ `MiniTest.expect.error`({f}, {pattern}, {opts}, {...})
576
+ Expect function call to raise error
577
+
578
+ Parameters ~
579
+ {f} `(function)` Function to be tested for raising error.
580
+ {pattern} `(string|nil)` Pattern which error message should match.
581
+ Use `nil` or empty string to not test for pattern matching.
582
+ {opts} `(table|nil)` Options. Possible fields:
583
+ - <fail_reason> `(string|function)` - reason for failing expectation.
584
+ a function is called with expectation input and should return a string.
585
+ Default: `nil` for default reason like "Failed expectation for ...".
586
+
587
+ ------------------------------------------------------------------------------
588
+ *MiniTest.expect.no_error()*
589
+ `MiniTest.expect.no_error`({f}, {opts}, {...})
590
+ Expect function call to not raise error
591
+
592
+ Parameters ~
593
+ {f} `(function)` Function to be tested for not raising error.
594
+ {opts} `(table|nil)` Options. Possible fields:
595
+ - <fail_reason> `(string|function)` - reason for failing expectation.
596
+ a function is called with expectation input and should return a string.
597
+ Default: `nil` for default reason like "Failed expectation for ...".
598
+
599
+ ------------------------------------------------------------------------------
600
+ *MiniTest.expect.reference_screenshot()*
601
+ `MiniTest.expect.reference_screenshot`({screenshot}, {path}, {opts})
602
+ Expect equality to reference screenshot
603
+
604
+ Parameters ~
605
+ {screenshot} `(table|nil)` Array with screenshot information. Usually an output
606
+ of `child.get_screenshot()` (see |MiniTest-child-neovim-get_screenshot()|).
607
+ If `nil`, expectation passed.
608
+ {path} `(string|nil)` Path to reference screenshot. If `nil`, constructed
609
+ automatically in directory `opts.directory` from current case info and
610
+ total number of times it was called inside current case. If there is no
611
+ file at `path`, it is created with content of `screenshot`.
612
+ {opts} `(table|nil)` Options:
613
+ - <force> `(boolean)` - whether to forcefully create reference screenshot.
614
+ Temporary useful during test writing. Default: `false`.
615
+ - <ignore_text> `(boolean|table)` - whether to ignore all or some text lines.
616
+ If `true` - ignore all, if number array - ignore text of those lines,
617
+ if `false` - do not ignore any. Default: `false`.
618
+ - <ignore_attr> `(boolean|table)` - whether to ignore all or some attr lines.
619
+ If `true` - ignore all, if number array - ignore attr of those lines,
620
+ if `false` - do not ignore any. Default: `false`.
621
+ - <directory> `(string)` - directory where automatically constructed `path`
622
+ is located. Default: "tests/screenshots".
623
+ - <fail_reason> `(string|function)` - reason for failing expectation.
624
+ a function is called with expectation input and should return a string.
625
+ Default: `nil` for default reason like "Failed expectation for ...".
626
+
627
+ ------------------------------------------------------------------------------
628
+ *MiniTest.new_expectation()*
629
+ `MiniTest.new_expectation`({subject}, {predicate}, {fail_context})
630
+ Create new expectation function
631
+
632
+ Helper for writing custom functions with behavior similar to other methods
633
+ of |MiniTest.expect|.
634
+
635
+ Parameters ~
636
+ {subject} `(string|function|table)` Subject of expectation. If callable,
637
+ called with expectation input arguments to produce string value.
638
+ {predicate} `(function|table)` Predicate callable. Called with expectation
639
+ input arguments. Output `false` or `nil` means failed expectation.
640
+ {fail_context} `(string|function|table)` Information about fail. If callable,
641
+ called with expectation input arguments to produce string value.
642
+
643
+ Return ~
644
+ `(function)` Expectation function.
645
+
646
+ Usage ~
647
+ >lua
648
+ local expect_truthy = MiniTest.new_expectation(
649
+ 'truthy',
650
+ function(x) return x end,
651
+ function(x) return 'Object: ' .. vim.inspect(x) end
652
+ )
653
+ <
654
+ ------------------------------------------------------------------------------
655
+ *MiniTest.gen_reporter*
656
+ `MiniTest.gen_reporter`
657
+ Table with pre-configured report generators
658
+
659
+ Each element is a function which returns reporter - table with callable
660
+ `start`, `update`, and `finish` fields.
661
+
662
+ ------------------------------------------------------------------------------
663
+ *MiniTest.gen_reporter.buffer()*
664
+ `MiniTest.gen_reporter.buffer`({opts})
665
+ Generate buffer reporter
666
+
667
+ This is a default choice for interactive (not headless) usage. Opens a window
668
+ with dedicated non-terminal buffer and updates it with throttled redraws.
669
+
670
+ Opened buffer has the following helpful Normal mode mappings:
671
+ - `<Esc>` - stop test execution if executing (see |MiniTest.is_executing()|
672
+ and |MiniTest.stop()|). Close window otherwise.
673
+ - `q` - same as `<Esc>` for convenience and compatibility.
674
+
675
+ General idea:
676
+ - Group cases by concatenating first `opts.group_depth` elements of case
677
+ description (`desc` field). Groups by collected files if using default values.
678
+ - In `start()` show some stats to know how much is scheduled to be executed.
679
+ - In `update()` show symbolic overview of current group and state of current
680
+ case. Each symbol represents one case and its state:
681
+ - `?` - case didn't finish executing.
682
+ - `o` - pass.
683
+ - `O` - pass with notes.
684
+ - `x` - fail.
685
+ - `X` - fail with notes.
686
+ - In `finish()` show all fails and notes ordered by case.
687
+
688
+ Parameters ~
689
+ {opts} `(table|nil)` Table with options. Used fields:
690
+ - <group_depth> - number of first elements of case description (can be zero)
691
+ used for grouping. Higher values mean higher granularity of output.
692
+ Default: 1.
693
+ - <throttle_delay> - minimum number of milliseconds to wait between
694
+ redrawing. Reduces screen flickering but not amount of computations.
695
+ Default: 10.
696
+ - <window> - definition of window to open. Can take one of the forms:
697
+ - Callable. It is called expecting output to be target window id
698
+ (current window is used if output is `nil`). Use this to open in
699
+ "normal" window (like `function() vim.cmd('vsplit') end`).
700
+ - Table. Used as `config` argument in |nvim_open_win()|.
701
+ Default: table for centered floating window.
702
+
703
+ ------------------------------------------------------------------------------
704
+ *MiniTest.gen_reporter.stdout()*
705
+ `MiniTest.gen_reporter.stdout`({opts})
706
+ Generate stdout reporter
707
+
708
+ This is a default choice for headless usage. Writes to `stdout`. Uses
709
+ coloring ANSI escape sequences to make pretty and informative output
710
+ (should work in most modern terminals and continuous integration providers).
711
+
712
+ It has same general idea as |MiniTest.gen_reporter.buffer()| with slightly
713
+ less output (it doesn't overwrite previous text) to overcome typical
714
+ terminal limitations.
715
+
716
+ Parameters ~
717
+ {opts} `(table|nil)` Table with options. Used fields:
718
+ - <group_depth> - number of first elements of case description (can be zero)
719
+ used for grouping. Higher values mean higher granularity of output.
720
+ Default: 1.
721
+ - <quit_on_finish> - whether to quit after finishing test execution.
722
+ Default: `true`.
723
+
724
+ ------------------------------------------------------------------------------
725
+ *MiniTest.new_child_neovim()*
726
+ `MiniTest.new_child_neovim`()
727
+ Create child Neovim process
728
+
729
+ This creates an object designed to be a fundamental piece of |mini.test|
730
+ methodology. It can start/stop/restart a separate (child) Neovim process
731
+ (headless, but fully functioning) together with convenience helpers to
732
+ interact with it through |RPC| messages.
733
+
734
+ For more information see |MiniTest-child-neovim|.
735
+
736
+ Return ~
737
+ `(MiniTest.child)` Object of |MiniTest-child-neovim|.
738
+
739
+ Usage ~
740
+ >lua
741
+ -- Initiate
742
+ local child = MiniTest.new_child_neovim()
743
+ child.start()
744
+
745
+ -- Use API functions
746
+ child.api.nvim_buf_set_lines(0, 0, -1, true, { 'Line inside child Neovim' })
747
+
748
+ -- Execute Lua code, Vimscript commands, etc.
749
+ child.lua('_G.n = 0')
750
+ child.cmd('au CursorMoved * lua _G.n = _G.n + 1')
751
+ child.type_keys('l')
752
+ print(child.lua_get('_G.n')) -- Should be 1
753
+
754
+ -- Use other `vim.xxx` Lua wrappers (executed inside child process)
755
+ vim.b.aaa = 'current process'
756
+ child.b.aaa = 'child process'
757
+ print(child.lua_get('vim.b.aaa')) -- Should be 'child process'
758
+
759
+ -- Always stop process after it is not needed
760
+ child.stop()
761
+ <
762
+ ------------------------------------------------------------------------------
763
+ *MiniTest-child-neovim*
764
+ Child class
765
+
766
+ It offers a great set of tools to write reliable and reproducible tests by
767
+ allowing to use fresh process in any test action. Interaction with it is done
768
+ through |RPC| protocol.
769
+
770
+ Although quite flexible, at the moment it has certain limitations:
771
+ - Doesn't allow using functions or userdata for child's both inputs and
772
+ outputs. Usual solution is to move computations from current Neovim process
773
+ to child process. Use `child.lua()` and `child.lua_get()` for that.
774
+ - When writing tests, it is common to end up with "hanging" process: it
775
+ stops executing without any output. Most of the time it is because Neovim
776
+ process is "blocked", i.e. it waits for user input and won't return from
777
+ other call (like `child.api.nvim_exec_lua()`). Common causes are active
778
+ |hit-enter-prompt| (increase prompt height to a bigger value) or
779
+ Operator-pending mode (exit it). To mitigate this experience, most helpers
780
+ will throw an error if its immediate execution will lead to hanging state.
781
+ Also in case of hanging state try `child.api_notify` instead of `child.api`.
782
+
783
+ Notes:
784
+ - An important type of field is a "redirection table". It acts as a
785
+ convenience wrapper for corresponding `vim.*` table. Can be used both to
786
+ return and set values. Examples:
787
+ - `child.api.nvim_buf_line_count(0)` will execute
788
+ `vim.api.nvim_buf_line_count(0)` inside child process and return its
789
+ output to current process.
790
+ - `child.bo.filetype = 'lua'` will execute `vim.bo.filetype = 'lua'`
791
+ inside child process.
792
+ They still have same limitations listed above, so are not perfect. In
793
+ case of a doubt, use `child.lua()`.
794
+ - Almost all methods use |vim.rpcrequest()| (i.e. wait for call to finish and
795
+ then return value). See for `*_notify` variant to use |vim.rpcnotify()|.
796
+ - All fields and methods should be called with `.`, not `:`.
797
+
798
+ Class ~
799
+ {MiniTest.child}
800
+
801
+ Fields ~
802
+ {start} `(function)` Start child process. See |MiniTest-child-neovim-start()|.
803
+ {stop} `(function)` Stop current child process.
804
+ {restart} `(function)` Restart child process: stop if running and then
805
+ start a new one. Takes same arguments as `child.start()` but uses values
806
+ from most recent `start()` call as defaults.
807
+
808
+ {type_keys} `(function)` Emulate typing keys.
809
+ See |MiniTest-child-neovim-type_keys()|. Doesn't check for blocked state.
810
+
811
+ {cmd} `(function)` Execute Vimscript code from a string.
812
+ A wrapper for |nvim_exec()| without capturing output.
813
+ {cmd_capture} `(function)` Execute Vimscript code from a string and
814
+ capture output. A wrapper for |nvim_exec()| with capturing output.
815
+
816
+ {lua} `(function)` Execute Lua code. A wrapper for |nvim_exec_lua()|.
817
+ {lua_notify} `(function)` Execute Lua code without waiting for output.
818
+ {lua_get} `(function)` Execute Lua code and return result. A wrapper
819
+ for |nvim_exec_lua()| but prepends string code with `return`.
820
+ {lua_func} `(function)` Execute Lua function and return it's result.
821
+ Function will be called with all extra parameters (second one and later).
822
+ Note: usage of upvalues (data from outside function scope) is not allowed.
823
+
824
+ {is_blocked} `(function)` Check whether child process is blocked.
825
+ {is_running} `(function)` Check whether child process is currently running.
826
+
827
+ {ensure_normal_mode} `(function)` Ensure normal mode.
828
+ {get_screenshot} `(function)` Returns table with two "2d arrays" of single
829
+ characters representing what is displayed on screen and how it looks.
830
+ Has `opts` table argument for optional configuratnion.
831
+
832
+ {job} `(table|nil)` Information about current job. If `nil`, child is not running.
833
+
834
+ {api} `(table)` Redirection table for `vim.api`. Doesn't check for blocked state.
835
+ {api_notify} `(table)` Same as `api`, but uses |vim.rpcnotify()|.
836
+
837
+ {diagnostic} `(table)` Redirection table for |vim.diagnostic|.
838
+ {fn} `(table)` Redirection table for |vim.fn|.
839
+ {highlight} `(table)` Redirection table for |vim.highlight|.
840
+ {hl} `(table)` Redirection table for |vim.hl|.
841
+ {json} `(table)` Redirection table for `vim.json`.
842
+ {loop} `(table)` Redirection table for |vim.loop|.
843
+ {lsp} `(table)` Redirection table for `vim.lsp` (|lsp-core|).
844
+ {mpack} `(table)` Redirection table for |vim.mpack|.
845
+ {spell} `(table)` Redirection table for |vim.spell|.
846
+ {treesitter} `(table)` Redirection table for `vim.treesitter` (|lua-treesitter-core|).
847
+ {ui} `(table)` Redirection table for |vim.ui|. Currently of no
848
+ use because it requires sending function through RPC, which is impossible
849
+ at the moment.
850
+ {fs} `(table)` Redirection table for |vim.fs|.
851
+
852
+ {g} `(table)` Redirection table for |vim.g|.
853
+ {b} `(table)` Redirection table for |vim.b|.
854
+ {w} `(table)` Redirection table for |vim.w|.
855
+ {t} `(table)` Redirection table for |vim.t|.
856
+ {v} `(table)` Redirection table for |vim.v|.
857
+ {env} `(table)` Redirection table for |vim.env|.
858
+
859
+ {o} `(table)` Redirection table for |vim.o|.
860
+ {go} `(table)` Redirection table for |vim.go|.
861
+ {bo} `(table)` Redirection table for |vim.bo|.
862
+ {wo} `(table)` Redirection table for |vim.wo|.
863
+
864
+ ------------------------------------------------------------------------------
865
+ *MiniTest-child-neovim-start()*
866
+ `child.start`({args}, {opts})
867
+
868
+ Start child process and connect to it. Won't work if child is already running.
869
+
870
+ Parameters ~
871
+ {args} `(table)` Array with arguments for executable. Will be prepended with
872
+ the following default arguments (see |startup-options|): >lua
873
+ { '--clean', '-n', '--listen', <some address>,
874
+ '--headless', '--cmd', 'set lines=24 columns=80' }
875
+ <
876
+ {opts} `(table|nil)` Options:
877
+ - <nvim_executable> - name of Neovim executable. Default: |v:progpath|.
878
+ - <connection_timeout> - stop trying to connect after this amount of
879
+ milliseconds. Default: 5000.
880
+
881
+ Usage ~
882
+ >lua
883
+ child = MiniTest.new_child_neovim()
884
+
885
+ -- Start default clean Neovim instance
886
+ child.start()
887
+
888
+ -- Start with custom 'init.lua' file
889
+ child.start({ '-u', 'scripts/minimal_init.lua' })
890
+ <
891
+ ------------------------------------------------------------------------------
892
+ *MiniTest-child-neovim-type_keys()*
893
+ `child.type_keys`({wait}, {...})
894
+
895
+ Basically a wrapper for |nvim_input()| applied inside child process.
896
+ Differences:
897
+ - Can wait after each group of characters.
898
+ - Raises error if typing keys resulted into error in child process (i.e. its
899
+ |v:errmsg| was updated).
900
+ - Key `<` as a separate entry may not be escaped as `<LT>`.
901
+
902
+ Parameters ~
903
+ {wait} `(number|nil)` Number of milliseconds to wait after each entry. May be
904
+ omitted, in which case no waiting is done.
905
+ {...} `(string|table<number,string>)` Separate entries for |nvim_input()|,
906
+ after which `wait` will be applied. Can be either string or array of strings.
907
+
908
+ Usage ~
909
+ >lua
910
+ -- All of these type keys 'c', 'a', 'w'
911
+ child.type_keys('caw')
912
+ child.type_keys('c', 'a', 'w')
913
+ child.type_keys('c', { 'a', 'w' })
914
+
915
+ -- Waits 5 ms after `c` and after 'w'
916
+ child.type_keys(5, 'c', { 'a', 'w' })
917
+
918
+ -- Special keys can also be used
919
+ child.type_keys('i', 'Hello world', '<Esc>')
920
+ <
921
+ ------------------------------------------------------------------------------
922
+ *MiniTest-child-neovim-get_screenshot()*
923
+ `child.get_screenshot`({opts})
924
+
925
+ Compute what is displayed on (default TUI) screen and how it is displayed.
926
+ This basically calls |screenstring()| and |screenattr()| for every visible
927
+ cell (row from 1 to |'lines'|, column from 1 to |'columns'|).
928
+
929
+ Notes:
930
+ - To make output more portable and visually useful, outputs of
931
+ `screenattr()` are coded with single character symbols. Those are taken from
932
+ 94 characters (ASCII codes between 33 and 126), so there will be duplicates
933
+ in case of more than 94 different ways text is displayed on screen.
934
+
935
+ Parameters ~
936
+ {opts} `(table|nil)` Options. Possieble fields:
937
+ - <redraw> `(boolean)` - whether to call |:redraw| prior to computing
938
+ screenshot. Default: `true`.
939
+
940
+ Return ~
941
+ `(table|nil)` Screenshot table with the following fields:
942
+ - <text> - "2d array" (row-column) of single characters displayed at
943
+ particular cells.
944
+ - <attr> - "2d array" (row-column) of symbols representing how text is
945
+ displayed (basically, "coded" appearance/highlighting). They should be
946
+ used only in relation to each other: same/different symbols for two
947
+ cells mean same/different visual appearance. Note: there will be false
948
+ positives if there are more than 94 different attribute values.
949
+ It also can be used with `tostring()` to convert to single string (used
950
+ for writing to reference file). It results into two visual parts
951
+ (separated by empty line), for `text` and `attr`. Each part has "ruler"
952
+ above content and line numbers for each line.
953
+ Returns `nil` if couldn't get a reasonable screenshot.
954
+
955
+ Usage ~
956
+ >lua
957
+ local screenshot = child.get_screenshot()
958
+
959
+ -- Show character displayed row=3 and column=4
960
+ print(screenshot.text[3][4])
961
+
962
+ -- Convert to string
963
+ tostring(screenshot)
964
+ <
965
+
966
+ vim:tw=78:ts=8:noet:ft=help:norl: