fix initialization errors using driver.love

akkartik
Nov 17, 2023, 4:44 PM
5WHW3IDOHOBXY3M3QPXNMHFFNXXD6RR5B2WL6TB5TTVNZJYCN2AQC

Dependencies

  • [2] QRUFNFPP Merge text0
  • [3] BQH7ANWM resolve conflicts
  • [4] GSIADI3S run all tests on startup
  • [5] YONFBSVB don't hide errors when driver.love connects
  • [6] PJ5PQAQE record support for multiple versions
  • [7] IM6GSGVZ fix some arg names
  • [8] 36Z442IV back to commit 8123959e52f without code editing
  • [9] D2TYFYG2 Merge text.love
  • [10] 3QNOKBFM beginnings of a test harness
  • [11] T7QIIGQ6 attempt at better error recovery
  • [12] JNJ4R56X support running tests multiple times
  • [13] XGHCLIKB Merge lines.love
  • [14] UZHSWA3D Merge text0
  • [15] IZGDTFAM make preprocessing more obvious
  • [16] YF2ATH2Q Merge lines.love
  • [17] LRDM35CE app running again
  • [*] OTIBCAUJ love2d scaffold
  • [*] BJ5X5O4A let's prevent the text cursor from ever getting on a drawing
  • [*] DTBFNHJD manual tests for the protocol with the driver

Change contents

  • replacement in main.lua at line 240
    [6.1268][6.1084:1101](),[6.1084][6.1084:1101]()
    Mode = 'run'
    [6.1268]
    [6.1101]
    if Redo_initialization then
    Redo_initialization = nil
    love.run() -- won't actually replace the event loop;
    -- we're just running it for its initialization side-effects
    else
    Mode = 'run'
    end
  • replacement in live.lua at line 36
    [4.32][6.12:53](),[6.1754][6.12:53]()
    live.freeze_all_existing_definitions()
    [4.32]
    [6.53]
    if Live.frozen_definitions == nil then -- a second run due to initialization errors will contain definitions we don't want to freeze
    live.freeze_all_existing_definitions()
    end
  • edit in live.lua at line 85
    [5.97]
    [5.97]
    if Redo_initialization then
    Redo_initialization = nil
    love.run() -- won't actually replace the event loop;
    -- we're just running it for its initialization side-effects
    end
  • edit in live.lua at line 402
    [3.377]
    [3.377]
    function live.handle_initialization_error(err)
    Redo_initialization = true
    live.handle_error(err)
    end
  • replacement in app.lua at line 39
    [6.190][6.190:435]()
    -- Stash current state of App for tests
    App_for_tests = {}
    for k,v in pairs(App) do
    App_for_tests[k] = v
    end
    -- there's one nested table
    App_for_tests.screen = {}
    for k,v in pairs(App.screen) do
    App_for_tests.screen[k] = v
    [6.190]
    [6.435]
    -- Stash initial state of App (right after loading files) for tests
    if App_for_tests == nil then
    App_for_tests = {}
    for k,v in pairs(App) do
    App_for_tests[k] = v
    end
    -- there's one nested table
    App_for_tests.screen = {}
    for k,v in pairs(App.screen) do
    App_for_tests.screen[k] = v
    end
  • replacement in app.lua at line 145
    [6.8513][6.8513:8569]()
    App.initialize(love.arg.parseGameArguments(arg), arg)
    [6.8513]
    [6.170]
    xpcall(function() App.initialize(love.arg.parseGameArguments(arg), arg) end, live.handle_initialization_error)
  • edit in Manual_tests.md at line 65
    [21.1426]
    [21.1426]
    Driver can connect to app on errors in on.initialize.
  • edit in Manual_tests.md at line 67
    [21.1501]
    [21.1501]
    driver, define on.initialize with a run-time error:
    ```
    on.initialize = function()
    foo = bar+1
    end
    ```
    Hit F4.
    Quit the client app and restart. App shows an error.
    Edit `on.initialize` in the driver and remove the error:
    ```
    on.initialize = function()
    end
    ```
    Hit F4. The error disappears from the app and driver.
    * clone this repo to a new client app, clear its save dir, run it, run the
    driver, define on.initialize with a run-time error:
    ```
    on.initialize = function()
    foo = bar+1
    end
    ```
    Hit F4.
    Quit the client app and restart. App shows an error.
    Hit F4 again in the driver (without fixing the error).
    The client app continues to show the error.
    * clone this repo to a new client app, clear its save dir, run it, run the