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

@ -117,7 +117,6 @@
</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>
@ -233,7 +232,6 @@
</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>
@ -279,6 +277,10 @@
Filters="*.bmp"/>
<Folder
Name="Other Files"
Filters=""/>
Filters="">
<F N="../scripts/tests/config.lua"/>
<F N="../scripts/runtests.lua"/>
<F N="../scripts/tests/settings.lua"/>
</Folder>
</Files>
</Project>