convert to lua 5.3

This commit is contained in:
Enno Rehling 2020-04-19 21:35:48 +02:00
parent 346d62e1aa
commit 64a2890c91
48 changed files with 299 additions and 127 deletions

View File

@ -50,6 +50,8 @@ find_package (ToLua REQUIRED)
if (TOLUA_FOUND)
if (${TOLUA_VERSION_STRING} VERSION_EQUAL "5.2")
find_package (Lua 5.2 REQUIRED)
elseif (${TOLUA_VERSION_STRING} VERSION_EQUAL "5.3")
find_package ( Lua 5.3 REQUIRED)
else ()
find_package (Lua51 REQUIRED)
endif()

View File

@ -82,6 +82,10 @@ LUA_DIR=/usr
if [ -d /usr/include/lua5.1 ]; then
LUA_VERSION="5.1"
LUA_INCLUDE=/usr/include/lua5.1
elif [ -d /usr/include/lua5.3 ]; then
export LUA_DIR=/usr
LUA_VERSION="5.3"
LUA_INCLUDE=/usr/include/lua5.3
elif [ -d /usr/include/lua5.2 ]; then
export LUA_DIR=/usr
LUA_VERSION="5.2"

View File

@ -1,5 +1,6 @@
#!/bin/bash
set -e
eval $(luarocks path)
ROOT=$(git rev-parse --show-toplevel)
[ -z $BUILD ] && BUILD=Debug ; export BUILD

View File

@ -1,6 +1,8 @@
-- Tests that work in all games. With game config of E2.
-- Tests are under scripts/test/e2 and all files must be in scripts/test/e2/init.lua
lunit = require('lunit')
module = lunit.module
path = 'scripts'
if config.install then
path = config.install .. '/' .. path

View File

@ -1,6 +1,9 @@
-- Tests that work in E3. With game config of E3.
-- Tests are under scripts/test/e3 and all files must be in scripts/test/e3/init.lua
lunit = require('lunit')
module = lunit.module
path = 'scripts'
if config.install then
path = config.install .. '/' .. path

View File

@ -10,6 +10,9 @@ package.path = package.path .. ';' .. path .. '/?.lua;' .. path .. '/?/init.lua'
lunit = require 'lunit'
require 'eressea'
require 'eressea.path'
lunit = require('lunit')
module = lunit.module
require 'tests'
result = lunit.main()
return result.errors + result.failed

View File

@ -1,10 +1,13 @@
require "lunit"
local tcname = 'tests.bindings'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
local eressea = eressea
local _G = _G
module("tests.bindings", lunit.testcase)
function test_eressea()
assert_equal("function", _G.type(eressea.free_game))
assert_equal("function", _G.type(eressea.read_game))

View File

@ -1,4 +1,10 @@
require "lunit"
local tcname = 'tests.shared.common'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
local function _test_create_ship(r)
local s = ship.create(r, config.ships[1])
@ -26,8 +32,6 @@ local function two_factions()
return f1, f2
end
module("tests.common", package.seeall, lunit.testcase)
function setup()
eressea.free_game()
eressea.settings.set("nmr.timeout", "0")

View File

@ -1,6 +1,10 @@
require "lunit"
module("tests.eressea.config", package.seeall, lunit.testcase )
local tcname = 'tests.shared.config'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup()
eressea.free_game()

View File

@ -1,6 +1,10 @@
require "lunit"
module("tests.e2.adamantium", package.seeall, lunit.testcase )
local tcname = 'tests.e2.adamantium'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup()
eressea.free_game()

View File

@ -1,6 +1,10 @@
require "lunit"
module("tests.e2.allies", package.seeall, lunit.testcase)
local tcname = 'tests.e2.allies'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup()
eressea.free_game()

View File

@ -1,6 +1,10 @@
require "lunit"
module("tests.e2.astral", package.seeall, lunit.testcase)
local tcname = 'tests.e2.astral'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup()
eressea.free_game()
@ -17,7 +21,7 @@ function test_fetch_astral()
local r = region.create(0, 0, "plain")
local ra = r:get_astral('fog')
local rb = region.create(ra.x + 1, ra.y, 'fog')
local f = faction.create("human")
local f = faction.create("human");
local u1 = unit.create(f, r, 1)
local u2 = unit.create(f, r, 1)
local u3 = unit.create(f, rb, 1)

View File

@ -1,6 +1,10 @@
require "lunit"
module("tests.e2.buildings", package.seeall, lunit.testcase )
local tcname = 'tests.e2.buildings'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup()
eressea.game.reset()

View File

@ -1,6 +1,10 @@
require "lunit"
module("tests.e2.carts", package.seeall, lunit.testcase)
local tcname = 'tests.e2.carts'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup()
eressea.free_game()

View File

@ -1,6 +1,10 @@
require "lunit"
module("tests.e2.destroy", package.seeall, lunit.testcase)
local tcname = 'tests.e2.destroy'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup()
eressea.free_game()

View File

@ -1,6 +1,10 @@
require "lunit"
module("tests.e2.e2features", package.seeall, lunit.testcase )
local tcname = 'tests.e2.features'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup()
eressea.free_game()

View File

@ -1,6 +1,10 @@
require "lunit"
module("tests.e2.guard", package.seeall, lunit.testcase)
local tcname = 'tests.e2.guard'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup()
eressea.free_game()

View File

@ -3,7 +3,6 @@ require 'tests.e2.trees'
require 'tests.e2.buildings'
require 'tests.e2.movement'
require 'tests.e2.carts'
require 'tests.e2.quit'
require 'tests.e2.astral'
require 'tests.e2.spells'
require 'tests.e2.e2features'

View File

@ -1,6 +1,10 @@
require "lunit"
module("tests.e2.insects", package.seeall, lunit.testcase)
local tcname = 'tests.e2.insects'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup()
eressea.free_game()

View File

@ -1,6 +1,10 @@
require "lunit"
module("tests.e2.items", package.seeall, lunit.testcase )
local tcname = 'tests.e2.items'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup()
eressea.free_game()

View File

@ -1,6 +1,10 @@
require "lunit"
module("tests.e2.movement", package.seeall, lunit.testcase)
local tcname = 'tests.e2.movement'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup()
eressea.free_game()

View File

@ -1,6 +1,10 @@
require "lunit"
module("tests.e2.production", package.seeall, lunit.testcase )
local tcname = 'tests.e2.production'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup()
eressea.game.reset()

View File

@ -1,6 +1,10 @@
require "lunit"
module("tests.e2.quit", package.seeall, lunit.testcase)
local tcname = 'tests.e2.quit'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function test_quit_faction()
local r = region.create(47, 0, "plain")

View File

@ -1,6 +1,10 @@
require "lunit"
module("tests.e2.shiplanding", package.seeall, lunit.testcase)
local tcname = 'tests.e2.shiplanding'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup()
eressea.free_game()

View File

@ -1,6 +1,10 @@
require "lunit"
module("tests.e2.ships", package.seeall, lunit.testcase)
local tcname = 'tests.e2.ships'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup()
eressea.game.reset()

View File

@ -1,6 +1,10 @@
require "lunit"
module("tests.e2.spells", package.seeall, lunit.testcase)
local tcname = 'tests.e2.spells'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup()
eressea.game.reset()

View File

@ -1,6 +1,10 @@
require "lunit"
module('tests.e2.stealth', package.seeall, lunit.testcase)
local tcname = 'tests.e2.stealth'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
local f
local u

View File

@ -1,6 +1,10 @@
require "lunit"
module("tests.e2.undead", package.seeall, lunit.testcase)
local tcname = 'tests.e2.undead'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup()
eressea.free_game()

View File

@ -1,6 +1,10 @@
require "lunit"
module("tests.economy", package.seeall, lunit.testcase)
local tcname = 'tests.shared.economy'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup()
eressea.free_game()

View File

@ -1,6 +1,9 @@
require "lunit"
module ('tests.eressea.faction', package.seeall, lunit.testcase)
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module("tests.faction", 'seeall')
else
module("tests.faction", 'seeall')
end
local f

View File

@ -1,6 +1,10 @@
require "lunit"
module("tests.hunger", package.seeall, lunit.testcase)
local tcname = 'tests.hunger'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup()
eressea.free_game()

View File

@ -1,6 +1,10 @@
require "lunit"
module("tests.items", package.seeall, lunit.testcase )
local tcname = 'tests.shared.items'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup()
eressea.free_game()

View File

@ -1,6 +1,9 @@
require "lunit"
module("tests.laws", package.seeall, lunit.testcase)
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module("tests.laws", 'seeall')
else
module("tests.laws", 'seeall')
end
function setup()
eressea.free_game()
@ -115,3 +118,4 @@ function test_force_leave_postcombat()
assert_equal(nil, u3.building)
assert_equal(1, u3.number)
end

View File

@ -1,6 +1,9 @@
require "lunit"
module("tests.eressea.locale", package.seeall, lunit.testcase )
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module("tests.locale", 'seeall')
else
module("tests.locale", 'seeall')
end
function setup()
eressea.free_game()

View File

@ -1,6 +1,10 @@
require "lunit"
module("tests.magicbag", package.seeall, lunit.testcase)
local tcname = 'tests.shared.magicbag'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
local u

View File

@ -1,6 +1,9 @@
require "lunit"
module("tests.movement", package.seeall, lunit.testcase)
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module("tests.movement", 'seeall')
else
module("tests.movement", 'seeall')
end
function setup()
eressea.free_game()

View File

@ -1,12 +1,14 @@
require "lunit"
local tcname = 'tests.shared.orders'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
local _G = _G
local eressea = eressea
local default_ship = config.ships[1]
local default_building = config.buildings[1]
module('tests.eressea.orders', package.seeall, lunit.testcase)
local r, f, u
function setup()

View File

@ -1,6 +1,9 @@
require "lunit"
module("tests.eressea.pool", package.seeall, lunit.testcase )
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module("tests.pool", 'seeall')
else
module("tests.pool", 'seeall')
end
function setup()
eressea.game.reset()

View File

@ -1,6 +1,10 @@
require "lunit"
module("tests.process", package.seeall, lunit.testcase)
local tcname = 'tests.shared.process'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
local u, r, f

View File

@ -1,6 +1,10 @@
require "lunit"
module("tests.production", package.seeall, lunit.testcase )
local tcname = 'tests.shared.production'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup()
eressea.game.reset()

View File

@ -1,6 +1,10 @@
require "lunit"
module("tests.regions", package.seeall, lunit.testcase)
local tcname = 'tests.regions'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup()
eressea.game.reset()

View File

@ -1,6 +1,10 @@
require "lunit"
module("tests.report", package.seeall, lunit.testcase)
local tcname = 'tests.shared.report'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup()
eressea.free_game()

View File

@ -1,6 +1,10 @@
require 'lunit'
module('tests.eressea.settings', package.seeall, lunit.testcase )
local tcname = 'tests.settings'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup()
eressea.free_game()

View File

@ -1,5 +1,10 @@
require 'lunit'
module("tests.spells", package.seeall, lunit.testcase)
local tcname = 'tests.shared.spells'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup()
eressea.free_game()

View File

@ -1,6 +1,10 @@
require "lunit"
module("tests.storage", package.seeall, lunit.testcase)
local tcname = 'tests.shared.storage'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup()
eressea.free_game()

View File

@ -1,6 +1,10 @@
require "lunit"
module("tests.eressea.study", package.seeall, lunit.testcase)
local tcname = 'tests.study'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup()
conf = [[{

View File

@ -1,6 +1,10 @@
require "lunit"
module("tests.undead", package.seeall, lunit.testcase)
local tcname = 'tests.shared.undead'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup()
eressea.free_game()

View File

@ -1,6 +1,10 @@
require "lunit"
module("tests.xmas", package.seeall, lunit.testcase )
local tcname = 'tests.shared.xmas'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
end
function setup()
eressea.free_game()