• R/O
  • SSH
  • HTTPS

cstl: Commit


Commit MetaInfo

Revision408 (tree)
Time2010-10-06 23:07:32
Authorkatono

Log Message

setup/teardownのエラーを表示。

Change Summary

Incremental Difference

--- branches/try-vfunc/unittest/UnitTest.c (revision 407)
+++ branches/try-vfunc/unittest/UnitTest.c (revision 408)
@@ -99,26 +99,35 @@
9999 size_t j;
100100 for (i = 0; suites[i].name != 0; i++) {
101101 TestSuite *suite = &suites[i];
102- PRINTF1("Suite: %s\n", suite->name);
102+ PRINTF0("================================\n");
103+ PRINTF1("* %s\n", suite->name);
103104 if (suite->setup_error) {
105+ PRINTF2("%s: SETUP ERROR[%d]\n", suite->name, suite->setup_error);
106+ PRINTF0("\n");
107+ continue;
104108 }
105- if (suite->teardown_error) {
106- }
107109 for (j = 0; suite->test_cases[j].name != 0; j++) {
108110 TestCase *tc = &suite->test_cases[j];
109- if (tc->setup_error || tc->teardown_error) {
111+ PRINTF0(".");
112+ if (tc->setup_error) {
110113 PRINTF0("E");
111- } else if (tc->result.num_asserts_failed == 0) {
112- PRINTF0(".");
113- } else {
114+ }
115+ if (tc->result.num_asserts_failed > 0) {
114116 PRINTF0("F");
115117 }
118+ if (tc->teardown_error) {
119+ PRINTF0("E");
120+ }
116121 }
117122 PRINTF0("\n");
118- if (suite->result.num_tests_failed == 0) {
123+ if (suite->result.num_tests_failed == 0 &&
124+ suite->result.case_result.num_errors_setup == 0 &&
125+ suite->result.case_result.num_errors_teardown == 0) {
119126 PRINTF1("OK (%d Tests)\n", suite->result.num_tests_ran);
120127 } else {
121- PRINTF2("NG (%d Tests, %d Failures)\n", suite->result.num_tests_ran, suite->result.num_tests_failed);
128+ PRINTF2("NG (%d Tests, %d Failures, %d Errors)\n",
129+ suite->result.num_tests_ran, suite->result.num_tests_failed,
130+ suite->result.case_result.num_errors_setup + suite->result.case_result.num_errors_teardown);
122131 for (j = 0; suite->test_cases[j].name != 0; j++) {
123132 TestCase *tc = &suite->test_cases[j];
124133 TestAssertion *pos;
@@ -127,34 +136,28 @@
127136 for (pos = LIST_BEGIN(list); pos != LIST_END(list); pos = pos->next) {
128137 if (!pos->passed_flag) {
129138 if (!name_printed) {
130- PRINTF1("\nTest: %s\n", tc->name);
139+ PRINTF1("\n ** %s\n", tc->name);
131140 name_printed = 1;
132141 }
133142 PRINTF3(" %s(%d) %s\n", pos->file, pos->line, pos->expr);
134143 }
135144 }
145+ if (tc->setup_error) {
146+ PRINTF1("\n ** %s\n", tc->name);
147+ PRINTF1(" SETUP ERROR[%d]\n", tc->setup_error);
148+ } else if (tc->teardown_error) {
149+ if (!name_printed) {
150+ PRINTF1("\n ** %s\n", tc->name);
151+ }
152+ PRINTF1(" TEARDOWN ERROR[%d]\n", tc->teardown_error);
153+ }
136154 }
137155 }
156+ if (suite->teardown_error) {
157+ PRINTF0("\n");
158+ PRINTF2("%s: TEARDOWN ERROR[%d]\n", suite->name, suite->teardown_error);
159+ }
138160 PRINTF0("\n");
139-
140-/* PRINTF1("Test: %s\n", tc->name);*/
141-/* for (pos = LIST_BEGIN(list); pos != LIST_END(list); pos = pos->next) {*/
142-/* if (!pos->passed_flag) {*/
143-/* PRINTF3(" %s(%d) %s\n", pos->file, pos->line, pos->expr);*/
144-/* }*/
145-/* }*/
146-/* PRINTF0("\n");*/
147-/* if (tc->result.num_asserts_failed == 0) {*/
148-/* PRINTF1("OK (%d Tests)\n", tc->result.num_asserts_ran);*/
149-/* } else {*/
150-/* PRINTF2("NG (%d Failures / %d Tests)\n", tc->result.num_asserts_failed, tc->result.num_asserts_ran);*/
151-/* for (pos = LIST_BEGIN(list); pos != LIST_END(list); pos = pos->next) {*/
152-/* if (!pos->passed_flag) {*/
153-/* PRINTF3(" %s(%d) %s\n", pos->file, pos->line, pos->expr);*/
154-/* }*/
155-/* }*/
156-/* }*/
157-/* PRINTF0("\n");*/
158161 }
159162 }
160163
@@ -201,7 +204,7 @@
201204 }
202205 }
203206 suites_ran = i;
204- print_result();
207+/* print_result();*/
205208 get_result(suites);
206209 cleanup(suites);
207210 }
@@ -229,7 +232,7 @@
229232 }
230233 }
231234 suites_ran = 1;
232- print_result();
235+/* print_result();*/
233236 get_result(suites);
234237 cleanup(suites);
235238 }
@@ -257,7 +260,7 @@
257260 }
258261 }
259262 suites_ran = 1;
260- print_result();
263+/* print_result();*/
261264 get_result(suites);
262265 cleanup(suites);
263266 }
@@ -457,8 +460,8 @@
457460
458461 void unittest_run_all(TestSuite *suites)
459462 {
460- PRINTF0("****************** Unit Test ******************\n");
461- PRINTF0("\n");
463+/* PRINTF0("****************** Unit Test ******************\n");*/
464+/* PRINTF0("\n");*/
462465 init(suites);
463466 run_all(suites);
464467 }
--- branches/try-vfunc/unittest/TestSuite.c (revision 407)
+++ branches/try-vfunc/unittest/TestSuite.c (revision 408)
@@ -56,11 +56,11 @@
5656 {
5757 size_t i;
5858 *ncases = *ncases_failed = *nasserts = *nasserts_failed = 0;
59- PRINTF1("Suite: %s\n", self->name);
59+/* PRINTF1("Suite: %s\n", self->name);*/
6060 self->setup_error = TestSuite_setup(self);
6161 if (self->setup_error) {
62- PRINTF1(" SETUP ERROR[%d]\n", self->setup_error);
63- PRINTF0("\n");
62+/* PRINTF1(" SETUP ERROR[%d]\n", self->setup_error);*/
63+/* PRINTF0("\n");*/
6464 self->result.num_errors_setup++;
6565 return SETUP_NG;
6666 }
@@ -87,12 +87,12 @@
8787 (*ncases) += i;
8888 self->teardown_error = TestSuite_teardown(self);
8989 if (self->teardown_error) {
90- PRINTF1(" TEARDOWN ERROR[%d]\n", self->teardown_error);
91- PRINTF0("\n");
90+/* PRINTF1(" TEARDOWN ERROR[%d]\n", self->teardown_error);*/
91+/* PRINTF0("\n");*/
9292 self->result.num_errors_teardown++;
9393 return TEARDOWN_NG;
9494 }
95- PRINTF0("\n");
95+/* PRINTF0("\n");*/
9696 return SUITE_OK;
9797 }
9898
@@ -101,11 +101,11 @@
101101 {
102102 TestCaseResult case_result;
103103 *ncases = *ncases_failed = *nasserts = *nasserts_failed = 0;
104- PRINTF1("Suite: %s\n", self->name);
104+/* PRINTF1("Suite: %s\n", self->name);*/
105105 self->setup_error = TestSuite_setup(self);
106106 if (self->setup_error) {
107- PRINTF1(" SETUP ERROR[%d]\n", self->setup_error);
108- PRINTF0("\n");
107+/* PRINTF1(" SETUP ERROR[%d]\n", self->setup_error);*/
108+/* PRINTF0("\n");*/
109109 self->result.num_errors_setup++;
110110 return SETUP_NG;
111111 }
@@ -126,12 +126,12 @@
126126 *ncases = 1;
127127 self->teardown_error = TestSuite_teardown(self);
128128 if (self->teardown_error) {
129- PRINTF1(" TEARDOWN ERROR[%d]\n", self->teardown_error);
130- PRINTF0("\n");
129+/* PRINTF1(" TEARDOWN ERROR[%d]\n", self->teardown_error);*/
130+/* PRINTF0("\n");*/
131131 self->result.num_errors_teardown++;
132132 return TEARDOWN_NG;
133133 }
134- PRINTF0("\n");
134+/* PRINTF0("\n");*/
135135 return SUITE_OK;
136136 }
137137
--- branches/try-vfunc/unittest/TestCase.c (revision 407)
+++ branches/try-vfunc/unittest/TestCase.c (revision 408)
@@ -62,10 +62,10 @@
6262 current_case = self;
6363 *nasserts = 0;
6464 *nasserts_failed = 0;
65- PRINTF1(" Test: %s ... ", self->name);
65+/* PRINTF1(" Test: %s ... ", self->name);*/
6666 self->setup_error = TestCase_setup(self);
6767 if (self->setup_error) {
68- PRINTF1("SETUP ERROR[%d]\n", self->setup_error);
68+/* PRINTF1("SETUP ERROR[%d]\n", self->setup_error);*/
6969 self->result.num_errors_setup++;
7070 return;
7171 }
@@ -81,18 +81,18 @@
8181 (*nasserts_failed)++;
8282 if (!failed_flag) {
8383 failed_flag = 1;
84- PRINTF0("FAILED\n");
84+/* PRINTF0("FAILED\n");*/
8585 }
86- PRINTF4(" %d. %s(%d) %s\n", n, pos->file, pos->line, pos->expr);
86+/* PRINTF4(" %d. %s(%d) %s\n", n, pos->file, pos->line, pos->expr);*/
8787 n++;
8888 }
8989 }
9090 if (!failed_flag) {
91- PRINTF0("passed\n");
91+/* PRINTF0("passed\n");*/
9292 }
9393 self->teardown_error = TestCase_teardown(self);
9494 if (self->teardown_error) {
95- PRINTF1(" TEARDOWN ERROR[%d]\n", self->teardown_error);
95+/* PRINTF1(" TEARDOWN ERROR[%d]\n", self->teardown_error);*/
9696 self->result.num_errors_teardown++;
9797 return;
9898 }
@@ -119,7 +119,7 @@
119119 {
120120 TestAssertion *self = (TestAssertion *) MALLOC(sizeof(TestAssertion));
121121 if (!self) {
122- PRINTF0("malloc failed!!\n");
122+/* PRINTF0("malloc failed!!\n");*/
123123 return 0;
124124 }
125125 self->passed_flag = passed_flag;
Show on old repository browser