Fix test to work with lunitx on Lua 5.1

This commit is contained in:
Enno Rehling 2020-05-03 16:52:40 +02:00
parent 04c3052916
commit 6cf6f96fb8
57 changed files with 126 additions and 116 deletions

View File

@ -2,7 +2,10 @@
-- Tests are under scripts/test/e2 and all files must be in scripts/test/e2/init.lua
lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
module = lunit.module
end
path = 'scripts'
if config.install then
path = config.install .. '/' .. path

View File

@ -2,7 +2,9 @@
-- Tests are under scripts/test/e3 and all files must be in scripts/test/e3/init.lua
lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
module = lunit.module
end
path = 'scripts'
if config.install then
@ -12,7 +14,6 @@ package.path = package.path .. ';' .. path .. '/?.lua;' .. path .. '/?/init.lua'
config.rules = 'e3'
lunit = require 'lunit'
require 'eressea'
require 'eressea.path'
require 'eressea.xmlconf'

View File

@ -1,18 +1,19 @@
-- Basic test without loading XML Config. Test care about needed settings.
-- Tests are under scripts/test/ and all files must be in scripts/test/init.lua
lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
module = lunit.module
end
path = 'scripts'
if config.install then
path = config.install .. '/' .. path
end
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,9 +1,9 @@
local tcname = 'tests.bindings'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
local _G = _G

View File

@ -1,9 +1,9 @@
local tcname = 'tests.shared.common'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
local function _test_create_ship(r)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,9 +1,9 @@
local tcname = 'tests.e2.quit'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function test_quit_faction()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,9 +1,9 @@
local tcname = 'tests.e3.rules'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
local settings

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,7 +3,7 @@ local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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