2014-06-30 12:22:50 +02:00
|
|
|
|
Regression test
|
|
|
|
|
===============
|
|
|
|
|
|
|
|
|
|
:unified-context-diff: https://en.wikipedia.org/wiki/Diff#Unified_format
|
|
|
|
|
|
|
|
|
|
Source structure
|
|
|
|
|
----------------
|
|
|
|
|
|
|
|
|
|
----------------------------------------------
|
|
|
|
|
.
|
|
|
|
|
├── unit
|
|
|
|
|
│ └── …
|
|
|
|
|
└── compose
|
|
|
|
|
└── …
|
2020-11-21 06:57:08 +01:00
|
|
|
|
├── [enabled] → applicability
|
2024-02-12 23:48:29 +01:00
|
|
|
|
├── [env] → environment setup
|
2017-02-16 21:32:01 +01:00
|
|
|
|
├── [rc] → configuration
|
2014-06-30 12:22:50 +02:00
|
|
|
|
├── [in] → start file
|
2020-11-21 06:57:08 +01:00
|
|
|
|
├── cmd → command
|
|
|
|
|
├── [script] → UI automation
|
|
|
|
|
├── [out] → expected end file
|
|
|
|
|
├── [kak_*] → expected expansion values
|
|
|
|
|
└── [error] → expected error
|
2014-06-30 12:22:50 +02:00
|
|
|
|
----------------------------------------------
|
|
|
|
|
|
|
|
|
|
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 test’s expected output and the actual output.
|
2017-02-16 21:32:01 +01:00
|
|
|
|
|
|
|
|
|
Details
|
|
|
|
|
-------
|
|
|
|
|
|
2020-11-21 06:57:08 +01:00
|
|
|
|
+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.
|
|
|
|
|
|
2024-02-12 23:48:29 +01:00
|
|
|
|
+env+ is optional.
|
|
|
|
|
If it exists, it will be sourced before starting Kakoune.
|
|
|
|
|
|
2017-02-16 21:32:01 +01:00
|
|
|
|
+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.
|
|
|
|
|
|
2020-11-21 06:57:08 +01:00
|
|
|
|
+in+ is optional
|
|
|
|
|
and should contain the initial text loaded into the input buffer
|
|
|
|
|
for editing by the +cmd+ key sequence.
|
|
|
|
|
|
2017-02-16 21:32:01 +01:00
|
|
|
|
+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.
|
|
|
|
|
|
2020-11-21 06:57:08 +01:00
|
|
|
|
+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.
|
2017-02-16 21:32:01 +01:00
|
|
|
|
|
2020-11-21 06:57:08 +01:00
|
|
|
|
You can also say `ui_out -ignore N` to ignore the next _N_ JSON UI messages,
|
|
|
|
|
where _N_ is a positive integer.
|
2017-02-16 21:32:01 +01:00
|
|
|
|
|
|
|
|
|
+out+ is optional
|
|
|
|
|
and should contain the expected text generated by the +cmd+ key sequence.
|
|
|
|
|
|
2020-11-21 06:57:08 +01:00
|
|
|
|
If the actual +out+ text
|
2017-02-16 21:32:01 +01:00
|
|
|
|
does not match the expected content in the corresponding file,
|
|
|
|
|
the unit test will fail.
|
|
|
|
|
|
2020-11-21 06:57:08 +01:00
|
|
|
|
If there is no +out+
|
2017-02-16 21:32:01 +01:00
|
|
|
|
then the unit test will always succeed.
|
|
|
|
|
|
2020-11-21 06:57:08 +01:00
|
|
|
|
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.
|