diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2024-01-12 03:03:31 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2024-01-12 03:22:43 -0800 |
commit | 57fb2d4b57db3fef5245d40e16f5ea811c3806a4 (patch) | |
tree | cf0bb86a8224323f67c798cf9a12806b23bff3cc /log.lua | |
parent | aa6bfb4b15ea75fa289b78cacc7de38f41daf69a (diff) | |
download | text.love-57fb2d4b57db3fef5245d40e16f5ea811c3806a4.tar.gz |
clean up test mocks before aborting
Scenario: modify a test to fail in the source editor delete any settings in the 'config' file in the save dir start lines.love press C-e to switch to source editor Before this commit, this scenario led to the following events: the C-e keypress invokes App.run_tests_and_initialize() the failing test results in a call to error() the call to error() is trapped by the xpcall around the event handler in love.run handle_error runs Current_app is 'source', so love.event.quit() is triggered love.quit() is invoked source.settings() is invoked App.screen.position() is invoked, which calls the test mock Since App.screen.move was never invoked, App.screen.position() returns nil The 'config' file is written without values for source.x and source.y As a result, future runs fail to open. This is likely a corner case only I will ever run into, since I'm careful to never commit failing unit tests. Still, I spent some time trying to figure out the best place to fix this. Options: * don't write config if Error_message is set but we do want config written in this scenario: * we hit an error, source editor opens * we spend some time debugging and don't immediately fix the issue * we quit, with some new files opened in various places * hardcode source.settings() to call love.window.getPosition() rather than App.screen.position(). drawback: weird special case * clean up test mocks before aborting this seems like something we always want I'm not very sure of my choice. This bug doesn't leave me feeling very great about my whole app. Arguably everything I've done is bullshit hacks piled on hacks. Perhaps the issue is: - naked error() in LÖVE apps never invokes love.quit(), but - an unhandled error within my handle_error invokes love.quit() (via love.event.quit) Perhaps LÖVE should provide a way to abort without invoking the quit handler. There's literally no other way in LÖVE to request a quit.
Diffstat (limited to 'log.lua')
0 files changed, 0 insertions, 0 deletions