This repository now includes a comprehensive regression test suite for safely refactoring import/parse.py.
# One-time setup
./tests/setup_tests.sh
# Refactoring workflow
vim import/parse.py # Make changes
make test # Verify output unchanged| File | Purpose |
|---|---|
tests/test_parse_regression.py |
Main test runner (353 lines) |
tests/setup_tests.sh |
One-time setup script |
tests/README.md |
Full documentation |
tests/QUICKREF.md |
Quick reference card |
tests/EXAMPLE.md |
Complete walkthrough |
tests/SUMMARY.md |
High-level overview |
tests/baseline/ |
Reference output files |
make test # Run regression tests
make test-update # Update baseline
make run-parse # Just run parse.py
make compare # Compare with previous version
make clean # Remove generated files
make help # Show all commandsThe test suite ensures refactoring doesn't break parse.py by:
- Running parse.py to generate fresh output
- Comparing 7 output files against a known-good baseline:
luftrom.geojson- Main airspace (feature-level comparison)luftrom.fl.txt,luftrom.ft.txt,luftrom.m.txt- Text formatsluftrom.openaip- OpenAIP XMLaccsectors.geojson- ACC sectorsxcontest.json- XContest format
- Reporting differences with detailed diagnostics
Detailed comparison checks:
- Feature count
- Feature names (detects missing/new)
- Coordinate counts
- Properties (class, ceiling, floor)
- Fast SHA256 hash comparison
- Line-by-line diff if hashes differ
# Ensure you have good output
cd import && python3 parse.py
# Lock it in as baseline
make test-update# Make a change
vim import/parse.py
# Test it
make test
# If pass: commit
# If fail: investigate and fix OR update baseline if intentional$ make test
INFO: Running parse.py...
INFO: parse.py completed successfully
INFO: ✓ luftrom.geojson: PASS (identical)
INFO: ✓ luftrom.fl.txt: PASS (identical)
...
======================================================================
Total files: 7
Passed: 7
Failed: 0
======================================================================
$ git commit -m "Refactor: Extract coordinate parsing"ERROR: ✗ luftrom.geojson: Files differ
ERROR: Missing features (2): oslo-tma-1, bergen-ctr
Action: Fix your code to restore original behavior
ERROR: ✗ luftrom.geojson: Files differ
ERROR: flesland-tma: coordinate count differs (64 vs 96)
Action: Verify the fix is correct, then make test-update
- ✅ Refactor Confidently - Immediate feedback on regressions
- ✅ Fast Iteration - 2-5 minute test cycle
- ✅ Detailed Diagnostics - See exactly what changed
- ✅ Version Controlled - Baseline in git ensures consistency
- ✅ Simple - Just
make testafter every change
.github/copilot-instructions.md- Added testing section.gitignore- Documented test file handlingMakefile- Added test commands
- Quick Start:
tests/QUICKREF.md - Full Guide:
tests/README.md - Example Walkthrough:
tests/EXAMPLE.md - Implementation Details:
tests/SUMMARY.md
| Goal | Command |
|---|---|
| Set up tests | ./tests/setup_tests.sh |
| Run tests | make test |
| Update baseline | make test-update |
| Verbose output | make test-verbose |
| Run parser only | make run-parse |
| Compare versions | make compare |
| Clean output | make clean |
| Show all commands | make help |
- Baseline represents current behavior, not necessarily correct behavior
- Tests are deterministic - same input = same output
- No mock data needed - uses real AIP sources
- Tests run in ~2-5 minutes (limited by parse.py runtime)
- Run
./tests/setup_tests.shto create baseline - Start refactoring
import/parse.py - Run
make testafter each change - Read
tests/README.mdfor details
Happy refactoring! The tests have your back. 🎯