From ef6fa16496df82cc379f7edc1b451da7fa9fe8f2 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 19 Apr 2020 21:35:48 +0200 Subject: [PATCH] convert to lua 5.3 --- .gitmodules | 3 --- CMakeLists.txt | 2 ++ lunit | 1 - s/cmake-init | 4 ++++ s/runtests | 1 + scripts/run-tests-e2.lua | 4 ++-- scripts/run-tests-e3.lua | 5 +++-- scripts/run-tests.lua | 5 +++-- scripts/tests/bindings.lua | 11 +++++++---- scripts/tests/common.lua | 10 +++++++--- scripts/tests/config.lua | 10 +++++++--- scripts/tests/e2/adamantium.lua | 10 +++++++--- scripts/tests/e2/allies.lua | 10 +++++++--- scripts/tests/e2/astral.lua | 12 ++++++++---- scripts/tests/e2/buildings.lua | 10 +++++++--- scripts/tests/e2/carts.lua | 10 +++++++--- scripts/tests/e2/destroy.lua | 10 +++++++--- scripts/tests/e2/e2features.lua | 10 +++++++--- scripts/tests/e2/guard.lua | 10 +++++++--- scripts/tests/e2/init.lua | 1 - scripts/tests/e2/insects.lua | 10 +++++++--- scripts/tests/e2/items.lua | 10 +++++++--- scripts/tests/e2/movement.lua | 10 +++++++--- scripts/tests/e2/production.lua | 10 +++++++--- scripts/tests/e2/quit.lua | 10 +++++++--- scripts/tests/e2/shiplanding.lua | 10 +++++++--- scripts/tests/e2/ships.lua | 10 +++++++--- scripts/tests/e2/spells.lua | 10 +++++++--- scripts/tests/e2/stealth.lua | 10 +++++++--- scripts/tests/e2/undead.lua | 10 +++++++--- scripts/tests/economy.lua | 10 +++++++--- scripts/tests/faction.lua | 9 ++++++--- scripts/tests/hunger.lua | 10 +++++++--- scripts/tests/items.lua | 10 +++++++--- scripts/tests/laws.lua | 10 +++++++--- scripts/tests/locale.lua | 9 ++++++--- scripts/tests/magicbag.lua | 10 +++++++--- scripts/tests/movement.lua | 9 ++++++--- scripts/tests/orders.lua | 12 +++++++----- scripts/tests/pool.lua | 9 ++++++--- scripts/tests/process.lua | 10 +++++++--- scripts/tests/production.lua | 10 +++++++--- scripts/tests/regions.lua | 10 +++++++--- scripts/tests/report.lua | 10 +++++++--- scripts/tests/settings.lua | 10 +++++++--- scripts/tests/spells.lua | 9 +++++++-- scripts/tests/storage.lua | 10 +++++++--- scripts/tests/study.lua | 10 +++++++--- scripts/tests/undead.lua | 10 +++++++--- scripts/tests/xmas.lua | 10 +++++++--- 50 files changed, 299 insertions(+), 137 deletions(-) delete mode 160000 lunit diff --git a/.gitmodules b/.gitmodules index 4d903c57f..f76a3af9c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "lunit"] - path = lunit - url = https://github.com/ennorehling/lunit.git [submodule "dlmalloc"] path = dlmalloc url = https://github.com/ennorehling/dlmalloc.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d2635f05..e8c4893d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/lunit b/lunit deleted file mode 160000 index 155c96594..000000000 --- a/lunit +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 155c96594435413b4f704eb17558ea0b70631bad diff --git a/s/cmake-init b/s/cmake-init index eea222334..da747e3ec 100755 --- a/s/cmake-init +++ b/s/cmake-init @@ -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" diff --git a/s/runtests b/s/runtests index b74a4b785..2c8049098 100755 --- a/s/runtests +++ b/s/runtests @@ -1,6 +1,7 @@ #!/bin/bash set -e +eval $(luarocks path) ROOT=$(git rev-parse --show-toplevel) [ -z $BUILD ] && BUILD=Debug ; export BUILD diff --git a/scripts/run-tests-e2.lua b/scripts/run-tests-e2.lua index b5f18c7f7..a421904f6 100644 --- a/scripts/run-tests-e2.lua +++ b/scripts/run-tests-e2.lua @@ -1,10 +1,11 @@ -- 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 - package.path = package.path .. ';' .. config.install .. '/lunit/?.lua' --needed to find lunit if not run from eressea root. Needs right [lua] install setting in eressea.ini (point to eressea root from the start folder) end package.path = package.path .. ';' .. path .. '/?.lua;' .. path .. '/?/init.lua' @@ -15,7 +16,6 @@ require 'eressea' require 'eressea.xmlconf' require 'eressea.path' require 'tests.e2' -require 'lunit' rng.inject(0) eressea.settings.set("rules.food.flags", "4") diff --git a/scripts/run-tests-e3.lua b/scripts/run-tests-e3.lua index 3332df306..f50ac71eb 100644 --- a/scripts/run-tests-e3.lua +++ b/scripts/run-tests-e3.lua @@ -1,10 +1,12 @@ -- 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 - package.path = package.path .. ';' .. config.install .. '/lunit/?.lua' --needed to find lunit if not run form eressea root. Needs right [lua] install setting in eressea.ini (point to eressea root from the start folder) end package.path = package.path .. ';' .. path .. '/?.lua;' .. path .. '/?/init.lua' @@ -15,7 +17,6 @@ require 'eressea' require 'eressea.path' require 'eressea.xmlconf' require 'tests.e3' -require 'lunit' rng.inject(0) eressea.settings.set("rules.alliances", "0") diff --git a/scripts/run-tests.lua b/scripts/run-tests.lua index d1306ddcd..5a7bcb9ad 100644 --- a/scripts/run-tests.lua +++ b/scripts/run-tests.lua @@ -4,14 +4,15 @@ path = 'scripts' if config.install then path = config.install .. '/' .. path - package.path = package.path .. ';' .. config.install .. '/lunit/?.lua' --needed to find lunit if not run form eressea root. Needs right [lua] install setting in eressea.ini (point to eressea root from the start folder) end package.path = package.path .. ';' .. path .. '/?.lua;' .. path .. '/?/init.lua' require 'eressea' require 'eressea.path' + +lunit = require('lunit') +module = lunit.module require 'tests' -require 'lunit' result = lunit.main() return result.errors + result.failed diff --git a/scripts/tests/bindings.lua b/scripts/tests/bindings.lua index 5820e0a47..4e308de99 100644 --- a/scripts/tests/bindings.lua +++ b/scripts/tests/bindings.lua @@ -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)) diff --git a/scripts/tests/common.lua b/scripts/tests/common.lua index 96069d4a5..ca09fe6c9 100644 --- a/scripts/tests/common.lua +++ b/scripts/tests/common.lua @@ -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") diff --git a/scripts/tests/config.lua b/scripts/tests/config.lua index 733a8ee07..cdf93ed2c 100644 --- a/scripts/tests/config.lua +++ b/scripts/tests/config.lua @@ -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() diff --git a/scripts/tests/e2/adamantium.lua b/scripts/tests/e2/adamantium.lua index a893d32d5..0a0c2ec6b 100644 --- a/scripts/tests/e2/adamantium.lua +++ b/scripts/tests/e2/adamantium.lua @@ -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() diff --git a/scripts/tests/e2/allies.lua b/scripts/tests/e2/allies.lua index ef38a97bf..a5177944f 100644 --- a/scripts/tests/e2/allies.lua +++ b/scripts/tests/e2/allies.lua @@ -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 skip_test_get_set_ally() local f1 = faction.create("human") diff --git a/scripts/tests/e2/astral.lua b/scripts/tests/e2/astral.lua index 5c4461921..c183c6207 100644 --- a/scripts/tests/e2/astral.lua +++ b/scripts/tests/e2/astral.lua @@ -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) diff --git a/scripts/tests/e2/buildings.lua b/scripts/tests/e2/buildings.lua index 845c4ba7d..7eb3b41c8 100644 --- a/scripts/tests/e2/buildings.lua +++ b/scripts/tests/e2/buildings.lua @@ -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() diff --git a/scripts/tests/e2/carts.lua b/scripts/tests/e2/carts.lua index 025b473df..f649451e2 100644 --- a/scripts/tests/e2/carts.lua +++ b/scripts/tests/e2/carts.lua @@ -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() diff --git a/scripts/tests/e2/destroy.lua b/scripts/tests/e2/destroy.lua index 430ca301c..1813c108b 100644 --- a/scripts/tests/e2/destroy.lua +++ b/scripts/tests/e2/destroy.lua @@ -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() diff --git a/scripts/tests/e2/e2features.lua b/scripts/tests/e2/e2features.lua index b0233c3fb..a9ba6ed51 100644 --- a/scripts/tests/e2/e2features.lua +++ b/scripts/tests/e2/e2features.lua @@ -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() diff --git a/scripts/tests/e2/guard.lua b/scripts/tests/e2/guard.lua index e3cf8075f..fd7f37ad0 100644 --- a/scripts/tests/e2/guard.lua +++ b/scripts/tests/e2/guard.lua @@ -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() diff --git a/scripts/tests/e2/init.lua b/scripts/tests/e2/init.lua index 3bd09bafc..095d2bcf0 100644 --- a/scripts/tests/e2/init.lua +++ b/scripts/tests/e2/init.lua @@ -3,7 +3,6 @@ require 'tests.e2.allies' require 'tests.e2.quit' require 'tests.e2.movement' require 'tests.e2.carts' -require 'tests.e2.quit' require 'tests.e2.astral' require 'tests.e2.spells' require 'tests.e2.e2features' diff --git a/scripts/tests/e2/insects.lua b/scripts/tests/e2/insects.lua index f5b8a3213..296c67e82 100644 --- a/scripts/tests/e2/insects.lua +++ b/scripts/tests/e2/insects.lua @@ -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() diff --git a/scripts/tests/e2/items.lua b/scripts/tests/e2/items.lua index 2492a7fdb..9221d424b 100644 --- a/scripts/tests/e2/items.lua +++ b/scripts/tests/e2/items.lua @@ -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() diff --git a/scripts/tests/e2/movement.lua b/scripts/tests/e2/movement.lua index aa42857f3..db9f4fbdd 100644 --- a/scripts/tests/e2/movement.lua +++ b/scripts/tests/e2/movement.lua @@ -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() diff --git a/scripts/tests/e2/production.lua b/scripts/tests/e2/production.lua index 80d3447d2..7941c1af4 100644 --- a/scripts/tests/e2/production.lua +++ b/scripts/tests/e2/production.lua @@ -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() diff --git a/scripts/tests/e2/quit.lua b/scripts/tests/e2/quit.lua index 7db59091b..9d02c49eb 100644 --- a/scripts/tests/e2/quit.lua +++ b/scripts/tests/e2/quit.lua @@ -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") diff --git a/scripts/tests/e2/shiplanding.lua b/scripts/tests/e2/shiplanding.lua index 2258a1992..7b146f2e6 100644 --- a/scripts/tests/e2/shiplanding.lua +++ b/scripts/tests/e2/shiplanding.lua @@ -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() diff --git a/scripts/tests/e2/ships.lua b/scripts/tests/e2/ships.lua index 5b77220ec..2f5db607d 100644 --- a/scripts/tests/e2/ships.lua +++ b/scripts/tests/e2/ships.lua @@ -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() diff --git a/scripts/tests/e2/spells.lua b/scripts/tests/e2/spells.lua index de2386113..39a867507 100644 --- a/scripts/tests/e2/spells.lua +++ b/scripts/tests/e2/spells.lua @@ -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.free_game() diff --git a/scripts/tests/e2/stealth.lua b/scripts/tests/e2/stealth.lua index 7f531776c..60b66e83f 100644 --- a/scripts/tests/e2/stealth.lua +++ b/scripts/tests/e2/stealth.lua @@ -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 diff --git a/scripts/tests/e2/undead.lua b/scripts/tests/e2/undead.lua index f7586ee4b..8e072e489 100644 --- a/scripts/tests/e2/undead.lua +++ b/scripts/tests/e2/undead.lua @@ -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() diff --git a/scripts/tests/economy.lua b/scripts/tests/economy.lua index 0c140e418..17dcbfc61 100644 --- a/scripts/tests/economy.lua +++ b/scripts/tests/economy.lua @@ -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() diff --git a/scripts/tests/faction.lua b/scripts/tests/faction.lua index c264f4596..7247498ea 100644 --- a/scripts/tests/faction.lua +++ b/scripts/tests/faction.lua @@ -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 diff --git a/scripts/tests/hunger.lua b/scripts/tests/hunger.lua index a33c2208b..fed24440e 100644 --- a/scripts/tests/hunger.lua +++ b/scripts/tests/hunger.lua @@ -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() diff --git a/scripts/tests/items.lua b/scripts/tests/items.lua index f4d8657c6..e1e780f3c 100644 --- a/scripts/tests/items.lua +++ b/scripts/tests/items.lua @@ -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() diff --git a/scripts/tests/laws.lua b/scripts/tests/laws.lua index 6dc37daf7..e22bc5d8f 100644 --- a/scripts/tests/laws.lua +++ b/scripts/tests/laws.lua @@ -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 + diff --git a/scripts/tests/locale.lua b/scripts/tests/locale.lua index 2770beb3f..d1d35ded3 100644 --- a/scripts/tests/locale.lua +++ b/scripts/tests/locale.lua @@ -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() diff --git a/scripts/tests/magicbag.lua b/scripts/tests/magicbag.lua index b51925726..7e4629707 100644 --- a/scripts/tests/magicbag.lua +++ b/scripts/tests/magicbag.lua @@ -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 diff --git a/scripts/tests/movement.lua b/scripts/tests/movement.lua index 22bd8d30e..943e912a8 100644 --- a/scripts/tests/movement.lua +++ b/scripts/tests/movement.lua @@ -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() diff --git a/scripts/tests/orders.lua b/scripts/tests/orders.lua index 6dc191d6c..c63254315 100644 --- a/scripts/tests/orders.lua +++ b/scripts/tests/orders.lua @@ -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() diff --git a/scripts/tests/pool.lua b/scripts/tests/pool.lua index 0d24f8129..06f212f60 100644 --- a/scripts/tests/pool.lua +++ b/scripts/tests/pool.lua @@ -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() diff --git a/scripts/tests/process.lua b/scripts/tests/process.lua index 1fc9a64f5..0b9b3e35b 100644 --- a/scripts/tests/process.lua +++ b/scripts/tests/process.lua @@ -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 diff --git a/scripts/tests/production.lua b/scripts/tests/production.lua index c8a299676..b127fff02 100644 --- a/scripts/tests/production.lua +++ b/scripts/tests/production.lua @@ -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() diff --git a/scripts/tests/regions.lua b/scripts/tests/regions.lua index 32197f0fd..e16dd1691 100644 --- a/scripts/tests/regions.lua +++ b/scripts/tests/regions.lua @@ -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() diff --git a/scripts/tests/report.lua b/scripts/tests/report.lua index b02f4a908..66eaa7d89 100644 --- a/scripts/tests/report.lua +++ b/scripts/tests/report.lua @@ -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() diff --git a/scripts/tests/settings.lua b/scripts/tests/settings.lua index 8f2c5e637..f321a515b 100644 --- a/scripts/tests/settings.lua +++ b/scripts/tests/settings.lua @@ -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() diff --git a/scripts/tests/spells.lua b/scripts/tests/spells.lua index 27a5424f7..767df5d16 100644 --- a/scripts/tests/spells.lua +++ b/scripts/tests/spells.lua @@ -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() diff --git a/scripts/tests/storage.lua b/scripts/tests/storage.lua index 32fbe9ef3..22af5a221 100644 --- a/scripts/tests/storage.lua +++ b/scripts/tests/storage.lua @@ -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() diff --git a/scripts/tests/study.lua b/scripts/tests/study.lua index 32638ba90..21c70044e 100644 --- a/scripts/tests/study.lua +++ b/scripts/tests/study.lua @@ -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 = [[{ diff --git a/scripts/tests/undead.lua b/scripts/tests/undead.lua index a3c541afa..4cb86fc67 100644 --- a/scripts/tests/undead.lua +++ b/scripts/tests/undead.lua @@ -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() diff --git a/scripts/tests/xmas.lua b/scripts/tests/xmas.lua index 8ae85fc76..10386c0ed 100644 --- a/scripts/tests/xmas.lua +++ b/scripts/tests/xmas.lua @@ -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()