kakoune/test
Johannes Altmanninger aad0c7cef8 Don't capture local-scoped faces in prompt
ASan shows that we resolve a face spec owned by a freed stack variable.

    =================================================================
    ==2263300==ERROR: AddressSanitizer: stack-use-after-return on address 0x7a9316c33918 at pc 0x633ea421d8ea bp 0x7ffca001e980 sp 0x7ffca001e970
    READ of size 8 at 0x7a9316c33918 thread T0
        ...
        #6 0x633ea421d8e9 in Kakoune::FaceRegistry::resolve_spec(Kakoune::FaceSpec const&) const src/face_registry.cc:128
        ...

    Address 0x7a9316c33918 is located in stack of thread T0 at offset 2328 in frame
        #0 0x633ea427a095 in operator() src/commands.cc:2267

      This frame has 26 object(s):
        [32, 36) '<unknown>'
        ...
        [544, 560) 'disable_hooks' (line 2269)
        ...
        [928, 2432) 'local_scope' (line 2271) <== Memory access at offset 2328 is inside this variable
2024-04-27 16:29:57 +10:00
..
commands Fix edit-fifo-noscroll test on BSD 2024-02-18 09:58:53 +11: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 Adjust test/highlight/rust/value 2024-04-27 16:29:57 +10:00
hooks Immediately execute ModuleLoaded hooks for already loaded modules 2023-02-14 21:31:29 +11:00
indent Fix some corner cases in c-family indentation 2023-10-25 12:51:16 +11:00
normal Make insert repeat (.) more consistent 2024-02-24 05:18:56 +01:00
prompt Add tests for prompt history behaviour 2022-06-07 14:01:23 +10:00
regression Don't capture local-scoped faces in prompt 2024-04-27 16:29:57 +10:00
shell Make shell-script-candidates completer run in the background 2023-11-14 21:39:03 +11:00
tools Another try to fix blame-jump-message test flakyness 2024-02-18 19:00:33 +11:00
README.asciidoc rc git.kak: fix blame-jump for commits with special characters 2024-02-13 19:24:24 +11:00
run Remove unused -within-next ui_out switch 2024-02-18 15:46:24 +11: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.