aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander M Pickering <alex@cogarr.net>2023-11-24 21:45:42 -0600
committerAlexander M Pickering <alex@cogarr.net>2023-11-24 21:45:42 -0600
commitb26614f10d13835c8a9b6856abcad6ad057c904e (patch)
tree29f5ea3cc0e1bc784c610a8b272e141e5d03aba0
parentda0d5a002e69faf69c4cbc9720248f3b556ee011 (diff)
downloadbrokengine-b26614f10d13835c8a9b6856abcad6ad057c904e.tar.gz
brokengine-b26614f10d13835c8a9b6856abcad6ad057c904e.tar.bz2
brokengine-b26614f10d13835c8a9b6856abcad6ad057c904e.zip
Add some asserts and fix the networking test
-rw-r--r--spec/common.lua10
-rw-r--r--spec/test2_spec.lua4
2 files changed, 8 insertions, 6 deletions
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)