refactor: Simplify template logic - reduce from 6 to 3 categories, remove variant_type, keep validation, remove tests

Simplified template logic: reduced from 6 categories (required, modifiers, optional, versioned, conditional, flags) to 3 categories (required, modifiers, optional). Removed variant_type and replaced with modifier-based approach (version, bootloader replaced, hardware_support). All validation methods kept for recipe generation and validation. Removed tests directory (tests/test_recipe_generator.py, tests/integration/, tests/container/). Removed non-ISO workflows (validate-recipes, test-generation, container-tests, validate-ingredients). Updated Makefile, requirements.txt, and documentation. All 20 recipes successfully generated, validated, and flattened.
This commit is contained in:
Lukas Greve
2026-03-27 12:13:51 +01:00
parent 789e0e05d4
commit 288ed0a249
79 changed files with 83 additions and 1464 deletions
-116
View File
@@ -392,122 +392,6 @@ done
---
## Testing
Phyllome OS uses a comprehensive test suite with 36+ tests covering unit, integration, and regression scenarios.
### Test Suite Structure
| Test File | Tests | Coverage |
|-----------|-------|----------|
| `tests/test_recipe_generator.py` | 36 | Unit tests for RecipeGenerator |
| `tests/integration/test_integration.py` | 5+ | End-to-end workflow tests |
| `tests/integration/test_ingredients.py` | ~15 | Fragment validation |
| `tests/integration/test_recipe_composition.py` | ~10 | Recipe generation |
| `tests/integration/test_semantic_validation.py` | ~10 | pykickstart validation |
| `tests/integration/test_golden_masters.py` | ~5 | Regression tests |
### Running Tests
```bash
cd scripts
# All tests (unit + integration)
make test
# Unit tests only
python3 -m pytest tests/test_recipe_generator.py -v
# Integration tests only
make test-integration
# Containerized tests
make test-container
# or: podman run --rm -v .:/phyllomeos:ro phyllo/test-runner
```
**Expected output:**
```
============================= test session starts =============================
collected 41 items
tests/test_recipe_generator.py ............. [ 29%]
tests/integration/test_integration.py ..... [ 43%]
...
============================== 41 passed in 2.34s ==============================
```
### Fragment Validation Test
```bash
# Test all ingredients with pykickstart
for fragment in $(find ingredients -name "*.ks"); do
python3 -c "
from pykickstart.parser import KickstartParser
from pykickstart.version import makeVersion, DEVEL
parser = KickstartParser(makeVersion(DEVEL))
parser.readKickstart(open('$fragment').read())
" && echo "$fragment" || echo "$fragment"
done
```
### Adding New Tests
**Unit test example:**
```python
# tests/test_recipe_generator.py
def test_generate_recipe_with_new_modifier():
"""Test recipe generation with custom modifier."""
content = self.generator.generate_recipe(
'virtual-desktop', '43',
desktop='gnome',
storage='standard',
security='secure'
)
assert '# A recipe for a virtual desktop' in content
assert '%ksappend ingredients/shared/desktop/gnome/packages.ks' in content
```
**Integration test example:**
```python
# tests/integration/test_recipe_composition.py
def test_manifest_generates_correct_count():
"""Test manifest generates expected number of recipes."""
result = subprocess.run(
['python3', 'generate_recipe.py',
'--manifest', 'recipes_manifest.yaml',
'--output-dir', '../recipes/'],
capture_output=True, text=True
)
assert result.returncode == 0
recipe_count = len(list(Path('../recipes').glob('*.cfg')))
assert recipe_count == 16
```
### Golden Master Tests
Golden masters (expected outputs) are stored in `tests/fixtures/expected_recipes/`:
```bash
# View expected output for virtual-desktop
cat tests/fixtures/expected_recipes/virtual-desktop_43.cfg
```
**To update golden masters** (after intentional changes):
```bash
# Generate and compare
python3 -m pytest tests/integration/test_golden_masters.py -v
```
---
## CI/CD
The project uses Gitea Actions for automated testing and building.