Merge branch 'lua-test-framework' of https://github.com/badgerman/eressea into badgerman-lua-test-framework

Conflicts:
	src/kernel/region.c
	src/util/log.h
This commit is contained in:
Enno Rehling 2015-05-17 17:39:10 +02:00
commit 177d1c701f
5 changed files with 33 additions and 4 deletions

View File

@ -6,5 +6,5 @@ rules=''
if config.rules then if config.rules then
rules = config.rules .. '/' rules = config.rules .. '/'
end end
read_xml(confdir .. rules .. 'config.xml', confdir .. rules .. 'catalog.xml') assert(0 == read_xml(confdir .. rules .. 'config.xml', confdir .. rules .. 'catalog.xml'), "could not load XML data, did you compile with LIBXML2 ?")
eressea.config.read(rules .. 'config.json', confdir) assert(0 == eressea.config.read(rules .. 'config.json', confdir), "could not read JSON data")

View File

@ -94,7 +94,7 @@ TOLUA_PKG(game);
int log_lua_error(lua_State * L) int log_lua_error(lua_State * L)
{ {
const char *error = lua_tostring(L, -1); const char *error = lua_tostring(L, -1);
log_error("LUA call failed.\n%s\n", error); log_fatal("LUA call failed.\n%s\n", error);
lua_pop(L, 1); lua_pop(L, 1);
return 1; return 1;
} }

View File

@ -780,7 +780,7 @@ CuSuite *get_laws_suite(void)
SUITE_ADD_TEST(suite, test_force_leave_buildings); SUITE_ADD_TEST(suite, test_force_leave_buildings);
SUITE_ADD_TEST(suite, test_force_leave_ships); SUITE_ADD_TEST(suite, test_force_leave_ships);
SUITE_ADD_TEST(suite, test_force_leave_ships_on_ocean); SUITE_ADD_TEST(suite, test_force_leave_ships_on_ocean);
SUITE_ADD_TEST(suite, test_peasant_luck_effect); DISABLE_TEST(suite, test_peasant_luck_effect);
SUITE_ADD_TEST(suite, test_luck_message); SUITE_ADD_TEST(suite, test_luck_message);
return suite; return suite;

View File

@ -264,6 +264,34 @@ void log_error(const char *format, ...)
} }
} }
void log_fatal(const char *format, ...)
{
const char * prefix = "ERROR";
const int mask = LOG_CPERROR;
/* write to the logfile, always */
if (logfile && (log_flags & mask)) {
va_list args;
va_start(args, format);
_log_writeln(logfile, 0, prefix, format, args);
va_end(args);
}
/* write to stderr, if that's not the logfile already */
if (logfile != stderr) {
int dupe = check_dupe(format, prefix);
if (!dupe) {
va_list args;
va_start(args, format);
_log_writeln(stderr, stdio_codepage, prefix, format, args);
va_end(args);
}
}
if (log_flags & LOG_FLUSH) {
log_flush();
}
}
void log_info(const char *format, ...) void log_info(const char *format, ...)
{ {
const char * prefix = "INFO"; const char * prefix = "INFO";

View File

@ -20,6 +20,7 @@ extern "C" {
extern void log_flush(void); extern void log_flush(void);
/* use macros above instead of these: */ /* use macros above instead of these: */
extern void log_fatal(const char *format, ...);
extern void log_error(const char *format, ...); extern void log_error(const char *format, ...);
extern void log_warning(const char *format, ...); extern void log_warning(const char *format, ...);
extern void log_debug(const char *format, ...); extern void log_debug(const char *format, ...);