Where `merge1` and `update` are names of test files, eg `test/update.test`.
36
37
Options are:
38
39
* `-quiet` prints only failures, skipped files and the summary.
40
* `-verbose` prints the output of every `fossil` command.
41
* `-strict` counts the failure of a known bug as a failure.
42
* `-halt` stops at the first failure.
43
* `-keep` leaves the temporary repositories in place.
44
* `-prot` also writes the output to the file `prot`.
45
* `-trials N` sets how many random trials fuzz tests (delta1, merge2, …)
46
run per input kind. The default is 20 (5 for expensive `large` /
47
`repeats` inputs). Use `-trials 100` for the historical full fuzz.
48
This flag is only the fuzz loop count; it does not select
49
`-assurance` cases.
50
* `-assurance smoke|ci|stress` selects how thoroughly the tests run.
51
The default is `smoke`, which skips `powerloss`. It also sets the
52
cases that `unicode-pathnames` and `utf` run:
53
- `unicode-pathnames`: `smoke` is one pair per fold-behavior class;
54
`ci` is the full hand-written lists; `stress` adds generated pairs.
55
At startup the harness classifies the temporary filesystem once
56
(ASCII case, NFC/NFD, and sharp-s versus `ss`). Predictions use
57
that classification with Fossil's `case-sensitive` setting
58
(byte-for-byte when on; Unicode D145 caseless match when off).
59
- `utf`: `smoke` is a stratified edge set of `test-looks-like-utf`
60
cells; `ci` is the full BOM×payload×extra product; `stress` adds
61
generated payloads. A Tcl predictor scores each LOOK_*/BOM line
62
for both yes and no.
63
Unmet predictions fail the run.
64
65
`make test TESTFLAGS="-quiet update"` passes options and names via `make`.
66
67
Assurance recipes:
68
69
```sh
70
make test # smoke (default)
71
make test TESTFLAGS="-assurance ci" # full current coverage
72
make test TESTFLAGS="-assurance stress" # ci plus generated cases
73
```
74
75
`tester.tcl` exits with status 0 when all tests pass, 1 when one or more tests
76
fail. Failed tests are reported with what it expected vs what it got. The
77
summary lists skipped files with a reason, and all known bugs reported as
78
`FAILED (knownBug)`. Skips and known bugs do not change the exit status unless
79
`-strict` is given.
80
81
A new test should only require adding another `.test` file.
82
83
## Requirements
84
85
* Tcl 8.6 or later, we also test with Tcl 9.0 which is now common. `configure` finds `tclsh`, and `make test` fails if it finds none.
86
* A writable temporary directory, from `TMPDIR`, `TEMP` or `TMP`, falling back to `/tmp`. All writes are made to the temporary directory, except with `-prot`
87
which writes a session log to wherever it was started from.
88
* `src/` which must be at the same level in the same directory as `test/`, reflecting the source tree layout. The tests (at least) `settings.test` and `settings-repo.test` need the source to do their job.
89
90
The following tests are skipped when their requirements are missing:
91
92
| Needs | Test files |
93
| --- | --- |
94
| a TCP connection over the loopback interface | `unversioned`, and the HTTP clone in `powerloss` |
95
| `-assurance ci` or `stress` | `powerloss` |
96
| a C compiler (`cc`, or `CC`), `LD_PRELOAD`, `tools/powerloss/powerloss.c` from the source tree, and a Fossil that isn't statically linked | `powerloss` |
97
| `configure --json` | `json` |
98
| `configure --with-th1-docs` | `th1-docs` |
99
| `configure --with-th1-hooks` | `th1-hooks` |
100
| `configure --with-tcl` | `th1-tcl` |
101
102
[`tools/powerloss/README-POWERLOSS.md`](../tools/powerloss/README-POWERLOSS.md) describes the `powerloss` library dependency.
103
104
None of the tests need network access. That doesn't mean all network-related tests will work, because some isolated environments don't even have loopback and
105
the test suite detects this.
106
107
## Coverage
108
109
| Area | Test files |
110
| --- | --- |
111
| Check-ins and the working tree | `amend`, `clean`, `commit-warning`, `mv-rm`, `revert`, `stash`, `symlinks`, `unicode-pathnames`, `update` |
112
| Branches and tags | `branch-tag` |
113
| Merges, cherrypicks, backouts, and annotate and blame after them | `merge1` to `merge6`, `merge-history`, `merge_exe`, `merge_renames`, `merge_renames_2`, `merge_warn` |
114
| Commands interrupted by a power loss or a killed process | `powerloss` |
115
| Git export and import, bundles, patches, ZIP and tarball archives | `roundtrip` |
Each `NAME.test` file is a Tcl script sourced by `tester.tcl`. `test_setup` creates and opens a repository in a temporary directory. `fossil ARGS` runs the
126
executable being tested and sets `RESULT` to its output and `CODE` to 0 if the command succeeded and did not write anything to standard error, or 1 otherwise. `test_eq NAME ACTUAL EXPECTED` and `test_match NAME ACTUAL PATTERN`
127
report both values when they fail, and `test NAME EXPRESSION` gives the report. `test_skip REASON` skips the rest of the file, `test_skip_part REASON`
128
reports a few skipped tests while the file continues, and `test_fail_then_return NAME
129
REASON` records a failed setup step and stops the file. A last argument of `knownBug` to any of the `test` procedures marks a known bug as described above.
130
131
## Maintaining the tests
132
133
First step is noticing bugs. One pattern is when Fossil's output changes causing tests that rely on changed output to fail. `tester.tcl` prints the expected and the actual text for each but this won't always be obvious. It's possible that output changes may mask a code failure too.
134
135
If you suspect an output-change bug, use `-verbose` to print the output of every command, and `-keep` to leave test repos in place for inspection. `rewrite-test-output.tcl` replaces hashes, process IDs and temporary paths in the output of a run with fixed strings, so you can use `diff` to compare two runs. You should then be able to update the expected output text.
136
137
When a test finds a fault that is not yet fixed, add `knownBug` as the test's last argument, so that the suite still exits with status 0. A known bug that passes is reported as `OK (knownBug)?`. Don't forget to remove `knownBug` when you're sure the fault is fixed.
138
139
If the known bug is the exit status of a `fossil` command, add `-knownBug` to that command too. Otherwise the command prints an `ERROR` line on every run, even with `-quiet`. With `-knownBug` you only see the error line under `-strict`.
140
141
A test marked `knownBug` should fail on every applicable system. If the fault only shows up in some environments, the test must set up the relevant environment. If Fossil really does behave differently on some system depending how the system is configured (for example decomposed pathnames on macOS, which vary depending whether the filesystem is HFS+ or APFS) the test must check the behavior. The test suite avoids operating system names by testing for behaviors instead, wherever possible. If a test needs something the system might not have, that becomes a requirement and you can use `test_skip` for.
142
143
`fixed_word_lines NLINE` is a procedure in `tester.tcl` that returns generated text as a string, the same text on every run. `delta1.test` and `merge2.test` use it for their input. If your new test needs text to work on start with this. Look at delta and merge tests for examples of how to use this with character encodings.
144
145
Beware of global variables! If you feel you really have to create a new global variable, be sure there isn't a collision with other files. Some future design
146
of tester.tcl should avoid this problem.
147
148
`make test` runs only the `.test` files. The other scripts in `test/` are run by hand:
149
150
* `release-checklist.wiki` lists the checks to make before a release, with the `.wiki` and `.md` pages they use.
151
* `many-www.tcl` requests about 10,000 web pages from an open checkout with `fossil test-http` and times each, to find crashes and slow pages. `valgrind-www.tcl` requests hundreds of pages under valgrind to find memory errors.
152
* `update-test-1.sh` and `update-test-2.sh` run `fossil update` scenarios in an empty directory.
153
* `link-tester.html` steps through a list of links in `fossil ui`, for checking each page by eye.
154
155
The remaining files are helper scripts and test data.