Prevent missing regex_patterns (#15)

This commit is contained in:
Johan 2026-01-10 17:51:12 +02:00 committed by GitHub
parent 599fd6209f
commit 783609d2e3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
195 changed files with 1617 additions and 562 deletions

View file

@ -17,9 +17,11 @@ The repository a script to generate the specification based on the TRaSH-Guide d
### Requirements
The scripts utilize UV for easy package management, ensure it's installed by following the [official instructions](https://github.com/astral-sh/uv?tab=readme-ov-file#installation).
- **Python 3.13+**
- **UV** for package management - install via [official instructions](https://github.com/astral-sh/uv?tab=readme-ov-file#installation)
- **TRaSH-Guides data** - a local clone with JSON data in `docs/json/` (not automatically cloned)
Additionally it's expected that you have a local folder with a TRaSH-Guides clone containing the JSON data ([docs/json within the TRaSH-Guides repository](https://github.com/TRaSH-Guides/Guides/tree/master/docs/json)). The script does not pull any data.
Dependencies are defined in `pyproject.toml` and managed by UV.
### Running the script
@ -30,3 +32,48 @@ uv run scripts/generate.py /path/to/trash-guides/docs/json .
```
It will clear any potentially pre-existing output and generate new output based on the provided TRaSH-Guides folder.
## Testing
This project includes automated tests to validate the integrity of generated output files.
### Running Tests
The test suite validates that:
- Every pattern referenced in custom formats exists as a regex pattern file
- Every custom format referenced in profiles exists as a custom format file
```bash
# Install dev dependencies
uv sync --extra dev
# Run all tests
uv run pytest tests/ -v
# Run specific test files
uv run pytest tests/test_custom_formats.py -v
uv run pytest tests/test_profiles.py -v
# Run with coverage report
uv run pytest tests/ --cov=scripts --cov-report=term
```
### Test Validation
The tests ensure data integrity across the generated output:
- **Custom Format Tests** - Validates all pattern references in `custom_formats/` exist in `regex_patterns/`
- **Profile Tests** - Validates all custom format references in `profiles/` exist in `custom_formats/`
If a test fails, it will clearly indicate which files contain broken references, making it easy to identify and fix issues.
## Code Quality
This project uses **pylint** for static code analysis and quality checks.
```bash
# Install dev tools
uv sync --extra dev
# Run linting
uv run pylint scripts tests
```