Add sections anchors

This commit is contained in:
Igor Támara 2025-10-29 12:00:08 -05:00 committed by CJ van den Berg
parent 6b5bf768f2
commit edf3a4d51a
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
3 changed files with 102 additions and 31 deletions

View file

@ -17,12 +17,13 @@ and also an
To work with tests you will need to:
* [Clone](https://github.com/neurocyte/flow) the repo
* [Clone](https://github.com/neurocyte/flow) the repository
* Have [zig installed](https://ziglang.org/download/). Highly recommended to use
[anyzig](https://github.com/marler8997/anyzig)
Flow tests are placed in the directory `test`.
[]($section.id("running_tests"))
## Running the tests
To run the full set of tests, inside flow, use `F5`, which runs a task that
@ -35,6 +36,7 @@ zig build test
it will work if flow was invoked from the project root, which is the same
place that you would normally run the tests when on the terminal.
[]($section.id("running_a_test"))
### Run a particular test
To run an specific test use `Dtest-filter` option with the name of your
@ -44,6 +46,7 @@ test, i.e., for the test called **test_block_name** use:
zig build test -Dtest-filter="test_block_name"
```
[]($section.id("first_test"))
## Adding tests
Tests are needed when:
@ -61,9 +64,10 @@ exercises the functionality and makes proof of it behaving as expected.
Maintain the logic test as simple as possible. It's possible to add
additional functions to make the tests readable and extendable though.
public functions are stratightforward tested, while there are some
public functions are straightforward tested, while there are some
conventions for testing private functions.
[]($section.id("private_functions_testing"))
### Testing private functions
Some internal logic of a module can be tested without the need to be
@ -106,6 +110,7 @@ try helix.test_internal.move_cursor_long_word_right_end(root, cursor, the_metric
In case there is need of a new test file for concern separation, continue
to the next section.
[]($section.id("new_test_file"))
## Adding a new test file
Three steps are required for adding a new test file:
@ -115,6 +120,7 @@ Three steps are required for adding a new test file:
1. Optionally, make available a module to the build system
for your particular test
[]($section.id("create_test_file"))
### Create the test file
Place your test file under `test` directory, the name should be prefixed
@ -123,6 +129,7 @@ with `tests_`.
For the rest of this section we will use as a sample
`tests_project_manager.zig`.
[]($section.id("linking_tests"))
### Include the test file
Tests files are linked via `test/tests.zig`, import your new test_file
@ -132,6 +139,7 @@ alphabetically as in our sample:
pub const project_manager = @import("tests_project_manager.zig");
```
[]($section.id("import_in_build_zig"))
### Import required modules when building tests
In `build.zig` import the required module under `tests.root_module`, for
@ -144,8 +152,10 @@ tests.root_module.addImport("project_manager", project_manager_mod);
[Sample](https://github.com/neurocyte/flow/commit/e053a0dcf4b4c93f1ce1fe6d14a3c04e886d393c)
of adding a new test file for project manager.
[]($section.id("faq"))
## FAQ on tests
[]($section.id("import_editor"))
### I need to test something that requires importing the editor ¿What do I do?
There are two paths from here:
@ -154,15 +164,17 @@ There are two paths from here:
1. Extend the tests to automate via external tools
[]($section.id("lower_level"))
### Refactor to test lower level functions
Refactor the functions involved in the functionality to make them
not rely directly with editor and other higher level componets, and
not rely directly with editor and other higher level components, and
test the lower level ones.
An example of this can be seen in commands
### Use aditional tools to test a running flow session
[]($section.id("end_to_end"))
### Use additional tools to test a running flow session
Use additional tools to invoke the built editor and send keys to
it, modify a file and then compare the initial contents of the file
@ -171,7 +183,7 @@ and the resulting contents of your file and the expected ones.
If in doubt about how to do something,
[please ask](https://discord.com/invite/4wvteUPphx).
[]($section.id("next"))
## Next steps
* [How to contribute](/docs/contributing)