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 #!/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 if [ ! -e ../CMakeLists.txt ]; then
echo "are you sure you are in the build directory?" echo "are you sure you are in the build directory?"
exit exit
@ -26,3 +42,4 @@ cmake .. \
-DCMAKE_INCLUDE_PATH=$INCLUDE_PATH \ -DCMAKE_INCLUDE_PATH=$INCLUDE_PATH \
-DCMAKE_PREFIX_PATH=$PREFIX_PATH \ -DCMAKE_PREFIX_PATH=$PREFIX_PATH \
-DCMAKE_INSTALL_PREFIX=$HOME/eressea $* -DCMAKE_INSTALL_PREFIX=$HOME/eressea $*
cd -

View File

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

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