mirror of
https://github.com/javl/image2cpp.git
synced 2026-09-11 09:03:04 +00:00
Add an initial version of our testing suite
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
# image2cpp test suite
|
||||
|
||||
Test uses the real `index.html` file and scripts in a headless browser
|
||||
using `Playwright`. Output is compared against known valid (`golden`) files.
|
||||
This way we are testing the output of the actual tool, not a reimplementation.
|
||||
|
||||
## Setup and running
|
||||
|
||||
```
|
||||
python3 -m venv .venv
|
||||
source .venv/bin/activate
|
||||
pip install -r tests/requirements.txt
|
||||
playwright install chromium
|
||||
```
|
||||
|
||||
To run:
|
||||
```
|
||||
python3 tests/test_conversions.py
|
||||
```
|
||||
|
||||
Prints `ok`/`FAIL` per scenario and exits non-zero if anything doesn't
|
||||
match.
|
||||
|
||||
## Updating golden files and test image
|
||||
|
||||
To generate the test image again (only needed if we changed the image):
|
||||
```
|
||||
python3 tests/generate_test_image.py
|
||||
```
|
||||
|
||||
After an intentional change to the conversion logic, regenerate the
|
||||
golden output and optionally review the diff before committing:
|
||||
|
||||
```
|
||||
python3 tests/test_conversions.py --update
|
||||
git diff tests/golden
|
||||
```
|
||||
Reference in New Issue
Block a user