From b26614f10d13835c8a9b6856abcad6ad057c904e Mon Sep 17 00:00:00 2001 From: Alexander M Pickering Date: Fri, 24 Nov 2023 21:45:42 -0600 Subject: Add some asserts and fix the networking test --- spec/common.lua | 10 +++++----- spec/test2_spec.lua | 4 +++- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'spec') diff --git a/spec/common.lua b/spec/common.lua index 4df1a7c..f1eee04 100644 --- a/spec/common.lua +++ b/spec/common.lua @@ -10,9 +10,9 @@ else -- windows end function common.rungame() - f = io.popen(game_bin .. " spec/headless","r") - d = f:read("*all") - f:close() + f = assert(io.popen(game_bin .. " spec/headless","r")) + d = assert(f:read("*all")) + assert(f:close()) --print(d) return d end @@ -21,8 +21,8 @@ function common.runboth() --print("Running both") --Do we have a race condition here? (Can client start and send it's message --before the server is ready to accept? - f1 = io.popen(server_bin .. " spec/server","r") - f2 = io.popen(game_bin .. " spec/headless","r") + f1 = assert(io.popen(server_bin .. " spec/server","r")) + f2 = assert(io.popen(game_bin .. " spec/headless","r")) --print("Both ran...") d1 = f1:read("*all") d2 = f2:read("*all") diff --git a/spec/test2_spec.lua b/spec/test2_spec.lua index 82ca33e..575e1d1 100644 --- a/spec/test2_spec.lua +++ b/spec/test2_spec.lua @@ -77,14 +77,16 @@ describe("network library",function() end) end local i = os.time() + local game_exit = GAME.exit function GAME.tick() if has_ponged then - GAME.exit() + game_exit() end if i - os.time() > 5 then error("Failed") end end + GAME.exit = function(...) end -- only exit when we pong, not before. ]]) common.writegame([[ local socket = net.newsocket(net.PAIR) -- cgit v1.2.3-70-g09d2