summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/ctest.cc
diff options
context:
space:
mode:
authorDarshan Shaligram <dshaligram@users.sourceforge.net>2009-10-18 18:09:22 +0530
committerDarshan Shaligram <dshaligram@users.sourceforge.net>2009-10-18 18:17:47 +0530
commit20499e4d29a0af3143ca2aaa163390d97c04c258 (patch)
tree4506fe40fa455e02bc8ba0dbcf1175e675e5a374 /crawl-ref/source/ctest.cc
parentebf9ea59c9613529a05e9e8a1b74a5d2d388195b (diff)
downloadcrawl-ref-20499e4d29a0af3143ca2aaa163390d97c04c258.tar.gz
crawl-ref-20499e4d29a0af3143ca2aaa163390d97c04c258.zip
Add test for monster placement.
Adds test/monplace.lua to test placing monsters using the Lua direct monster creation binding (does not exercise all the map code). Allow choosing what tests to run with "crawl -test test1,test2".
Diffstat (limited to 'crawl-ref/source/ctest.cc')
-rw-r--r--crawl-ref/source/ctest.cc18
1 files changed, 18 insertions, 0 deletions
diff --git a/crawl-ref/source/ctest.cc b/crawl-ref/source/ctest.cc
index c0c7f743c6..daca476c7d 100644
--- a/crawl-ref/source/ctest.cc
+++ b/crawl-ref/source/ctest.cc
@@ -20,6 +20,7 @@
#include "files.h"
#include "luadgn.h"
#include "maps.h"
+#include "state.h"
#include "stuff.h"
#include <algorithm>
@@ -73,8 +74,25 @@ namespace crawl_tests
luaL_openlib(dlua, "crawl", crawl_test_lib, 0);
}
+ bool is_test_selected(const std::string &testname)
+ {
+ if (crawl_state.tests_selected.empty())
+ return (true);
+ for (int i = 0, size = crawl_state.tests_selected.size();
+ i < size; ++i)
+ {
+ const std::string &phrase(crawl_state.tests_selected[i]);
+ if (testname.find(phrase) != std::string::npos)
+ return (true);
+ }
+ return (false);
+ }
+
void run_test(const std::string &file)
{
+ if (!is_test_selected(file))
+ return;
+
++ntests;
const std::string path(catpath(test_dir, file));
dlua.execfile(path.c_str(), true, false);