diff options
| author | Alexander <alex@cogarr.net> | 2020-06-29 15:29:03 -0400 |
|---|---|---|
| committer | Alexander <alex@cogarr.net> | 2020-06-29 15:29:03 -0400 |
| commit | 80789508b9655d25629223b9dcc84b4cfb77ce45 (patch) | |
| tree | 37e140e532af61c1ca4699c8b6254cf2cb07ed02 /spec/test1_spec.lua | |
| parent | 44a1421c393632978d59c0698a93ae22243b97e9 (diff) | |
| download | brokengine-80789508b9655d25629223b9dcc84b4cfb77ce45.tar.gz brokengine-80789508b9655d25629223b9dcc84b4cfb77ce45.tar.bz2 brokengine-80789508b9655d25629223b9dcc84b4cfb77ce45.zip | |
Updates for mdoc
Also more tests
Diffstat (limited to 'spec/test1_spec.lua')
| -rw-r--r-- | spec/test1_spec.lua | 62 |
1 files changed, 19 insertions, 43 deletions
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) |
