A simple Python script that watches a folder for file changes and creates an HTML visualization when tests fail.
- 🔍 File Watcher: Monitors a folder for any file changes
- 🧪 Test Runner: Automatically runs tests when files change
- ❌ Error Capture: Captures error messages when tests fail
- 📊 HTML Visualization: Creates simple HTML files showing:
- Two boxes (code change → test failure)
- A red arrow connecting them
- Full error output displayed below
pip install -r requirements.txtpython redliner.py <watch_path> "<test_command>"Python with pytest:
python redliner.py . "python -m pytest"Python with unittest:
python redliner.py . "python -m unittest discover"JavaScript with npm:
python redliner.py ./src "npm test"Watch specific directory:
python redliner.py ./src "python -m pytest tests/"- The script monitors the specified directory for file changes
- When a file is modified or created, it runs your test command
- If tests fail, it generates an HTML file in the
output/directory - Open the HTML file in your browser to see the visualization
HTML files are saved in the output/ directory with timestamps:
test_failure_20251011_143022.htmltest_failure_20251011_143145.html- etc.
Each file contains:
- Timestamp of the failure
- Name of the changed file
- Visual flow: CODE CHANGE → TEST FAILED
- Complete error output
The script includes a 1-second debounce to avoid running tests too frequently when multiple files change rapidly.
Press Ctrl+C to stop watching for changes.
To test the script, create a simple test file:
test_example.py:
def test_always_fails():
assert 1 == 2, "This test is designed to fail!"Then run:
python redliner.py . "python -m pytest test_example.py"Modify test_example.py and watch as an HTML visualization is generated in the output/ folder!