コード例 #1
0
ファイル: text_reporter.c プロジェクト: thoni56/cgreen
static void text_reporter_finish_suite(TestReporter *reporter, const char *file, int line, uint32_t duration_in_milliseconds) {
    const char *name = get_current_from_breadcrumb((CgreenBreadcrumb *) reporter->breadcrumb);
    bool use_colors = reporter->options && ((TextReporterOptions *)reporter->options)->use_colours;
    TextMemo *memo = (TextMemo *)reporter->memo;
    
    reporter_finish_suite(reporter, file, line, duration_in_milliseconds);

    if (have_quiet_mode(reporter)) {
        memo->printer(".");
        if (get_breadcrumb_depth((CgreenBreadcrumb *) reporter->breadcrumb) == 0)
            memo->printer("\n");
    } else {
        char buf[1000];
        sprintf(buf, "Completed \"%s\": ", name);
        if (reporter->passes)
            strcat(buf, format_passes(reporter->passes, use_colors));
        if (reporter->skips) {
            insert_comma(buf);
            strcat(buf, format_skips(reporter->skips, use_colors));
        }
        if (reporter->failures) {
            insert_comma(buf);
            strcat(buf, format_failures(reporter->failures, use_colors));
        }
        if (reporter->exceptions) {
            insert_comma(buf);
            strcat(buf, format_exceptions(reporter->exceptions, use_colors));
        }
        memo->printer("%s in %dms.\n", buf, duration_in_milliseconds);
    }
}
コード例 #2
0
ファイル: text_reporter.c プロジェクト: thoni56/cgreen
static void show_breadcrumb(const char *name, void *memo_ptr) {
    TextMemo *memo = (TextMemo *)memo_ptr;
    if (memo->depth > 1) {
        memo->printer("-> ");
    }
    if (memo->depth > 0) {
        memo->printer("%s ", name);
    }
    memo->depth++;
}
コード例 #3
0
static void show_fail(TestReporter *reporter, const char *file, int line,
		const char *message, va_list arguments) {
    char buffer[1000];
    TextMemo *memo = (TextMemo *)reporter->memo;
    memo->printer("%s:%d: ", file, line);
    memo->printer("Failure: ");
    memo->depth = 0;
    walk_breadcrumb((CgreenBreadcrumb *) reporter->breadcrumb, &show_breadcrumb, memo);
    memo->printer("\n\t");
    vsprintf(buffer, (message == NULL ? "<FATAL: NULL for failure message>" : message), arguments);
    memo->printer(buffer);
    memo->printer("\n");
    memo->printer("\n");
    fflush(NULL);
}
コード例 #4
0
ファイル: text_reporter.c プロジェクト: thoni56/cgreen
static void show_incomplete(TestReporter *reporter, const char *file, int line,
		const char *message, va_list arguments) {
    char buffer[1000];
    TextMemo *memo = (TextMemo *)reporter->memo;
    
	memo->printer("%s:%d: ", file, line);
	memo->printer("Exception: ");

    memo->depth = 0;
	walk_breadcrumb((CgreenBreadcrumb *) reporter->breadcrumb, &show_breadcrumb,
                    memo);

	memo->printer("\n\t");
	vsprintf(buffer, message ? message: "Test terminated unexpectedly, likely from a non-standard exception or Posix signal", arguments);
    memo->printer(buffer);
	memo->printer("\n");
	memo->printer("\n");
    fflush(NULL);
}
コード例 #5
0
ファイル: text_reporter.c プロジェクト: thoni56/cgreen
static void show_fail(TestReporter *reporter, const char *file, int line,
		const char *message, va_list arguments) {
    char buffer[1000];
    TextMemo *memo = (TextMemo *)reporter->memo;
    memo->printer("%s:%d: ", file, line);
    memo->printer("Failure: ");
    memo->depth = 0;
    walk_breadcrumb((CgreenBreadcrumb *) reporter->breadcrumb, &show_breadcrumb, memo);
    memo->printer("\n\t");
    // Simplify *printf statements for more robust cross-platform logging
    if (message == NULL) {
        vsprintf(buffer, "<FATAL: NULL for failure message>", arguments);
    } else {
        vsprintf(buffer, message, arguments);
    }
    memo->printer("%s", buffer);
    memo->printer("\n");
    memo->printer("\n");
    fflush(NULL);
}
コード例 #6
0
ファイル: text_reporter.c プロジェクト: thoni56/cgreen
static void text_reporter_start_suite(TestReporter *reporter, const char *name,
		const int number_of_tests) {
    TextMemo *memo = (TextMemo *)reporter->memo;
    
    reporter_start_test(reporter, name);
    if (get_breadcrumb_depth((CgreenBreadcrumb *) reporter->breadcrumb) == 1) {
        memo->printer("Running \"%s\" (%d tests)%s",
                      get_current_from_breadcrumb((CgreenBreadcrumb *) reporter->breadcrumb),
                      number_of_tests,
                      have_quiet_mode(reporter)?":":"...\n");
        fflush(stdout);
    }
}