#include #include #include #include "xml_reporter.h" static void indent(TestReporter *reporter) { int depth = get_breadcrumb_depth((CgreenBreadcrumb *)reporter->breadcrumb); while (depth-- > 0) { printf("\t"); } } static void xml_reporter_start_suite(TestReporter *reporter, const char *name, int count) { if (get_breadcrumb_depth((CgreenBreadcrumb *)reporter->breadcrumb) == 0) { printf("\n"); } indent(reporter); printf("\n", name); reporter_start_suite(reporter, name, count); } static void xml_reporter_start_test(TestReporter *reporter, const char *name) { indent(reporter); printf("\n", name); reporter_start_test(reporter, name); } static void xml_show_fail(TestReporter *reporter, const char *file, int line, const char *message, va_list arguments) { indent(reporter); printf("\n"); indent(reporter); printf("\t"); vprintf(message, arguments); printf("\n"); indent(reporter); printf("\t\n", file, line); indent(reporter); printf("\n"); } static void xml_show_incomplete(TestReporter *reporter, const char *file, int line, const char *message, va_list arguments) { indent(reporter); printf("\n"); indent(reporter); printf("\tFailed to complete\n"); indent(reporter); printf("\n"); } static void xml_reporter_finish_test(TestReporter *reporter, const char *filename, int line, const char *message) { reporter_finish_test(reporter, filename, line, message); indent(reporter); printf("\n"); } static void xml_reporter_finish_suite(TestReporter *reporter, const char *filename, int line) { reporter_finish_suite(reporter, filename, line); indent(reporter); printf("\n"); } TestReporter *create_xml_reporter() { TestReporter *reporter = create_reporter(); reporter->start_suite = &xml_reporter_start_suite; reporter->start_test = &xml_reporter_start_test; reporter->show_fail = &xml_show_fail; reporter->show_incomplete = &xml_show_incomplete; reporter->finish_test = &xml_reporter_finish_test; reporter->finish_suite = &xml_reporter_finish_suite; return reporter; }