consistently save/restore state when running tests
[?]
Jan 24, 2023, 4:29 AM
JOLUCIT6HFXFKYQ6PNGSNBF4GBYDA6ATVOITT2SYGJH7HBURTDDACDependencies
- [2]
LYIV4YOLmake run_test look like run_tests - [3]
LSWOBVHDundo font changes when running tests - [4]
D5J7IZADdebug helper: run a single test - [5]
LRDM35CEapp running again - [6]
K7YGVRXHgeneralize the protocol to return errors, etc. - [7]
JNJ4R56Xsupport running tests multiple times - [8]
5ZCQGZP5save 2 more alternate formats for test failures - [9]
FFFJ54GJrestore globals after running tests - [10]
S4IAYCIRdelete all tests once they've executed - [11]
3BRGOF7Nreturn failing tests with every code change - [12]
OETGXCQMrename - [13]
2NTKHMLGconfigurable error handler when running tests - [14]
FFMMA7L2send Test_failures _before_ restoring globals - [15]
BC4SO6ARclean up a print - [16]
AVTNUQYRbasic test-enabled framework - [17]
FCFJVYKYredundant check - [18]
ORRSP7FVdeduce test names on failures - [19]
D76AELSVdeduplicate an initialization - [20]
CZQ3NJ4NMerge text0 - [21]
IMEJA43Lsnapshot - [22]
3QMTXKWNrename - [*]
3QNOKBFMbeginnings of a test harness
Change contents
- edit in live.lua at line 282
local globals = live.shallow_copy_all_globals()local current_font = love.graphics.getFont()love.graphics.setFont(Love_snapshot.initial_font) - edit in live.lua at line 285[4.59]→[3.113:153](∅→∅),[4.59]→[4.83:121](∅→∅),[3.153]→[4.83:121](∅→∅),[4.100]→[4.83:121](∅→∅),[4.39]→[4.122:481](∅→∅)
love.graphics.setFont(current_font)live.restore_all_globals(globals)endendfunction live.shallow_copy_all_globals()local result = {}for k,v in pairs(_G) doresult[k] = vendreturn resultendfunction live.restore_all_globals(x)-- delete extra bindingsfor k,v in pairs(_G) doif x[k] == nil then_G[k] = nilendend-- restore previous bindingsfor k,v in pairs(x) do_G[k] = v - replacement in app.lua at line 431
local saved_app = Applocal globals = App.shallow_copy_all_globals() - edit in app.lua at line 433
local saved_font = love.graphics.getFont()love.graphics.setFont(Love_snapshot.initial_font) - replacement in app.lua at line 440
App = saved_applove.graphics.setFont(saved_font)-- restore all global state except Test_errorslocal test_errors = Test_errorsApp.restore_all_globals(globals)Test_errors = test_errors - replacement in app.lua at line 448
local saved_app = Applocal globals = App.shallow_copy_all_globals() - replacement in app.lua at line 450[4.115]→[4.115:143](∅→∅),[4.143]→[2.64:123](∅→∅),[2.123]→[4.2065:2083](∅→∅),[4.175]→[4.2065:2083](∅→∅),[4.187]→[4.2065:2083](∅→∅),[4.221]→[4.2065:2083](∅→∅),[4.7564]→[4.2065:2083](∅→∅)
App.initialize_for_test()xpcall(test, function(err) record_error_fn('', err) end)App = saved_applocal saved_font = love.graphics.getFont()love.graphics.setFont(Love_snapshot.initial_font)App.initialize_for_test()xpcall(test, function(err) record_error_fn('', err) end)love.graphics.setFont(saved_font)-- restore all global state except Test_errorslocal test_errors = Test_errorsApp.restore_all_globals(globals)Test_errors = test_errorsendfunction App.shallow_copy_all_globals()local result = {}for k,v in pairs(_G) doresult[k] = vendreturn resultendfunction App.restore_all_globals(x)-- delete extra bindingsfor k,v in pairs(_G) doif x[k] == nil then_G[k] = nilendend-- restore previous bindingsfor k,v in pairs(x) do_G[k] = vend