trying to make tests not throw out so many ERROR log mesages, commenting on some of them.

This commit is contained in:
Enno Rehling 2016-01-29 17:49:27 +01:00
parent 729c4ceea1
commit 9bf1059d8a
6 changed files with 37 additions and 19 deletions

View File

@ -640,9 +640,32 @@ int check_param(const struct param *p, const char *key, const char *searchvalue)
return result; return result;
} }
const char * relpath(char *buf, size_t sz, const char *path) { static const char *g_basedir;
strlcpy(buf, basepath(), sz); const char *basepath(void)
strlcat(buf, path, sz); {
if (g_basedir)
return g_basedir;
return ".";
}
void set_basepath(const char *path)
{
g_basedir = path;
}
static const char * relpath(char *buf, size_t sz, const char *path) {
if (g_basedir) {
strlcpy(buf, g_basedir, sz);
#ifdef WIN32
strlcat(buf, "\\", sz);
#else
strlcat(buf, "/", sz);
#endif
strlcat(buf, path, sz);
}
else {
strlcpy(buf, path, sz);
}
return buf; return buf;
} }
@ -652,7 +675,7 @@ const char *datapath(void)
static char zText[MAX_PATH]; // FIXME: static return value static char zText[MAX_PATH]; // FIXME: static return value
if (g_datadir) if (g_datadir)
return g_datadir; return g_datadir;
return relpath(zText, sizeof(zText), "/data"); return relpath(zText, sizeof(zText), "data");
} }
void set_datapath(const char *path) void set_datapath(const char *path)
@ -666,7 +689,7 @@ const char *reportpath(void)
static char zText[MAX_PATH]; // FIXME: static return value static char zText[MAX_PATH]; // FIXME: static return value
if (g_reportdir) if (g_reportdir)
return g_reportdir; return g_reportdir;
return relpath(zText, sizeof(zText), "/reports"); return relpath(zText, sizeof(zText), "reports");
} }
void set_reportpath(const char *path) void set_reportpath(const char *path)
@ -674,19 +697,6 @@ void set_reportpath(const char *path)
g_reportdir = path; g_reportdir = path;
} }
static const char *g_basedir;
const char *basepath(void)
{
if (g_basedir)
return g_basedir;
return ".";
}
void set_basepath(const char *path)
{
g_basedir = path;
}
double get_param_flt(const struct param *p, const char *key, double def) double get_param_flt(const struct param *p, const char *key, double def)
{ {
const char *str = get_param(p, key); const char *str = get_param(p, key);

View File

@ -32,6 +32,7 @@ static void test_readwrite_unit(CuTest * tc)
struct region *r; struct region *r;
struct faction *f; struct faction *f;
int fno; int fno;
/* FIXME: at some point during this test, errno is set to 17 (File exists), why? */
test_cleanup(); test_cleanup();
r = test_create_region(0, 0, 0); r = test_create_region(0, 0, 0);

View File

@ -2,6 +2,7 @@
#include <quicklist.h> #include <quicklist.h>
#include <kernel/spell.h> #include <kernel/spell.h>
#include <util/log.h>
#include <CuTest.h> #include <CuTest.h>
#include <tests.h> #include <tests.h>
@ -24,6 +25,7 @@ static void test_create_a_spell(CuTest * tc)
static void test_create_duplicate_spell(CuTest * tc) static void test_create_duplicate_spell(CuTest * tc)
{ {
spell *sp; spell *sp;
/* FIXME: this test emits ERROR messages (duplicate spells), inject a logger to verify that */
test_cleanup(); test_cleanup();
CuAssertPtrEquals(tc, 0, find_spell("testspell")); CuAssertPtrEquals(tc, 0, find_spell("testspell"));
@ -36,6 +38,7 @@ static void test_create_duplicate_spell(CuTest * tc)
static void test_create_spell_with_id(CuTest * tc) static void test_create_spell_with_id(CuTest * tc)
{ {
spell *sp; spell *sp;
/* FIXME: this test emits ERROR messages (duplicate spells), inject a logger to verify that */
test_cleanup(); test_cleanup();
CuAssertPtrEquals(tc, 0, find_spellbyid(42)); CuAssertPtrEquals(tc, 0, find_spellbyid(42));

View File

@ -2,6 +2,7 @@
#include "magic.h" #include "magic.h"
#include <kernel/config.h>
#include <kernel/faction.h> #include <kernel/faction.h>
#include <kernel/order.h> #include <kernel/order.h>
#include <kernel/item.h> #include <kernel/item.h>
@ -386,6 +387,8 @@ void test_multi_cast(CuTest *tc) {
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
u->faction->locale = lang = get_or_create_locale("de"); u->faction->locale = lang = get_or_create_locale("de");
locale_setstring(lang, parameters[P_ANY], "ALLE");
init_parameters(lang);
locale_setstring(lang, mkname("spell", sp->sname), "Feuerball"); locale_setstring(lang, mkname("spell", sp->sname), "Feuerball");
CuAssertStrEquals(tc, "Feuerball", spell_name(sp, lang)); CuAssertStrEquals(tc, "Feuerball", spell_name(sp, lang));
set_level(u, SK_MAGIC, 10); set_level(u, SK_MAGIC, 10);

View File

@ -253,6 +253,7 @@ static void test_write_unit(CuTest *tc) {
race *rc; race *rc;
struct locale *lang; struct locale *lang;
char buffer[1024]; char buffer[1024];
/* FIXME: test emits ERROR: no translation for combat status status_aggressive in locale de */
test_cleanup(); test_cleanup();
rc = rc_get_or_create("human"); rc = rc_get_or_create("human");

View File

@ -108,7 +108,7 @@ void test_cleanup(void)
if (errno) { if (errno) {
int error = errno; int error = errno;
errno = 0; errno = 0;
log_error("errno: %d", error); log_error("errno: %d (%s)", error, strerror(error));
} }
random_source_reset(); random_source_reset();