replace config.install with environment variable

This commit is contained in:
Enno Rehling 2021-02-22 01:53:01 +01:00
parent 6176e5e754
commit 2bb18d27bc
7 changed files with 29 additions and 44 deletions

View File

@ -1,3 +1,15 @@
local path = os.getenv("ERESSEA_DIR")
if not path then
if config.install then
path = config.install
else
path = '.'
end
else
config.install = path
end
path = path .. "/scripts"
package.path = path .. '/?.lua;' .. path .. '/?/init.lua;' .. package.path
if config.paths ~= nil then if config.paths ~= nil then
for path in string.gmatch(config.paths, "([^:]+)") do for path in string.gmatch(config.paths, "([^:]+)") do
package.path = package.path .. ';' .. path .. '/?.lua;' .. path .. '/?/init.lua' package.path = package.path .. ';' .. path .. '/?.lua;' .. path .. '/?/init.lua'

View File

@ -1,9 +1,3 @@
local path = 'scripts'
if config.install then
path = config.install .. '/' .. path
end
package.path = path .. '/?.lua;' .. path .. '/?/init.lua;' .. package.path
require 'eressea.path' require 'eressea.path'
require 'eressea' require 'eressea'
require 'eressea.xmlconf' require 'eressea.xmlconf'

View File

@ -1,22 +1,15 @@
-- Tests that work in all games. With game config of E2. -- 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 -- 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
end
package.path = path .. '/?.lua;' .. path .. '/?/init.lua;' .. package.path
config.rules = 'e2' config.rules = 'e2'
lunit = require 'lunit'
if _VERSION >= 'Lua 5.2' then
module = lunit.module
end
require 'eressea.path'
require 'eressea' require 'eressea'
require 'eressea.xmlconf' require 'eressea.xmlconf'
require 'eressea.path'
require 'tests.e2' require 'tests.e2'
rng.inject(0) rng.inject(0)

View File

@ -1,21 +1,14 @@
-- Tests that work in E3. With game config of E3. -- 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 -- 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
path = config.install .. '/' .. path
end
package.path = path .. '/?.lua;' .. path .. '/?/init.lua;' .. package.path
config.rules = 'e3' config.rules = 'e3'
lunit = require 'lunit'
if _VERSION >= 'Lua 5.2' then
module = lunit.module
end
require 'eressea'
require 'eressea.path' require 'eressea.path'
require 'eressea'
require 'eressea.xmlconf' require 'eressea.xmlconf'
require 'tests.e3' require 'tests.e3'

View File

@ -1,19 +1,13 @@
-- Basic test without loading XML Config. Test care about needed settings. -- 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 -- Tests are under scripts/test/ and all files must be in scripts/test/init.lua
lunit = require('lunit') lunit = require 'lunit'
if _VERSION >= 'Lua 5.2' then if _VERSION >= 'Lua 5.2' then
module = lunit.module module = lunit.module
end end
path = 'scripts'
if config.install then
path = config.install .. '/' .. path
end
package.path = path .. '/?.lua;' .. path .. '/?/init.lua;' .. package.path
require 'eressea'
require 'eressea.path' require 'eressea.path'
require 'eressea'
require 'tests' require 'tests'
result = lunit.main() result = lunit.main()
return result.errors + result.failed return result.errors + result.failed

View File

@ -1,3 +1,5 @@
require 'eressea.path'
function nmr_check(maxnmrs) function nmr_check(maxnmrs)
local nmrs = get_nmrs(1) local nmrs = get_nmrs(1)
if nmrs > maxnmrs then if nmrs > maxnmrs then
@ -188,11 +190,6 @@ end
math.randomseed(rng.random()) math.randomseed(rng.random())
local path = 'scripts'
if config.install then
path = config.install .. '/' .. path
end
package.path = path .. '/?.lua;' .. path .. '/?/init.lua;' .. package.path
require 'eressea' require 'eressea'
require 'eressea.xmlconf' -- read xml data require 'eressea.xmlconf' -- read xml data

View File

@ -5,10 +5,12 @@ IF EXIST ..\build-vs12 SET BUILD=..\build-vs12\Debug
IF EXIST ..\build-vs14 SET BUILD=..\build-vs14\Debug IF EXIST ..\build-vs14 SET BUILD=..\build-vs14\Debug
IF EXIST ..\build-vs15 SET BUILD=..\build-vs15\Debug IF EXIST ..\build-vs15 SET BUILD=..\build-vs15\Debug
IF EXIST ..\build-vs16 SET BUILD=..\build-vs16\Debug IF EXIST ..\build-vs16 SET BUILD=..\build-vs16\Debug
IF EXIST ..\out\build\x86-Debug\eressea.exe SET BUILD=..\out\build\x86-Debug
IF EXIST ..\out\build\x64-Debug\eressea.exe SET BUILD=..\out\build\x64-Debug
SET SERVER=%BUILD%\eressea.exe SET SERVER=%BUILD%\eressea.exe
%BUILD%\test_eressea.exe %BUILD%\test_eressea.exe
REM SET LUA_PATH=..\share\lua\5.4\?.lua;; SET LUA_PATH=..\scripts\?.lua;..\share\lua\5.4\?.lua;;
%SERVER% -v1 ..\scripts\run-tests.lua %SERVER% -v1 ..\scripts\run-tests.lua
%SERVER% -v1 -re2 ..\scripts\run-tests-e2.lua %SERVER% -v1 -re2 ..\scripts\run-tests-e2.lua