By default, McRogueFace now exits with code 1 on the first unhandled exception in timer, click, key, or animation callbacks. This prevents repeated exception output that wastes resources in AI-driven development. Changes: - Add exit_on_exception config flag (default: true) - Add --continue-after-exceptions CLI flag to preserve old behavior - Update exception handlers in Timer, PyCallable, and Animation - Signal game loop via McRFPy_API atomic flags - Return proper exit code from main() Before: Timer exceptions repeated 1000+ times until timeout After: Single traceback, clean exit with code 1 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
31 lines
1 KiB
Python
31 lines
1 KiB
Python
#!/usr/bin/env python3
|
|
"""Test for --continue-after-exceptions behavior (Issue #133)
|
|
|
|
This test verifies that:
|
|
1. By default, unhandled exceptions in timer callbacks cause immediate exit with code 1
|
|
2. With --continue-after-exceptions, exceptions are logged but execution continues
|
|
"""
|
|
|
|
import mcrfpy
|
|
import sys
|
|
|
|
def timer_that_raises(runtime):
|
|
"""A timer callback that raises an exception"""
|
|
raise ValueError("Intentional test exception")
|
|
|
|
# Create a test scene
|
|
mcrfpy.createScene("test")
|
|
mcrfpy.setScene("test")
|
|
|
|
# Schedule the timer - it will fire after 50ms
|
|
mcrfpy.setTimer("raise_exception", timer_that_raises, 50)
|
|
|
|
# This test expects:
|
|
# - Default behavior: exit with code 1 after first exception
|
|
# - With --continue-after-exceptions: continue running (would need timeout or explicit exit)
|
|
#
|
|
# The test runner should:
|
|
# 1. Run without --continue-after-exceptions and expect exit code 1
|
|
# 2. Run with --continue-after-exceptions and expect it to not exit immediately
|
|
|
|
print("Test initialized - timer will raise exception in 50ms")
|