From 02790e461c69569891c6d21b8a5826bcf2c00f77 Mon Sep 17 00:00:00 2001 From: Snaipe Date: Mon, 23 Mar 2015 20:54:48 +0100 Subject: [PATCH] Fixed bad formatting with mutli-line assertion messages --- src/log/normal.c | 12 +++++++++++- src/log/tap.c | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/log/normal.c b/src/log/normal.c index 3652580..9399a8a 100644 --- a/src/log/normal.c +++ b/src/log/normal.c @@ -21,7 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#define _GNU_SOURCE #include +#include +#include #include "criterion/stats.h" #include "criterion/logging.h" #include "criterion/options.h" @@ -69,6 +72,9 @@ void normal_log_post_all(struct criterion_global_stats *stats) { void normal_log_assert(struct criterion_assert_stats *stats) { if (!stats->passed) { + char *dup = strdup(*stats->message ? stats->message : stats->condition), *saveptr = NULL; + char *line = strtok_r(dup, "\n", &saveptr); + criterion_important("[%s----%s] ", FG_BLUE, RESET); criterion_important("%s%s%s:%s%d%s: Assertion failed: %s\n", FG_BOLD, @@ -77,7 +83,11 @@ void normal_log_assert(struct criterion_assert_stats *stats) { FG_RED, stats->line, RESET, - *stats->message ? stats->message : stats->condition); + line); + + while ((line = strtok_r(NULL, "\n", &saveptr))) + criterion_important("[%s----%s] %s\n", FG_BLUE, RESET, line); + free(dup); } } diff --git a/src/log/tap.c b/src/log/tap.c index 1e823b2..ebbdda4 100644 --- a/src/log/tap.c +++ b/src/log/tap.c @@ -21,6 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#define _GNU_SOURCE #include #include #include