From 30c1b0e1ff525556beb38b2144ef6e82bc193de3 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 12 Jun 2014 17:41:03 -0700 Subject: [PATCH] new lua test framework, work in progress. --- s/cmake-init | 17 ++ s/runtests | 8 +- scripts/runtests.lua | 7 + scripts/tests/config.lua | 18 ++ scripts/tests/eressea.lua | 1 + scripts/tests/settings.lua | 13 + se/server.vpj | 3 + se/tests.vpj | 564 +++++++++++++++++++------------------ 8 files changed, 345 insertions(+), 286 deletions(-) create mode 100644 scripts/runtests.lua create mode 100644 scripts/tests/config.lua create mode 100644 scripts/tests/settings.lua diff --git a/s/cmake-init b/s/cmake-init index 1b2e9526b..454557354 100755 --- a/s/cmake-init +++ b/s/cmake-init @@ -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 - diff --git a/s/runtests b/s/runtests index c56619db1..247db2251 100755 --- a/s/runtests +++ b/s/runtests @@ -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 + diff --git a/scripts/runtests.lua b/scripts/runtests.lua new file mode 100644 index 000000000..109443411 --- /dev/null +++ b/scripts/runtests.lua @@ -0,0 +1,7 @@ +-- new tests 2014-06-11 + +require "lunit" +require "tests.settings" +require "tests.config" +lunit.main() + diff --git a/scripts/tests/config.lua b/scripts/tests/config.lua new file mode 100644 index 000000000..9460d8bdd --- /dev/null +++ b/scripts/tests/config.lua @@ -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 + diff --git a/scripts/tests/eressea.lua b/scripts/tests/eressea.lua index f33726886..76203227a 100644 --- a/scripts/tests/eressea.lua +++ b/scripts/tests/eressea.lua @@ -200,3 +200,4 @@ function test_snowman() end assert_equal(nil, u) end + diff --git a/scripts/tests/settings.lua b/scripts/tests/settings.lua new file mode 100644 index 000000000..a454a1152 --- /dev/null +++ b/scripts/tests/settings.lua @@ -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 diff --git a/se/server.vpj b/se/server.vpj index 1f795b4f9..aa3e0992c 100644 --- a/se/server.vpj +++ b/se/server.vpj @@ -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"> + @@ -272,6 +273,7 @@ + @@ -286,6 +288,7 @@ Name="Header Files" Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if"> + diff --git a/se/tests.vpj b/se/tests.vpj index b42bea9de..8ff7a974d 100644 --- a/se/tests.vpj +++ b/se/tests.vpj @@ -1,284 +1,286 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + Version="10.0" + VendorName="SlickEdit" + TemplateName="GNU C/C++" + WorkingDir="." + BuildSystem="vsbuild"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +