From: bones_was_here Date: Wed, 20 Sep 2023 03:50:49 +0000 (+1000) Subject: Improve visibility of warnings, related cleanup and fixes X-Git-Url: http://git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=commitdiff_plain;h=bae3de16e76ed9b25933db14b165ec86aa8f1608 Improve visibility of warnings, related cleanup and fixes The reason for strcat1n is now fixed properly by darkplaces@b0abeba2 and a986d478 Double printing of backtraces with `developer 1` is fixed. Failure to print fatal messages with `developer 1` is fixed. Made the pipeline's `sv_cmd runtest` accept results prefixed with (eg) "[::SVQC::INFO]" (as long as they end with exactly "All tests OK"), also fixed incorrect hash being printed in green and fixed "PASS: unbound variable" error. --- diff --git a/qcsrc/lib/log.qh b/qcsrc/lib/log.qh index f33202f93..fb53baaca 100644 --- a/qcsrc/lib/log.qh +++ b/qcsrc/lib/log.qh @@ -34,12 +34,6 @@ void print_assertfailed_fatal(string expr); #define ASSERT_LESS(name, var, const) noref int name[(const - var + 1)]; -#if defined(MENUQC) -string(string, string...) strcat1n = #53; -#else -string(string, string...) strcat1n = #115; -#endif - // would be nice if __FUNC__ could be concatenated at compile time #if 0 // less work, bigger binary @@ -48,51 +42,48 @@ string(string, string...) strcat1n = #115; #define __SOURCELOC__ (sprintf("^7%s^9(^9%s^7:^9%s^7)", __FUNC__, __FILE__, STR(__LINE__))) #endif -#define _LOG_HEADER(level) "^9[::^7"PROGNAME"^9::"level"^9] ", __SOURCELOC__ -#define _LOG(f, level, s) \ +#define _LOG_PREFIX(level) strcat("^9[::^7", PROGNAME, "^9::", level, "^9] ") +#define _LOG_HEADER(level) strcat(_LOG_PREFIX(level), __SOURCELOC__, "\n") +#define _LOG(func_header, level, func_msg, s) \ MACRO_BEGIN \ - if (autocvar_developer > 0) f(strcat1n(_LOG_HEADER(level), "\n")); \ - f(strcat1n("^7", s, "\n")); \ + func_header(autocvar_developer > 0 ? _LOG_HEADER(level) : _LOG_PREFIX(level)); \ + func_msg(strcat("^7", s, "\n")); \ MACRO_END -#define LOG_FATAL(...) _LOG_FATAL(strcat1n(__VA_ARGS__)) +#define LOG_FATAL(...) _LOG_FATAL(strcat(__VA_ARGS__)) #define LOG_FATALF(...) _LOG_FATAL(sprintf(__VA_ARGS__)) -#define _LOG_FATAL(s) _LOG(error, "^1FATAL", s) +#define _LOG_FATAL(s) _LOG(print, "^1FATAL", error, s) -#define LOG_SEVERE(...) _LOG_SEVERE(strcat1n(__VA_ARGS__)) +#define LOG_SEVERE(...) _LOG_SEVERE(strcat(__VA_ARGS__)) #define LOG_SEVEREF(...) _LOG_SEVERE(sprintf(__VA_ARGS__)) -#define _LOG_SEVERE(s) _LOG(backtrace, "^1SEVERE", s) +#define _LOG_SEVERE(s) _LOG(print, "^1SEVERE", backtrace, s) -#define LOG_WARN(...) _LOG_WARN(strcat1n(__VA_ARGS__)) +#define LOG_WARN(...) _LOG_WARN(strcat(__VA_ARGS__)) #define LOG_WARNF(...) _LOG_WARN(sprintf(__VA_ARGS__)) -#define _LOG_WARN(s) _LOG(print, "^3WARNING", s) +#define _LOG_WARN(s) _LOG(print, "^3WARNING", print, s) -#define LOG_INFO(...) _LOG_INFO(strcat1n(__VA_ARGS__)) +#define LOG_INFO(...) _LOG_INFO(strcat(__VA_ARGS__)) #define LOG_INFOF(...) _LOG_INFO(sprintf(__VA_ARGS__)) #define _LOG_INFO(s) \ MACRO_BEGIN \ - if (autocvar_developer > 1) dprint(strcat1n(_LOG_HEADER("^5INFO"), "\n")); \ + if (autocvar_developer > 1) print(_LOG_HEADER("^5INFO")); \ + else if (autocvar_developer > 0) print(_LOG_PREFIX("^5INFO")); \ string __s = s; \ print("^7", __s); \ /* TODO: unconditionally add a newline when possible */ \ if (str2chr(__s, strlen(__s) - 1) != '\n') { print("\n"); } \ MACRO_END -#define LOG_TRACE(...) _LOG_TRACE(strcat1n(__VA_ARGS__)) +#define LOG_TRACE(...) _LOG_TRACE(strcat(__VA_ARGS__)) #define LOG_TRACEF(...) _LOG_TRACE(sprintf(__VA_ARGS__)) -#define _LOG_TRACE(s) _LOG(dprint, "^6TRACE", s) +#define _LOG_TRACE(s) _LOG(dprint, "^6TRACE", dprint, s) -#define LOG_DEBUG(...) _LOG_DEBUG(strcat1n(__VA_ARGS__)) +#define LOG_DEBUG(...) _LOG_DEBUG(strcat(__VA_ARGS__)) #define LOG_DEBUGF(...) _LOG_DEBUG(sprintf(__VA_ARGS__)) -#define _LOG_DEBUG(s) _LOG(dprint2, "^2DEBUG", s) - -#define dprint2(msg) \ - MACRO_BEGIN \ - if (autocvar_developer > 1) dprint(msg); \ - MACRO_END +#define _LOG_DEBUG(s) if (autocvar_developer > 1) _LOG(dprint, "^2DEBUG", dprint, s) // same as LOG_INFO but without any debug information that bloats console output and compiled program files -#define LOG_HELP(...) _LOG_HELP(strcat1n(__VA_ARGS__)) +#define LOG_HELP(...) _LOG_HELP(strcat(__VA_ARGS__)) #define LOG_HELPF(...) _LOG_HELP(sprintf(__VA_ARGS__)) #define _LOG_HELP(s) \ MACRO_BEGIN \ diff --git a/qcsrc/tools/sv_game-hashtest.sh b/qcsrc/tools/sv_game-hashtest.sh index f3f0eb233..431a6f7c1 100755 --- a/qcsrc/tools/sv_game-hashtest.sh +++ b/qcsrc/tools/sv_game-hashtest.sh @@ -185,12 +185,13 @@ mkdir -p data/maps createdtoday "data/maps/_init.bsp" \ || wget -nv -O data/maps/_init.bsp https://gitlab.com/xonotic/xonotic-maps.pk3dir/raw/master/maps/_init/_init.bsp +PASS=0 while read -r LINE do printf "%s\n" "$LINE" - [ "$LINE" = "All tests OK" ] && PASS=1 + printf "%s\n" "$LINE" | grep -q ".*All tests OK$" && PASS=1 done < <(${ENGINE} +developer 1 +map _init +sv_cmd runtest +wait +quit) -test "$PASS" = "1" || { printf 'sv_cmd runtest failed!'; exit 1; } +test "$PASS" = "1" || { printf "\033[1;31m%s\033[0m\n" "sv_cmd runtest failed!"; exit 1; } ${ENGINE} +map _init +sv_cmd dumpnotifs +wait +quit diff notifications.cfg data/data/notifications_dump.cfg || @@ -228,8 +229,8 @@ then # green ok print printf "\033[32m%s\033[0m\n" "hashes match" exit 0 else # red error print - printf "\033[32m%s\033[0m\n" "expected: $EXPECT" - printf "\033[32m%s\033[0m\n" " actual: $HASH" - printf "\033[31m%s\033[0m\n" "!!! ERROR: HASHES DO NOT MATCH !!!" + printf "\033[31m%s\033[0m\n" "expected: $EXPECT" + printf "\033[31m%s\033[0m\n" " actual: $HASH" + printf "\033[1;31m%s\033[0m\n" "!!! ERROR: HASHES DO NOT MATCH !!!" exit 1 fi