forked from github/server
repairing lua tests
Das ist totales Chaos, viele Testcases wurden einfach nicht ausgeführt weil sie nicht in den init files stehen. Etwas neu strukturiert, Test laufen jetzt auch wenn sie nicht aus dem eressea root Ordner gestartet werden wie in s/runtest und es sind einige Testcases mehr als bisher. Auch macht Travis jetzt die E3 Test. Dabei ist ein schwerwiegender Fehler beim neuen Bewache aufgefallen!
This commit is contained in:
parent
82f30288f8
commit
8f21aa7a11
|
@ -18,6 +18,7 @@ fi
|
|||
$ROOT/$BIN_DIR/eressea/test_eressea
|
||||
cd $ROOT
|
||||
[ -e eressea.ini ] || ln -sf conf/eressea.ini
|
||||
$ROOT/$BIN_DIR/eressea/eressea -v0 scripts/run-tests.lua
|
||||
$ROOT/$BIN_DIR/eressea/eressea -v0 scripts/run-tests-basic.lua
|
||||
$ROOT/$BIN_DIR/eressea/eressea -v0 scripts/run-tests-e2.lua
|
||||
$ROOT/$BIN_DIR/eressea/eressea -v0 scripts/run-tests-e3.lua
|
||||
cd $OLDWPD
|
||||
|
|
|
@ -13,4 +13,6 @@ cd build && cmake .. \
|
|||
-DCMAKE_BUILD_TYPE=Debug .. && \
|
||||
make && cd .. && inifile &&
|
||||
build/eressea/test_eressea &&
|
||||
build/eressea/eressea -v0 scripts/run-tests.lua
|
||||
build/eressea/eressea -v0 scripts/run-tests-basic.lua
|
||||
build/eressea/eressea -v0 scripts/run-tests-e2.lua
|
||||
build/eressea/eressea -v0 scripts/run-tests-e3.lua
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
-- new tests 2014-06-11
|
||||
-- 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
|
||||
|
||||
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'
|
||||
require 'tests'
|
||||
require 'lunit'
|
||||
lunit.main()
|
|
@ -0,0 +1,21 @@
|
|||
-- 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
|
||||
|
||||
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'
|
||||
|
||||
config.rules = 'e2'
|
||||
|
||||
require 'eressea'
|
||||
require 'eressea.xmlconf'
|
||||
require 'eressea.path'
|
||||
require 'tests.e2'
|
||||
require 'lunit'
|
||||
|
||||
rules = require('eressea.' .. config.rules)
|
||||
lunit.main()
|
|
@ -1,8 +1,11 @@
|
|||
-- new tests 2014-06-11
|
||||
-- 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
|
||||
|
||||
path = 'scripts'
|
||||
if config.source_dir ~= nil then
|
||||
path = config.source_dir .. '/' .. path
|
||||
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'
|
||||
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
-- new tests 2014-06-11
|
||||
|
||||
path = 'scripts'
|
||||
if config.source_dir ~= nil then
|
||||
path = config.source_dir .. '/' .. path
|
||||
end
|
||||
package.path = package.path .. ';' .. path .. '/?.lua;' .. path .. '/?/init.lua'
|
||||
|
||||
require 'eressea'
|
||||
require 'eressea.path'
|
||||
require 'tests'
|
||||
require 'lunit'
|
||||
lunit.main()
|
|
@ -1,6 +1,6 @@
|
|||
require "lunit"
|
||||
|
||||
module("tests.e3.e2features", package.seeall, lunit.testcase )
|
||||
module("tests.e2.e2features", package.seeall, lunit.testcase )
|
||||
|
||||
local function one_unit(r, f)
|
||||
local u = unit.create(f, r, 1)
|
||||
|
@ -269,7 +269,7 @@ end
|
|||
function test_block_movement_aots()
|
||||
eressea.settings.set("rules.guard.base_stop_prob", "0.0")
|
||||
eressea.settings.set("rules.guard.skill_stop_prob", "1.0")
|
||||
eressea.settings.set("rules.guard.amulet_stop_prob", "1.1")
|
||||
eressea.settings.set("rules.guard.amulet_stop_prob", "1.0")
|
||||
|
||||
local r0 = region.create(0, 0, "plain")
|
||||
local r1 = region.create(1, 0, "plain")
|
||||
|
@ -298,7 +298,7 @@ function test_block_movement_aots()
|
|||
u:add_order("NACH o o")
|
||||
end
|
||||
|
||||
u12:add_item("aots", 10)
|
||||
u12:add_item("aots", 1)
|
||||
u22:set_skill("stealth", 1)
|
||||
|
||||
process_orders()
|
||||
|
@ -334,27 +334,3 @@ function test_stonegolems()
|
|||
assert_equal(1 ,u2.number, "There shoud be one Stone Golems")
|
||||
-- end test Stone Golems four stones
|
||||
end
|
||||
|
||||
function test_only_building_owner_can_set_not_paid()
|
||||
local r = region.create(0, 0, "plain")
|
||||
local f = faction.create("noreply@eressea.de", "human", "de")
|
||||
local u1 = unit.create(f, r, 1)
|
||||
local u2 = unit.create(f, r, 1)
|
||||
local mine = building.create(r, "mine")
|
||||
mine.size = 2
|
||||
u1:add_item("money", 500)
|
||||
u1.building = mine
|
||||
u2.building = mine
|
||||
u1:clear_orders()
|
||||
u2:clear_orders()
|
||||
-- Test that Bezahle nicht is working
|
||||
u1:add_order("Bezahle nicht")
|
||||
process_orders()
|
||||
assert_equal(500, u1:get_item("money"))
|
||||
u1:clear_orders()
|
||||
-- Test that bug fix 0001976 is working
|
||||
-- Bezahle nicht is not working
|
||||
u2:add_order("Bezahle nicht")
|
||||
process_orders()
|
||||
assert_equal(0, u1:get_item("money"))
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
-- new tests 2015-02-13
|
||||
require 'tests.e2.shiplanding'
|
||||
require 'tests.e2.e2features'
|
||||
|
|
@ -1,19 +1,18 @@
|
|||
require "lunit"
|
||||
|
||||
module("tests.rules", package.seeall, lunit.testcase)
|
||||
module("tests.e2.shiplanding", package.seeall, lunit.testcase)
|
||||
|
||||
function setup()
|
||||
eressea.free_game()
|
||||
eressea.settings.set("nmr.removenewbie", "0")
|
||||
eressea.settings.set("nmr.timeout", "0")
|
||||
eressea.settings.set("NewbieImmunity", "0")
|
||||
eressea.config.parse('{ "races": { "human" : {}}}')
|
||||
end
|
||||
|
||||
function test_landing1()
|
||||
local ocean = region.create(1, 0, "ocean")
|
||||
local r = region.create(0, 0, "plain")
|
||||
local f = faction.create("noreply@eressea.de", "insects", "de")
|
||||
local f = faction.create("noreply@eressea.de", "human", "de")
|
||||
local f2 = faction.create("noreply@eressea.de", "human", "de")
|
||||
local s = ship.create(ocean, "longboat")
|
||||
local u1 = unit.create(f, ocean, 1)
|
||||
|
@ -31,7 +30,33 @@ function test_landing1()
|
|||
assert_equal(r.id, u1.region.id) -- the plain case: okay
|
||||
end
|
||||
|
||||
function test_landing_harbour()
|
||||
function test_landing_harbour_with_help()
|
||||
local ocean = region.create(1, 0, "ocean")
|
||||
local r = region.create(0, 0, "glacier")
|
||||
local harbour = building.create(r, "harbour")
|
||||
harbour.size = 25
|
||||
local f = faction.create("noreply@eressea.de", "human", "de")
|
||||
local f2 = faction.create("noreply@eressea.de", "human", "de")
|
||||
local s = ship.create(ocean, "longboat")
|
||||
local u1 = unit.create(f, ocean, 1)
|
||||
local u2 = unit.create(f2, r, 1)
|
||||
assert_not_nil(u2)
|
||||
u1:add_item("money", 1000)
|
||||
u2:add_item("money", 1000)
|
||||
u2.building = harbour
|
||||
u2:clear_orders()
|
||||
u2:add_order("KONTAKTIERE " .. itoa36(u1.id))
|
||||
|
||||
u1.ship = s
|
||||
u1:set_skill("sailing", 10)
|
||||
u1:clear_orders()
|
||||
u1:add_order("NACH w")
|
||||
process_orders()
|
||||
|
||||
assert_equal(r.id, u1.region.id) -- glacier with harbour and help-- okay
|
||||
end
|
||||
|
||||
function test_landing_harbour_without_help()
|
||||
local ocean = region.create(1, 0, "ocean")
|
||||
local r = region.create(0, 0, "glacier")
|
||||
local harbour = building.create(r, "harbour")
|
||||
|
@ -52,7 +77,7 @@ function test_landing_harbour()
|
|||
u1:add_order("NACH w")
|
||||
process_orders()
|
||||
|
||||
assert_equal(r.id, u1.region.id) -- glacier with harbour -- okay
|
||||
assert_equal(ocean.id, u1.region.id) -- glacier with harbour and no help-- cannot land
|
||||
end
|
||||
|
||||
function test_landing_harbour_unpaid()
|
||||
|
@ -61,13 +86,12 @@ function test_landing_harbour_unpaid()
|
|||
local harbour = building.create(r, "harbour")
|
||||
harbour.size = 25
|
||||
local f = faction.create("noreply@eressea.de", "human", "de")
|
||||
local f2 = faction.create("noreply@eressea.de", "human", "de")
|
||||
local s = ship.create(ocean, "longboat")
|
||||
local u1 = unit.create(f, ocean, 1)
|
||||
local u2 = unit.create(f2, r, 1)
|
||||
local u2 = unit.create(f, r, 1)
|
||||
assert_not_nil(u2)
|
||||
u1:add_item("money", 1000)
|
||||
u2:add_item("money", 1000)
|
||||
u2:add_item("money", 20)
|
||||
|
||||
u1.ship = s
|
||||
u1:set_skill("sailing", 10)
|
||||
|
@ -91,8 +115,7 @@ function test_landing_terrain()
|
|||
u2:add_item("money", 1000)
|
||||
|
||||
u1.ship = s
|
||||
u1:set_skill("sailing", 10)
|
||||
u1:clear_orders()
|
||||
u1:set_skill("sailing", 10) u1:clear_orders()
|
||||
u1:add_order("NACH w")
|
||||
process_orders()
|
||||
|
||||
|
@ -104,7 +127,7 @@ function test_landing_insects()
|
|||
local r = region.create(0, 0, "glacier")
|
||||
local harbour = building.create(r, "harbour")
|
||||
harbour.size = 25
|
||||
local f = faction.create("noreply@eressea.de", "insects", "de")
|
||||
local f = faction.create("noreply@eressea.de", "insect", "de")
|
||||
local f2 = faction.create("noreply@eressea.de", "human", "de")
|
||||
local s = ship.create(ocean, "longboat")
|
||||
local u1 = unit.create(f, ocean, 1)
|
|
@ -779,3 +779,27 @@ function test_weightless_silver()
|
|||
u1:add_item("money", 540)
|
||||
assert_equal(1000, u1.weight)
|
||||
end
|
||||
|
||||
function test_only_building_owner_can_set_not_paid()
|
||||
local r = region.create(0, 0, "plain")
|
||||
local f = faction.create("noreply@eressea.de", "human", "de")
|
||||
local u1 = unit.create(f, r, 1)
|
||||
local u2 = unit.create(f, r, 1)
|
||||
local mine = building.create(r, "mine")
|
||||
mine.size = 2
|
||||
u1:add_item("money", 500)
|
||||
u1.building = mine
|
||||
u2.building = mine
|
||||
u1:clear_orders()
|
||||
u2:clear_orders()
|
||||
-- Test that Bezahle nicht is working
|
||||
u1:add_order("Bezahle nicht")
|
||||
process_orders()
|
||||
assert_equal(500, u1:get_item("money"))
|
||||
u1:clear_orders()
|
||||
-- Test that bug fix 0001976 is working
|
||||
-- Bezahle nicht is not working
|
||||
u2:add_order("Bezahle nicht")
|
||||
process_orders()
|
||||
assert_equal(0, u1:get_item("money"))
|
||||
end
|
||||
|
|
|
@ -1,15 +1,10 @@
|
|||
require "lunit"
|
||||
|
||||
module ('tests.eressea.faction', package.seeall, lunit.testcase)
|
||||
|
||||
local f
|
||||
|
||||
function setup()
|
||||
conf = [[{
|
||||
"races": {
|
||||
"human" : {}
|
||||
}
|
||||
}]]
|
||||
eressea.config.reset()
|
||||
assert(eressea.config.parse(conf)==0)
|
||||
f = faction.create("faction@eressea.de", "human", "de")
|
||||
end
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
-- new tests 2014-06-11
|
||||
require 'tests.pool'
|
||||
require 'tests.settings'
|
||||
require 'tests.config'
|
||||
require 'tests.faction'
|
||||
require 'tests.locale'
|
||||
require 'tests.regions'
|
||||
require 'tests.study'
|
||||
require 'tests.movement'
|
||||
require 'tests.pool'
|
||||
require 'tests.regions'
|
||||
require 'tests.settings'
|
||||
require 'tests.study'
|
||||
|
|
Loading…
Reference in New Issue