1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
# yanglint testing
Testing yanglint is divided into two ways.
It is either tested in interactive mode using the tcl command 'expect' or non-interactively, classically from the command line.
For both modes, unit testing was used using the tcl package tcltest.
## How to
The sample commands in this chapter using `tclsh` are called in the `interactive` or `non-interactive` directories.
### How to run all yanglint tests?
In the build directory designated for cmake, enter:
```
ctest -R yanglint
```
### How to run all yanglint tests that are in interactive mode?
In the interactive directory, run:
```
tclsh all.tcl
```
### How to run all yanglint tests that are in non-interactive mode?
In the non-interactive directory, run:
```
tclsh all.tcl
```
### How to run all unit-tests from .test file?
```
tclsh clear.test
```
or alternatively:
```
tclsh all.tcl -file clear.test
```
### How to run one unit-test?
```
tclsh clear.test -match clear_ietf_yang_library
```
or alternatively:
```
tclsh all.tcl -file clear.test -match clear_ietf_yang_library
```
### How to run unit-tests for a certain yanglint command?
Test names are assumed to consist of the command name:
```
tclsh all.tcl -match clear*
```
### How do I get more detailed information about 'expect' for a certain test?
In the interactive directory, run:
```
tclsh clear.test -match clear_ietf_yang_library -load "exp_internal 1"
```
### How do I get more detailed dialog between 'expect' and yanglint for a certain test?
In the interactive directory, run:
```
tclsh clear.test -match clear_ietf_yang_library -load "log_user 1"
```
### How do I suppress error message from tcltest?
Probably only possible to do via `-verbose ""`
### How can I also debug?
You can write commands `interact` and `interpreter` from 'Expect' package into some test.
However, the most useful are the `exp_internal` and `log_user`, which can also be written directly into the test.
See also the rlwrap tool.
You can also use other debugging methods used in tcl programming.
### Are the tests between interactive mode and non-interactive mode similar?
Sort of...
- regex \n must be changed to \r\n in the tests for interactive yanglint
### I would like to add a new "ly_" function.
Add it to the ly.tcl file.
If you need to call other subfunctions in it, add them to namespace ly::private.
### I would like to use function other than those prefixed with "ly_".
Look in the common.tcl file in the "uti" namespace,
which contains general tcl functions that can be used in both interactive and non-interactive tests.
|