new lua test framework, work in progress.

This commit is contained in:
Enno Rehling 2014-06-12 17:41:03 -07:00
parent b84bf7ba56
commit 30c1b0e1ff
8 changed files with 345 additions and 286 deletions

View File

@ -1,4 +1,20 @@
#!/bin/sh
ROOT=$(pwd)
while [ ! -d $ROOT/.git ]; do
ROOT=$(dirname $ROOT)
if [ "$ROOT" == "/" ; then
echo "could not find root, are you in the git repository?"
exit
fi
done
MACHINE=`uname -m`
[ -z "$CC" ] && [ ! -z `which gcc` ] && CC="gcc"
[ -z "$CC" ] && [ ! -z `which tcc` ] && CC="tcc"
[ -z "$CC" ] && [ ! -z `which cc` ] && CC="cc"
BIN_DIR="build-$MACHINE-$CC-Debug"
cd $BIN_DIR
if [ ! -e ../CMakeLists.txt ]; then
echo "are you sure you are in the build directory?"
exit
@ -26,3 +42,4 @@ cmake .. \
-DCMAKE_INCLUDE_PATH=$INCLUDE_PATH \
-DCMAKE_PREFIX_PATH=$PREFIX_PATH \
-DCMAKE_INSTALL_PREFIX=$HOME/eressea $*
cd -

View File

@ -17,8 +17,6 @@ fi
echo $ROOT
$ROOT/$BIN_DIR/eressea/test_eressea
pushd $ROOT/game-e2
$ROOT/$BIN_DIR/eressea/eressea runtests.lua
cd $ROOT/game-e3
$ROOT/$BIN_DIR/eressea/eressea runtests.lua
popd
cd $ROOT/scripts
$ROOT/$BIN_DIR/eressea/eressea -v0 runtests.lua

7
scripts/runtests.lua Normal file
View File

@ -0,0 +1,7 @@
-- new tests 2014-06-11
require "lunit"
require "tests.settings"
require "tests.config"
lunit.main()

18
scripts/tests/config.lua Normal file
View File

@ -0,0 +1,18 @@
require "lunit"
module("tests.eressea.config", package.seeall, lunit.testcase )
function setup()
eressea.free_game()
end
function test_read()
local f
f = faction.create("orc@example.com", "orc", "en")
assert_equal(nil, f)
assert_not_nil(eressea.config)
eressea.config.parse('{ "races": { "orc" : {}}}')
f = faction.create("orc@example.com", "orc", "en")
assert_not_nil(f)
end

View File

@ -200,3 +200,4 @@ function test_snowman()
end
assert_equal(nil, u)
end

View File

@ -0,0 +1,13 @@
require "lunit"
module("tests.eressea.settings", package.seeall, lunit.testcase )
function setup()
eressea.free_game()
end
function test_settings()
assert_equal(nil, eressea.settings.get("foo"))
eressea.settings.set("foo", "bar")
assert_equal("bar", eressea.settings.get("foo"))
end

View File

@ -258,6 +258,7 @@
Name="Source Files"
Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d;*.m;*.mm;*.go">
<F N="../src/bind_building.c"/>
<F N="../src/bind_config.c"/>
<F N="../src/bind_eressea.c"/>
<F N="../src/bind_faction.c"/>
<F N="../src/bind_gmtool.c"/>
@ -272,6 +273,7 @@
<F N="../src/bind_storage.c"/>
<F N="../src/bind_unit.c"/>
<F N="../src/bindings.c"/>
<F N="../src/config.pkg.c"/>
<F N="../src/console.c"/>
<F N="../src/eressea.pkg.c"/>
<F N="../src/gmtool.c"/>
@ -286,6 +288,7 @@
Name="Header Files"
Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if">
<F N="../src/bind_building.h"/>
<F N="../src/bind_config.h"/>
<F N="../src/bind_eressea.h"/>
<F N="../src/bind_faction.h"/>
<F N="../src/bind_gmtool.h"/>

View File

@ -1,284 +1,286 @@
<!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd">
<Project
Version="10.0"
VendorName="SlickEdit"
TemplateName="GNU C/C++"
WorkingDir="."
BuildSystem="vsbuild">
<Config
Name="Debug"
Type="gnuc"
DebugCallbackName="gdb"
Version="1"
OutputFile="%bdtests"
CompilerConfigName="Latest Version"
Defines='"/DUSE_AUTOCONF"'>
<Menu>
<Target
Name="Compile"
MenuCaption="&amp;Compile"
Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer"
Deletable="0"
OutputExts="*.o"
SaveOption="SaveCurrent"
RunFromDir="%rw">
<Exec
CmdLine='gcc -c %xup -v -pipe -ansi %defd -g -Wall -Werror %~other -o "%bd%n%oe" %i %f'
OtherOptions="-std=c99"/>
</Target>
<Target
Name="Link"
MenuCaption="&amp;Link"
ShowOnMenu="Never"
Dialog="_gnuc_options_form Link"
CaptureOutputWith="ProcessBuffer"
Deletable="0"
SaveOption="SaveCurrent"
RunFromDir="%rw">
<Exec CmdLine='gcc %xup -v -pipe -g -Wall -Werror -o "%o" %objs'/>
</Target>
<Target
Name="Build"
MenuCaption="&amp;Build"
Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer"
Deletable="0"
SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"
DependsRef="Debug">
<Exec CmdLine='"%(VSLICKBIN1)vsbuild" "%w" "%r" -t build'/>
</Target>
<Target
Name="Rebuild"
MenuCaption="&amp;Rebuild"
Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer"
Deletable="0"
SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"
DependsRef="Debug">
<Exec CmdLine='"%(VSLICKBIN1)vsbuild" "%w" "%r" -t rebuild'/>
</Target>
<Target
Name="Debug"
MenuCaption="&amp;Debug"
Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1"
CaptureOutputWith="ProcessBuffer"
Deletable="0"
SaveOption="SaveNone"
RunFromDir="%rw">
<Exec CmdLine='vsdebugio -prog "%o"'/>
</Target>
<Target
Name="Execute"
MenuCaption="E&amp;xecute"
Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1"
CaptureOutputWith="ProcessBuffer"
Deletable="0"
SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw">
<Exec CmdLine='"%o"'/>
</Target>
<Target
Name="dash"
MenuCaption="-"
Deletable="0">
<Exec/>
</Target>
<Target
Name="GNU C Options"
MenuCaption="GNU C &amp;Options..."
ShowOnMenu="HideIfNoCmdLine"
Deletable="0"
SaveOption="SaveNone">
<Exec
CmdLine="gnucoptions"
Type="Slick-C"/>
</Target>
</Menu>
<List Name="GNUC Options">
<Item
Name="LinkerOutputType"
Value="Executable"/>
</List>
<Dependencies Name="Debug">
<Dependency Project="eressea.vpj"/>
</Dependencies>
<Includes>
<Include Dir="../src"/>
<Include Dir="../cutest"/>
<Include Dir="../build-i686-gcc-Debug/include"/>
<Include Dir="../quicklist"/>
<Include Dir="../storage"/>
<Include Dir="../cJSON"/>
</Includes>
<Libs PreObjects="0">
<Lib File="%bderessea.a"/>
<Lib File="/usr/lib/i386-linux-gnu/libxml2.a"/>
<Lib File="/usr/lib/i386-linux-gnu/libm.a"/>
</Libs>
</Config>
<Config
Name="Release"
Type="gnuc"
DebugCallbackName="gdb"
Version="1"
OutputFile="%bdtests"
CompilerConfigName="Latest Version"
Defines='"/DUSE_AUTOCONF"'>
<Menu>
<Target
Name="Compile"
MenuCaption="&amp;Compile"
Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer"
Deletable="0"
OutputExts="*.o"
SaveOption="SaveCurrent"
RunFromDir="%rw">
<Exec
CmdLine='gcc -c %xup -v -pipe -ansi %defd -Wall -Werror %~other -o "%bd%n%oe" %i %f'
OtherOptions="-std=c99"/>
</Target>
<Target
Name="Link"
MenuCaption="&amp;Link"
ShowOnMenu="Never"
Dialog="_gnuc_options_form Link"
CaptureOutputWith="ProcessBuffer"
Deletable="0"
SaveOption="SaveCurrent"
RunFromDir="%rw">
<Exec CmdLine='gcc %xup -v -pipe -Wall -Werror -o "%o" %objs'/>
</Target>
<Target
Name="Build"
MenuCaption="&amp;Build"
Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer"
Deletable="0"
SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"
DependsRef="Release">
<Exec CmdLine='"%(VSLICKBIN1)vsbuild" "%w" "%r" -t build'/>
</Target>
<Target
Name="Rebuild"
MenuCaption="&amp;Rebuild"
Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer"
Deletable="0"
SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"
DependsRef="Release">
<Exec CmdLine='"%(VSLICKBIN1)vsbuild" "%w" "%r" -t rebuild'/>
</Target>
<Target
Name="Debug"
MenuCaption="&amp;Debug"
Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1"
CaptureOutputWith="ProcessBuffer"
Deletable="0"
SaveOption="SaveNone"
RunFromDir="%rw">
<Exec CmdLine='vsdebugio -prog "%o"'/>
</Target>
<Target
Name="Execute"
MenuCaption="E&amp;xecute"
Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1"
CaptureOutputWith="ProcessBuffer"
Deletable="0"
SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw">
<Exec CmdLine='"%o"'/>
</Target>
<Target
Name="dash"
MenuCaption="-"
Deletable="0">
<Exec/>
</Target>
<Target
Name="GNU C Options"
MenuCaption="GNU C &amp;Options..."
ShowOnMenu="HideIfNoCmdLine"
Deletable="0"
SaveOption="SaveNone">
<Exec
CmdLine="gnucoptions"
Type="Slick-C"/>
</Target>
</Menu>
<List Name="GNUC Options">
<Item
Name="LinkerOutputType"
Value="Executable"/>
</List>
<Dependencies Name="Release">
<Dependency Project="eressea.vpj"/>
</Dependencies>
<Includes>
<Include Dir="../src"/>
<Include Dir="../cutest"/>
<Include Dir="../build-i686-gcc-Debug/include"/>
<Include Dir="../quicklist"/>
<Include Dir="../storage"/>
<Include Dir="../cJSON"/>
</Includes>
<Libs PreObjects="0">
<Lib File="%bderessea.a"/>
<Lib File="/usr/lib/i386-linux-gnu/libxml2.a"/>
<Lib File="/usr/lib/i386-linux-gnu/libm.a"/>
</Libs>
</Config>
<Files>
<Folder
Name="Source Files"
Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d;*.m;*.mm;*.go">
<F N="../cutest/CuTest.c"/>
<F N="../src/kernel/ally_test.c"/>
<F N="../src/util/base36_test.c"/>
<F N="../src/kernel/battle_test.c"/>
<F N="../src/util/bsdstring_test.c"/>
<F N="../src/kernel/building_test.c"/>
<F N="../src/kernel/curse_test.c"/>
<F N="../src/economy_test.c"/>
<F N="../src/kernel/equipment_test.c"/>
<F N="../src/util/functions_test.c"/>
<F N="../src/kernel/item_test.c"/>
<F N="../src/json_test.c"/>
<F N="../src/kernel/jsonconf_test.c"/>
<F N="../src/laws_test.c"/>
<F N="../src/kernel/magic_test.c"/>
<F N="../src/market_test.c"/>
<F N="../src/kernel/move_test.c"/>
<F N="../src/kernel/pool_test.c"/>
<F N="../src/kernel/reports_test.c"/>
<F N="../src/kernel/ship_test.c"/>
<F N="../src/kernel/spell_test.c"/>
<F N="../src/kernel/spellbook_test.c"/>
<F N="../src/test_eressea.c"/>
<F N="../src/tests.c"/>
<F N="../src/tests_test.c"/>
<F N="../src/util/umlaut_test.c"/>
</Folder>
<Folder
Name="Header Files"
Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if"/>
<Folder
Name="Resource Files"
Filters="*.ico;*.cur;*.dlg"/>
<Folder
Name="Bitmaps"
Filters="*.bmp"/>
<Folder
Name="Other Files"
Filters=""/>
</Files>
Version="10.0"
VendorName="SlickEdit"
TemplateName="GNU C/C++"
WorkingDir="."
BuildSystem="vsbuild">
<Config
Name="Debug"
Type="gnuc"
DebugCallbackName="gdb"
Version="1"
OutputFile="%bdtests"
CompilerConfigName="Latest Version"
Defines='"/DUSE_AUTOCONF"'>
<Menu>
<Target
Name="Compile"
MenuCaption="&amp;Compile"
Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer"
Deletable="0"
OutputExts="*.o"
SaveOption="SaveCurrent"
RunFromDir="%rw">
<Exec
CmdLine='gcc -c %xup -v -pipe -ansi %defd -g -Wall -Werror %~other -o "%bd%n%oe" %i %f'
OtherOptions="-std=c99"/>
</Target>
<Target
Name="Link"
MenuCaption="&amp;Link"
ShowOnMenu="Never"
Dialog="_gnuc_options_form Link"
CaptureOutputWith="ProcessBuffer"
Deletable="0"
SaveOption="SaveCurrent"
RunFromDir="%rw">
<Exec CmdLine='gcc %xup -v -pipe -g -Wall -Werror -o "%o" %objs'/>
</Target>
<Target
Name="Build"
MenuCaption="&amp;Build"
Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer"
Deletable="0"
SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"
DependsRef="Debug">
<Exec CmdLine='"%(VSLICKBIN1)vsbuild" "%w" "%r" -t build'/>
</Target>
<Target
Name="Rebuild"
MenuCaption="&amp;Rebuild"
Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer"
Deletable="0"
SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"
DependsRef="Debug">
<Exec CmdLine='"%(VSLICKBIN1)vsbuild" "%w" "%r" -t rebuild'/>
</Target>
<Target
Name="Debug"
MenuCaption="&amp;Debug"
Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1"
CaptureOutputWith="ProcessBuffer"
Deletable="0"
SaveOption="SaveNone"
RunFromDir="%rw">
<Exec CmdLine='vsdebugio -prog "%o"'/>
</Target>
<Target
Name="Execute"
MenuCaption="E&amp;xecute"
Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1"
CaptureOutputWith="ProcessBuffer"
Deletable="0"
SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw">
<Exec CmdLine='"%o"'/>
</Target>
<Target
Name="dash"
MenuCaption="-"
Deletable="0">
<Exec/>
</Target>
<Target
Name="GNU C Options"
MenuCaption="GNU C &amp;Options..."
ShowOnMenu="HideIfNoCmdLine"
Deletable="0"
SaveOption="SaveNone">
<Exec
CmdLine="gnucoptions"
Type="Slick-C"/>
</Target>
</Menu>
<List Name="GNUC Options">
<Item
Name="LinkerOutputType"
Value="Executable"/>
</List>
<Dependencies Name="Debug">
<Dependency Project="eressea.vpj"/>
</Dependencies>
<Includes>
<Include Dir="../src"/>
<Include Dir="../cutest"/>
<Include Dir="../build-i686-gcc-Debug/include"/>
<Include Dir="../quicklist"/>
<Include Dir="../storage"/>
<Include Dir="../cJSON"/>
</Includes>
<Libs PreObjects="0">
<Lib File="%bderessea.a"/>
<Lib File="/usr/lib/i386-linux-gnu/libm.a"/>
</Libs>
</Config>
<Config
Name="Release"
Type="gnuc"
DebugCallbackName="gdb"
Version="1"
OutputFile="%bdtests"
CompilerConfigName="Latest Version"
Defines='"/DUSE_AUTOCONF"'>
<Menu>
<Target
Name="Compile"
MenuCaption="&amp;Compile"
Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer"
Deletable="0"
OutputExts="*.o"
SaveOption="SaveCurrent"
RunFromDir="%rw">
<Exec
CmdLine='gcc -c %xup -v -pipe -ansi %defd -Wall -Werror %~other -o "%bd%n%oe" %i %f'
OtherOptions="-std=c99"/>
</Target>
<Target
Name="Link"
MenuCaption="&amp;Link"
ShowOnMenu="Never"
Dialog="_gnuc_options_form Link"
CaptureOutputWith="ProcessBuffer"
Deletable="0"
SaveOption="SaveCurrent"
RunFromDir="%rw">
<Exec CmdLine='gcc %xup -v -pipe -Wall -Werror -o "%o" %objs'/>
</Target>
<Target
Name="Build"
MenuCaption="&amp;Build"
Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer"
Deletable="0"
SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"
DependsRef="Release">
<Exec CmdLine='"%(VSLICKBIN1)vsbuild" "%w" "%r" -t build'/>
</Target>
<Target
Name="Rebuild"
MenuCaption="&amp;Rebuild"
Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer"
Deletable="0"
SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"
DependsRef="Release">
<Exec CmdLine='"%(VSLICKBIN1)vsbuild" "%w" "%r" -t rebuild'/>
</Target>
<Target
Name="Debug"
MenuCaption="&amp;Debug"
Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1"
CaptureOutputWith="ProcessBuffer"
Deletable="0"
SaveOption="SaveNone"
RunFromDir="%rw">
<Exec CmdLine='vsdebugio -prog "%o"'/>
</Target>
<Target
Name="Execute"
MenuCaption="E&amp;xecute"
Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1"
CaptureOutputWith="ProcessBuffer"
Deletable="0"
SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw">
<Exec CmdLine='"%o"'/>
</Target>
<Target
Name="dash"
MenuCaption="-"
Deletable="0">
<Exec/>
</Target>
<Target
Name="GNU C Options"
MenuCaption="GNU C &amp;Options..."
ShowOnMenu="HideIfNoCmdLine"
Deletable="0"
SaveOption="SaveNone">
<Exec
CmdLine="gnucoptions"
Type="Slick-C"/>
</Target>
</Menu>
<List Name="GNUC Options">
<Item
Name="LinkerOutputType"
Value="Executable"/>
</List>
<Dependencies Name="Release">
<Dependency Project="eressea.vpj"/>
</Dependencies>
<Includes>
<Include Dir="../src"/>
<Include Dir="../cutest"/>
<Include Dir="../build-i686-gcc-Debug/include"/>
<Include Dir="../quicklist"/>
<Include Dir="../storage"/>
<Include Dir="../cJSON"/>
</Includes>
<Libs PreObjects="0">
<Lib File="%bderessea.a"/>
<Lib File="/usr/lib/i386-linux-gnu/libm.a"/>
</Libs>
</Config>
<Files>
<Folder
Name="Source Files"
Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d;*.m;*.mm;*.go">
<F N="../cutest/CuTest.c"/>
<F N="../src/kernel/ally_test.c"/>
<F N="../src/util/base36_test.c"/>
<F N="../src/kernel/battle_test.c"/>
<F N="../src/util/bsdstring_test.c"/>
<F N="../src/kernel/building_test.c"/>
<F N="../src/kernel/curse_test.c"/>
<F N="../src/economy_test.c"/>
<F N="../src/kernel/equipment_test.c"/>
<F N="../src/util/functions_test.c"/>
<F N="../src/kernel/item_test.c"/>
<F N="../src/json_test.c"/>
<F N="../src/kernel/jsonconf_test.c"/>
<F N="../src/laws_test.c"/>
<F N="../src/kernel/magic_test.c"/>
<F N="../src/market_test.c"/>
<F N="../src/kernel/move_test.c"/>
<F N="../src/kernel/pool_test.c"/>
<F N="../src/kernel/reports_test.c"/>
<F N="../src/kernel/ship_test.c"/>
<F N="../src/kernel/spell_test.c"/>
<F N="../src/kernel/spellbook_test.c"/>
<F N="../src/test_eressea.c"/>
<F N="../src/tests.c"/>
<F N="../src/tests_test.c"/>
<F N="../src/util/umlaut_test.c"/>
</Folder>
<Folder
Name="Header Files"
Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if"/>
<Folder
Name="Resource Files"
Filters="*.ico;*.cur;*.dlg"/>
<Folder
Name="Bitmaps"
Filters="*.bmp"/>
<Folder
Name="Other Files"
Filters="">
<F N="../scripts/tests/config.lua"/>
<F N="../scripts/runtests.lua"/>
<F N="../scripts/tests/settings.lua"/>
</Folder>
</Files>
</Project>