From 729c4ceea12d432f7a7a884d3f2eda4b46a54d18 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 28 Jan 2016 16:00:36 +0100 Subject: [PATCH] increase error-logging from unit tests. suppress some unrelated errors. --- src/kernel/messages.c | 2 +- src/laws.test.c | 2 ++ src/spy.test.c | 6 +++--- src/study.test.c | 3 ++- src/test_eressea.c | 2 +- src/tests.c | 15 +++++++++++++-- 6 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/kernel/messages.c b/src/kernel/messages.c index 779354498..330c2feeb 100644 --- a/src/kernel/messages.c +++ b/src/kernel/messages.c @@ -90,7 +90,7 @@ struct message *msg_feedback(const struct unit *u, struct order *ord, ord = u->thisorder; if (!mtype) { - log_error("trying to create message of unknown type \"%s\"\n", name); + log_warning("trying to create message of unknown type \"%s\"\n", name); if (!mt_find("missing_feedback")) { mt_register(mt_new_va("missing_feedback", "unit:unit", "region:region", "command:order", "name:string", 0)); } diff --git a/src/laws.test.c b/src/laws.test.c index 5d21250cd..5be4c7143 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -1229,6 +1229,8 @@ static void test_show_without_item(CuTest *tc) test_cleanup(); loc = get_or_create_locale("de"); + locale_setstring(loc, parameters[P_ANY], "ALLE"); + init_parameters(loc); r = test_create_region(0, 0, test_create_terrain("testregion", LAND_REGION)); f = test_create_faction(test_create_race("human")); diff --git a/src/spy.test.c b/src/spy.test.c index 00a1767d0..a4e2f1151 100644 --- a/src/spy.test.c +++ b/src/spy.test.c @@ -100,7 +100,7 @@ static void test_sabotage_self(CuTest *tc) { order *ord; setup_sabotage(); - r = test_create_region(0, 0, NULL); + r = findregion(0, 0); assert(r); u = test_create_unit(test_create_faction(NULL), r); assert(u && u->faction && u->region == r); @@ -122,7 +122,7 @@ static void test_sabotage_other_fail(CuTest *tc) { message *msg; setup_sabotage(); - r = test_create_region(0, 0, NULL); + r = findregion(0, 0); assert(r); u = test_create_unit(test_create_faction(NULL), r); u2 = test_create_unit(test_create_faction(NULL), r); @@ -151,7 +151,7 @@ static void test_sabotage_other_success(CuTest *tc) { order *ord; setup_sabotage(); - r = test_create_region(0, 0, NULL); + r = findregion(0, 0); assert(r); u = test_create_unit(test_create_faction(NULL), r); u2 = test_create_unit(test_create_faction(NULL), r); diff --git a/src/study.test.c b/src/study.test.c index 6b9d97787..bdbfb9a01 100644 --- a/src/study.test.c +++ b/src/study.test.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -29,7 +30,7 @@ static void setup_study(study_fixture *fix, skill_t sk) { test_cleanup(); config_set("study.random_progress", "0"); test_create_world(); - r = test_create_region(0, 0, 0); + r = findregion(0, 0); f = test_create_faction(0); lang = get_or_create_locale(locale_name(f->locale)); locale_setstring(lang, mkname("skill", skillnames[sk]), skillnames[sk]); diff --git a/src/test_eressea.c b/src/test_eressea.c index 1053306c6..9e5fba524 100644 --- a/src/test_eressea.c +++ b/src/test_eressea.c @@ -156,7 +156,7 @@ int RunAllTests(int argc, char *argv[]) } int main(int argc, char ** argv) { - log_stderr = 0; + log_stderr = LOG_CPERROR|LOG_FLUSH; ++argv; --argc; if (argc > 0 && strcmp("--list", argv[0]) == 0) { diff --git a/src/tests.c b/src/tests.c index 6fef425d0..425e01d43 100644 --- a/src/tests.c +++ b/src/tests.c @@ -45,14 +45,19 @@ struct race *test_create_race(const char *name) struct region *test_create_region(int x, int y, const terrain_type *terrain) { - region *r = new_region(x, y, NULL, 0); + region *r = findregion(x, y); + if (!r) { + r = new_region(x, y, NULL, 0); + } if (!terrain) { terrain_type *t = get_or_create_terrain("plain"); t->size = 1000; fset(t, LAND_REGION|CAVALRY_REGION|FOREST_REGION); terraform_region(r, t); - } else + } + else { terraform_region(r, terrain); + } rsettrees(r, 0, 0); rsettrees(r, 1, 0); rsettrees(r, 2, 0); @@ -255,6 +260,11 @@ void test_create_world(void) struct locale * loc; loc = get_or_create_locale("de"); + + locale_setstring(loc, parameters[P_SHIP], "SCHIFF"); + locale_setstring(loc, parameters[P_ANY], "ALLE"); + init_parameters(loc); + locale_setstring(loc, keyword(K_RESERVE), "RESERVIEREN"); locale_setstring(loc, "money", "SILBER"); init_resources(); @@ -270,6 +280,7 @@ void test_create_world(void) test_create_itemtype("iron"); test_create_itemtype("stone"); + t_plain = test_create_terrain("plain", LAND_REGION | FOREST_REGION | WALK_INTO | CAVALRY_REGION | SAIL_INTO | FLY_INTO); t_plain->size = 1000; t_plain->max_road = 100;