typst/tests/README.md

42 lines
1.1 KiB
Markdown
Raw Normal View History

# Tests
2021-02-20 19:53:40 +03:00
## Directory structure
Top level directory structure:
- `typ`: Input files.
- `res`: Resource files used by tests.
2021-02-20 19:53:40 +03:00
- `ref`: Reference images which the output is compared with to determine whether
a test passed or failed.
- `png`: PNG files produced by tests.
- `pdf`: PDF files produced by tests.
2021-02-07 15:27:03 +03:00
## Running the tests
Running the integration tests (the tests in this directory).
2021-02-07 15:27:03 +03:00
```bash
cargo test --test typeset
```
2021-02-07 15:27:03 +03:00
Running all tests whose names contain the word `filter`.
```bash
2021-02-20 19:53:40 +03:00
cargo test --test typeset filter
2021-02-07 15:27:03 +03:00
```
To make the integration tests go faster they don't generate PDFs by default.
Pass the `--pdf` flag to generate those. Mind that PDFs are not tested
automatically at the moment, so you should always check the output manually when
making changes.
```bash
cargo test --test typeset -- --pdf
```
2021-02-20 19:53:40 +03:00
## Creating new tests
To keep things small, please optimize reference images before committing them.
When you use the approve buttom from the Test Helper (see the `tools` folder)
this happens automatically if you have `oxipng` installed.
```bash
# One image
oxipng -o max path/to/image.png
# All images
2021-02-20 19:53:40 +03:00
oxipng -r -o max tests/ref
```