| 1 | This directory contains the testsuite for pdfgrep. |
| 2 | |
| 3 | ## Dependencies |
| 4 | |
| 5 | The tests depend on the following packages: |
| 6 | |
| 7 | - dejagnu |
| 8 | - pdflatex |
| 9 | |
| 10 | ## Running |
| 11 | |
| 12 | To run the tests, execute `make check` from the toplevel source |
| 13 | directory. |
| 14 | |
| 15 | The testsuite might output some harmless messages like "WARNING: |
| 16 | Couldn't find the global config file.". What's really important are |
| 17 | any lines beginning with "FAIL:". |
| 18 | |
| 19 | ## Coverage |
| 20 | |
| 21 | To get a test coverage report, install `gcovr` and run configure with |
| 22 | the following arguments: |
| 23 | |
| 24 | ./configure CXXFLAGS="-O0" --enable-coverage |
| 25 | |
| 26 | and then run: |
| 27 | |
| 28 | make clean |
| 29 | make coverage |
| 30 | |
| 31 | This will print a test coverage report to stdout. To get an HTML |
| 32 | report with lcov, run `make cov-report-html`. |
| 33 | |
| 34 | ## Configuration |
| 35 | |
| 36 | The test runs can be configured by editing `testsuite/site.exp`. The |
| 37 | following variables can be set: |
| 38 | |
| 39 | - `disable_poppler_version_check`: Don't mark tests as unsupported if |
| 40 | the poppler version is not recent enough. (This is useful if you |
| 41 | have backported a patch from a later version to your current one). |
| 42 | |
| 43 | ## Writing new tests |
| 44 | |
| 45 | See the existing tests in `testsuite/pdfgrep.tests/` as example on how |
| 46 | to write tests. The utility functions to use are defined in |
| 47 | `testsuite/lib/pdfgrep.exp` and extensively commented. In particular, |
| 48 | the following functions and variables should be of interest: |
| 49 | |
| 50 | ### Variables |
| 51 | |
| 52 | - `test`: The name of the following test. |
| 53 | - `required_poppler_version`: The least poppler version that this test |
| 54 | does require. |
| 55 | - `requires_pcre_support`: Whether this test requires libpcre support. |
| 56 | - `requires_unac_support`: Whether this test requires libunac support. |
| 57 | |
| 58 | ### Procedures |
| 59 | |
| 60 | - `pdfgrep_expect`: Call pdfgrep and expect some output. |
| 61 | - `pdfgrep_expect_x`: Call pdfgrep and expect some output, but mark |
| 62 | this test as known to fail. |
| 63 | - `pdfgrep_expect_error`: Call pdfgrep and expect it to print an error. |
| 64 | - `expect_exit_status`: Compare the exit status of the last spawned |
| 65 | process. |
| 66 | - `mkpdf`: Generate a pdf using latex. |
| 67 | - `clear_pdfdir`: Delete the content of the directory of generated |
| 68 | pdfs. |