forked from github/server
trying to make tests not throw out so many ERROR log mesages, commenting on some of them.
This commit is contained in:
parent
729c4ceea1
commit
9bf1059d8a
6 changed files with 37 additions and 19 deletions
|
@ -640,9 +640,32 @@ int check_param(const struct param *p, const char *key, const char *searchvalue)
|
|||
return result;
|
||||
}
|
||||
|
||||
const char * relpath(char *buf, size_t sz, const char *path) {
|
||||
strlcpy(buf, basepath(), sz);
|
||||
strlcat(buf, path, sz);
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -652,7 +675,7 @@ const char *datapath(void)
|
|||
static char zText[MAX_PATH]; // FIXME: static return value
|
||||
if (g_datadir)
|
||||
return g_datadir;
|
||||
return relpath(zText, sizeof(zText), "/data");
|
||||
return relpath(zText, sizeof(zText), "data");
|
||||
}
|
||||
|
||||
void set_datapath(const char *path)
|
||||
|
@ -666,7 +689,7 @@ const char *reportpath(void)
|
|||
static char zText[MAX_PATH]; // FIXME: static return value
|
||||
if (g_reportdir)
|
||||
return g_reportdir;
|
||||
return relpath(zText, sizeof(zText), "/reports");
|
||||
return relpath(zText, sizeof(zText), "reports");
|
||||
}
|
||||
|
||||
void set_reportpath(const char *path)
|
||||
|
@ -674,19 +697,6 @@ void set_reportpath(const char *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)
|
||||
{
|
||||
const char *str = get_param(p, key);
|
||||
|
|
|
@ -32,6 +32,7 @@ static void test_readwrite_unit(CuTest * tc)
|
|||
struct region *r;
|
||||
struct faction *f;
|
||||
int fno;
|
||||
/* FIXME: at some point during this test, errno is set to 17 (File exists), why? */
|
||||
|
||||
test_cleanup();
|
||||
r = test_create_region(0, 0, 0);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <quicklist.h>
|
||||
#include <kernel/spell.h>
|
||||
#include <util/log.h>
|
||||
|
||||
#include <CuTest.h>
|
||||
#include <tests.h>
|
||||
|
@ -24,6 +25,7 @@ static void test_create_a_spell(CuTest * tc)
|
|||
static void test_create_duplicate_spell(CuTest * tc)
|
||||
{
|
||||
spell *sp;
|
||||
/* FIXME: this test emits ERROR messages (duplicate spells), inject a logger to verify that */
|
||||
|
||||
test_cleanup();
|
||||
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)
|
||||
{
|
||||
spell *sp;
|
||||
/* FIXME: this test emits ERROR messages (duplicate spells), inject a logger to verify that */
|
||||
|
||||
test_cleanup();
|
||||
CuAssertPtrEquals(tc, 0, find_spellbyid(42));
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "magic.h"
|
||||
|
||||
#include <kernel/config.h>
|
||||
#include <kernel/faction.h>
|
||||
#include <kernel/order.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->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");
|
||||
CuAssertStrEquals(tc, "Feuerball", spell_name(sp, lang));
|
||||
set_level(u, SK_MAGIC, 10);
|
||||
|
|
|
@ -253,6 +253,7 @@ static void test_write_unit(CuTest *tc) {
|
|||
race *rc;
|
||||
struct locale *lang;
|
||||
char buffer[1024];
|
||||
/* FIXME: test emits ERROR: no translation for combat status status_aggressive in locale de */
|
||||
|
||||
test_cleanup();
|
||||
rc = rc_get_or_create("human");
|
||||
|
|
|
@ -108,7 +108,7 @@ void test_cleanup(void)
|
|||
if (errno) {
|
||||
int error = errno;
|
||||
errno = 0;
|
||||
log_error("errno: %d", error);
|
||||
log_error("errno: %d (%s)", error, strerror(error));
|
||||
}
|
||||
|
||||
random_source_reset();
|
||||
|
|
Loading…
Reference in a new issue