1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-11-27 02:23:26 +03:00
kakoune/test
Johannes Altmanninger 6e5bc9dd6c Fix <c-r> use-after-free InsertCompletionHide touches used register
Before performing the insertion, InsertCompleter::insert calls
try_accept() to accept any selected completion candidate.  If there
is one, we fire InsertCompletionHide. If that one modifies the register
used by <c-r>, the inserted StringViews will be dangling.

Fix this by running try_insert first, and read from the register later.
Note that we call try_accept() twice but that's fine.

It would probably make more sense to copy the register before calling
insert() but I don't think it matters.

Closes #5220
2024-09-02 19:46:33 +10:00
..
commands Try to make tests less timing sensitive 2024-08-13 20:39:44 +10:00
compose Revert "Switch undo storage from a tree to a plain list" 2023-06-17 17:31:57 +10:00
display Add support for curly underline and separate underline color 2021-09-07 08:21:26 +10:00
highlight Delay NormalMode clearing of status line and info box to next idle 2024-08-08 13:08:01 +10:00
hooks Fix <c-r> use-after-free InsertCompletionHide touches used register 2024-09-02 19:46:33 +10:00
indent Tweak python block command test location and remove wall of text 2024-06-11 19:39:07 +10:00
normal Handle word completion when recording macros 2024-07-22 20:22:14 +10:00
prompt Add tests for prompt history behaviour 2022-06-07 14:01:23 +10:00
regression Fix json-ui scroll support 2024-08-14 21:32:03 +10:00
shell More test timing fix 2024-08-14 19:12:49 +10:00
tools Fix another case where git tests were hanging 2024-05-12 14:18:17 +10:00
README.asciidoc rc git.kak: fix blame-jump for commits with special characters 2024-02-13 19:24:24 +11:00
run Fix another case where git tests were hanging 2024-05-12 14:18:17 +10:00

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Regression test
===============

:unified-context-diff: https://en.wikipedia.org/wiki/Diff#Unified_format

Source structure
----------------

----------------------------------------------
.
├── unit
│   └── …
└── compose
    └── …
        ├── [enabled]    → applicability
        ├── [env]        → environment setup
        ├── [rc]         → configuration
        ├── [in]         → start file
        ├── cmd          → command
        ├── [script]     → UI automation
        ├── [out]        → expected end file
        ├── [kak_*]      → expected expansion values
        └── [error]      → expected error
----------------------------------------------

Usage
-----

To test, just type +run [test]+ in the +test+ directory.
It will print each passing test.  If a test fails, a {unified-context-diff}[unified context diff]
is printed showing the tests expected output and the actual output.

Details
-------

+enabled+ is optional.
If it exists and is executable,
it is invoked with no parameters.
If it exits with a non-zero exit code,
the test is assumed to be not applicable to the current environment
(for example, a test for OS-specific integration
isn't useful on a different OS)
and will be silently skipped.

+env+ is optional.
If it exists, it will be sourced before starting Kakoune.

+rc+ is optional
and should contain a sequence of commands,
_e.g._, +set-option+, +define-command+, +declare-option+.
+rc+ is sourced and evaluated before the +cmd+ key sequence is executed.

+in+ is optional
and should contain the initial text loaded into the input buffer
for editing by the +cmd+ key sequence.

+cmd+ is required
and should contain a key sequence that will edit the input buffer.
+cmd+ is executed after the +rc+ command sequence is sourced.

+script+ is optional
and is a shell-script that will be sourced after +cmd+ is executed.
The special +ui_in+ function sends a string
(expected to be a JSON UI message,
see `doc/json_ui.asciidoc` in the Kakoune source)
to the running Kakoune instance,
while the special +ui_out+ function
checks the next JSON UI messages from Kakoune
against its arguments,
and fails the test if any of them are different.

You can also say `ui_out -ignore N` to ignore the next _N_ JSON UI messages,
where _N_ is a positive integer. 

+out+ is optional
and should contain the expected text generated by the +cmd+ key sequence.

If the actual +out+ text
does not match the expected content in the corresponding file,
the unit test will fail.

If there is no +out+
then the unit test will always succeed.

Any +kak_*+ files should match the corresponding expansion
after +cmd+ is complete.
For example, a file named +kak_selection_desc+
should match the +%val{selection_desc}+ expansion.
See `:doc expansions` for a list of available expansions.

If there is an +error+ file,
the test is expected to produce an error.
If Kakoune exits successfully,
or if it fails with the wrong error,
the test is marked as a failure.