From 80789508b9655d25629223b9dcc84b4cfb77ce45 Mon Sep 17 00:00:00 2001 From: Alexander Date: Mon, 29 Jun 2020 15:29:03 -0400 Subject: Updates for mdoc Also more tests --- spec/test1_spec.lua | 62 ++++++++++++++++------------------------------------- 1 file changed, 19 insertions(+), 43 deletions(-) (limited to 'spec/test1_spec.lua') diff --git a/spec/test1_spec.lua b/spec/test1_spec.lua index 147abbd..01d6b0d 100644 --- a/spec/test1_spec.lua +++ b/spec/test1_spec.lua @@ -1,5 +1,10 @@ -print("Hello, world!") +if not package.path:find("spec/%?%.lua;") then + print("including spec") + package.path = "./spec/?.lua;" .. package.path +end +_G.assert = assert +local common = require("common") --[[Create the headless client init file]] local f = io.open("spec/headless/deviceinit.lua","w") f:write([=[ @@ -21,44 +26,14 @@ return { ]=]) f:close() -local game_bin = nil -if package.config:sub(1,1) == "/" then -- linux or osx - game_bin = "bin/client/bin/brokengine_client" -else - game_bin = "bin\\client\\bin\\brokengine_client.exe" -end - -function rungame() - f = io.popen(game_bin .. " spec/headless","r") - d = f:read("*all") - f:close() - return d -end - -function writegame(...) - f = assert(io.open("spec/headless/init.lua","w")) - data = {"GAME.crashy()"} - for _,v in pairs({...}) do - data[#data + 1] = v - end - data[#data + 1] = "\nGAME.exit()\n" - f:write(table.concat(data)) - f:close() -end - -function assert_game_runs() - assert.truthy(rungame():find("\nGoodbye\n$")) -end - describe("Brok[en]gine",function() - it("should run",function() - writegame() - d = rungame() - assert_game_runs() + it("should run #smoke",function() + common.writegame() + common.assert_game_runs() end) - it("should provide a lua environment",function() - writegame("print(\"Hello from lua!\")") - d = rungame() + it("should provide a lua environment #smoke",function() + common.writegame("print(\"Hello from lua!\")") + d = common.rungame() assert.truthy(d:find("\nHello from lua!\n")) end) @@ -75,15 +50,16 @@ describe("Brok[en]gine",function() windows = "newwindow", }) do it("should provide functions to make gui " .. k,function() - writegame("assert(gui." .. v .. ")") - assert_game_runs() + common.writegame("assert(gui." .. v .. ")") + common.assert_game_runs() end) end it("should provide functions to get the width and height of the screen",function() - writegame("assert(scrw)") - assert_game_runs() - writegame("assert(scrh)") - assert_game_runs() + common.writegame("assert(scrw)") + common.assert_game_runs() + common.writegame("assert(scrh)") + common.assert_game_runs() end) + end) -- cgit v1.2.3-70-g09d2