graph drawing tool

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.

Created by  akkartik  on January 12, 2024
PCB3ATUX6P23VGCFENBFNQWAK3SGLN4G7Y6NAEMFWRWEAOO3ILCAC
Change contents