Skip to content

Commit be28bd5

Browse files
committed
docs: main - writing tests line breaks
1 parent b541821 commit be28bd5

1 file changed

Lines changed: 33 additions & 58 deletions

File tree

docs/src/code/writing-tests.adoc

Lines changed: 33 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,17 @@
33

44
== The test framework
55

6-
The code base has unit and integration tests that can be executed
7-
automatically to ensure the program works as intended. Such tests are
8-
often written to trigger a bug and to ensure the bug is detected if it
9-
resurfaces in the future, but also to validate behavior of components
10-
and interfaces.
6+
The code base has unit and integration tests that can be executed automatically to ensure the program works as intended.
7+
Such tests are often written to trigger a bug and to ensure the bug is detected if it resurfaces in the future, but also to validate behavior of components and interfaces.
118

12-
The tests are collected in the `tests/` directory. The individual tests
13-
are in subdirectories of this directory. The tests are grouped in
14-
directories.
9+
The tests are collected in the `tests/` directory.
10+
The individual tests are in subdirectories of this directory.
11+
The tests are grouped in directories.
1512

1613
== Running tests
1714

18-
The tests are executed by the `scripts/runtests` script generated from
19-
`scripts/runtests.in` during build. The runtests script will by default
20-
locate tests to run under `tests/`, but can be limited to only run a
21-
limited set of tests by specifying the directory of the test or tests
22-
as argument(s).
15+
The tests are executed by the `scripts/runtests` script generated from `scripts/runtests.in` during build.
16+
The runtests script will by default locate tests to run under `tests/`, but can be limited to only run a limited set of tests by specifying the directory of the test or tests as argument(s).
2317

2418
Here is an example running only the tests in `tests/lathe/`
2519

@@ -29,13 +23,10 @@ Running test: tests/lathe
2923
Runtest: 1 tests run, 1 successful, 0 failed + 0 expected, 0 skipped
3024
----
3125

32-
The runtests script looks for all files named _test_, _test.sh_ and
33-
_test.hal_ below the directories specified on the command line, or under
34-
`tests/` if no command line argument is specified. These files
35-
represent three different ways to run the tests.
26+
The runtests script looks for all files named `test`, `test.sh` or `test.hal` below the directories specified on the command line, or under `tests/` if no command line argument is specified.
27+
These files represent three different ways to run the tests.
3628

37-
The _runtests_ script accepts the following arguments, see the output
38-
from `scripts/runtests -h` for the authorative list:
29+
The _runtests_ script accepts the following arguments, see the output from `scripts/runtests -h` for the authorative list:
3930
----
4031
-n do not remove temporary files for successful tests.
4132
-s stop after any failed test.
@@ -46,79 +37,63 @@ from `scripts/runtests -h` for the authorative list:
4637
----
4738
== Writing tests
4839

49-
Make sure the test can run successfully without a working X11 display,
50-
i.e. with the DISPLAY environment variable unset.
40+
Make sure the test can run successfully without a working X11 display, i.e. with the DISPLAY environment variable unset.
5141

5242
1. Create a folder in `tests/`.
5343
2. Provide one test script.
5444
3. Evaluate the output with one of the options below.
5545

56-
These are the files considered in the directory with the individual
57-
tests:
46+
These are the files considered in the directory with the individual tests:
5847

5948
.Test script (only one of these three)
6049

6150
test::
62-
A program that is executed and its exit code and output checked using
63-
either checkresult or expected.
51+
A program that is executed and its exit code and output checked using either checkresult or expected.
6452

6553
test.sh::
66-
A bash script that is executed and its exit code and output checked using
67-
either checkresult or expected.
54+
A bash script that is executed and its exit code and output checked using either checkresult or expected.
6855

6956
test.hal::
70-
A HAL script that is executed using `halrun -f test.hal` and its exit code
71-
and output checked using either checkresult or expected.
57+
A HAL script that is executed using `halrun -f test.hal` and its exit code and output checked using either checkresult or expected.
7258

7359
.Test evaluation
7460

7561
expected::
76-
A file whose content is compared to the output from running the test
77-
scripts. If the test output is identical to the content of the
78-
expected file, the test succeeds.
62+
A file whose content is compared to the output from running the test scripts.
63+
If the test output is identical to the content of the expected file, the test succeeds.
7964

8065
checkresult::
81-
An excutable file to perform more complex validation than just comparing
82-
the output of a test script. It gets the filename of the test program as
83-
its command line argument. The exit code of this program controls the result
84-
of the test. If both `expected` and `checkresult` exist, only `checkresult`
85-
is consulted to validate the test output.
66+
An excutable file to perform more complex validation than just comparing the output of a test script.
67+
It gets the filename of the test program as its command line argument.
68+
The exit code of this program controls the result of the test.
69+
If both `expected` and `checkresult` exist, only `checkresult` is consulted to validate the test output.
8670

8771
xfail::
88-
If this file exist, a test failure is expected and does not cause
89-
runtests to return an exit code signaling an error.
72+
If this file exist, a test failure is expected and does not cause runtests to return an exit code signaling an error.
9073

9174
skip::
9275
If this file exist, the test is skipped and not executed at all.
9376

9477
control::
95-
This file can be used to flag specific needs in the test. At the
96-
moment, the use of _sudo_ can be flagged, and tests requiring sudo
97-
can be skipped when using `runtests -u`. To flag such requirements,
98-
add a line with `Restrictions: sudo` to this file.
78+
This file can be used to flag specific needs in the test.
79+
At the moment, the use of _sudo_ can be flagged, and tests requiring sudo can be skipped when using `runtests -u`.
80+
To flag such requirements, add a line with `Restrictions: sudo` to this file.
9981

10082
== Some testing approaches
10183

102-
There are various ways to structure a test, depending on what one wants
103-
to test. Here are a few ideas on how to do it.
84+
There are various ways to structure a test, depending on what one wants to test.
85+
Here are a few ideas on how to do it.
10486

10587
=== Non-interactive "GUI"
10688

107-
If you want to test some operations in the user interface, a useful
108-
approach is is to write a custom "GUI" simulating the operations.
109-
This can be done by creating a normal LinuxCNC setup and pointing the
110-
[DISPLAY] DISPLAY value to a script that does the operations needed to
111-
test the behaviour.
89+
If you want to test some operations in the user interface, a useful approach is is to write a custom "GUI" simulating the operations.
90+
This can be done by creating a normal LinuxCNC setup and pointing the [DISPLAY] DISPLAY value to a script that does the operations needed to test the behaviour.
11291

113-
Examples of this approach can be found in `tests/halui/jogging/` and
114-
`tests/interp/subroutine-return/`.
92+
Examples of this approach can be found in `tests/halui/jogging/` and `tests/interp/subroutine-return/`.
11593

11694
=== Recording HAL pin transitions
11795

118-
Using the _sampler_ and _halsampler_ HAL components, one can set up a
119-
HAL configuration and collect pin value settings and changes and dump
120-
the result to stdout (or a file). The end result can then be compared
121-
with the expected output to verify if HAL behaves as expected.
96+
Using the _sampler_ and _halsampler_ HAL components, one can set up a HAL configuration and collect pin value settings and changes and dump the result to stdout (or a file).
97+
The end result can then be compared with the expected output to verify if HAL behaves as expected.
12298

123-
Examples of this approach can be found in `tests/multiclick/` and
124-
`tests/stepgen.2/`.
99+
Examples of this approach can be found in `tests/multiclick/` and `tests/stepgen.2/`.

0 commit comments

Comments
 (0)