You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2013/02/24 18:25:57 UTC
[lucy-commits] [3/19] git commit: refs/heads/master - Move code to diagnose batch
run to TestBatch
Move code to diagnose batch run to TestBatch
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/4072c56f
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/4072c56f
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/4072c56f
Branch: refs/heads/master
Commit: 4072c56f1fcb2d216ae3fc4732f7a53f7f766055
Parents: e15e869
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sun Feb 17 11:57:47 2013 +0100
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sun Feb 17 11:57:47 2013 +0100
----------------------------------------------------------------------
core/Clownfish/Test/TestRunner.c | 31 +++++--------------------
core/Lucy/Test.c | 28 +++++++++++++++++++---
core/Lucy/Test.cfh | 5 +++-
core/Lucy/Test/Highlight/TestHeatMap.c | 2 +-
core/Lucy/Test/Highlight/TestHeatMap.cfh | 2 +-
5 files changed, 36 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy/blob/4072c56f/core/Clownfish/Test/TestRunner.c
----------------------------------------------------------------------
diff --git a/core/Clownfish/Test/TestRunner.c b/core/Clownfish/Test/TestRunner.c
index e76ef01..3bf399d 100644
--- a/core/Clownfish/Test/TestRunner.c
+++ b/core/Clownfish/Test/TestRunner.c
@@ -53,36 +53,17 @@ TestRunner_destroy(TestRunner *self) {
bool
TestRunner_run_batch(TestRunner *self, TestBatch *batch) {
- TestBatch_Plan(batch);
- TestBatch_Run(batch);
-
- int64_t num_planned = TestBatch_Get_Num_Planned(batch);
- int64_t num_tests = TestBatch_Get_Num_Tests(batch);
- int64_t num_failed = TestBatch_Get_Num_Failed(batch);
- bool failed = false;
-
- if (num_failed > 0) {
- failed = true;
- TestFormatter_batch_comment(self->formatter, "%d/%d tests failed.\n",
- num_failed, num_tests);
- }
- if (num_tests != num_planned) {
- failed = true;
- TestFormatter_batch_comment(self->formatter,
- "Bad plan: You planned %d tests but ran"
- " %d.\n",
- num_planned, num_tests);
- }
+ bool success = TestBatch_Run(batch);
- self->num_tests += num_tests;
- self->num_tests_failed += num_failed;
- self->num_batches += 1;
+ self->num_tests += TestBatch_Get_Num_Tests(batch);
+ self->num_tests_failed += TestBatch_Get_Num_Failed(batch);
+ self->num_batches += 1;
- if (failed) {
+ if (!success) {
self->num_batches_failed += 1;
}
- return !failed;
+ return success;
}
bool
http://git-wip-us.apache.org/repos/asf/lucy/blob/4072c56f/core/Lucy/Test.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test.c b/core/Lucy/Test.c
index 020e89d..ec219a7 100644
--- a/core/Lucy/Test.c
+++ b/core/Lucy/Test.c
@@ -50,9 +50,7 @@ Test_run_batch(CharBuf *class_name, TestFormatter *formatter) {
TestBatch *batch = (TestBatch*)VA_Fetch(batches, i);
if (CB_Equals(TestBatch_Get_Class_Name(batch), (Obj*)class_name)) {
- TestRunner *runner = TestRunner_new(formatter);
- bool result = TestRunner_Run_Batch(runner, batch);
- DECREF(runner);
+ bool result = TestBatch_Run(batch);
DECREF(batches);
return result;
}
@@ -119,8 +117,30 @@ TestBatch_plan(TestBatch *self) {
TestFormatter_Batch_Prologue(self->formatter, self);
}
-void
+bool
TestBatch_run(TestBatch *self) {
+ TestBatch_Plan(self);
+ TestBatch_Run_Tests(self);
+
+ bool failed = false;
+ if (self->num_failed > 0) {
+ failed = true;
+ TestFormatter_batch_comment(self->formatter, "%d/%d tests failed.\n",
+ self->num_failed, self->test_num);
+ }
+ if (self->test_num != self->num_tests) {
+ failed = true;
+ TestFormatter_batch_comment(self->formatter,
+ "Bad plan: You planned %d tests but ran"
+ " %d.\n",
+ self->num_tests, self->test_num);
+ }
+
+ return !failed;
+}
+
+void
+TestBatch_run_tests(TestBatch *self) {
}
int64_t
http://git-wip-us.apache.org/repos/asf/lucy/blob/4072c56f/core/Lucy/Test.cfh
----------------------------------------------------------------------
diff --git a/core/Lucy/Test.cfh b/core/Lucy/Test.cfh
index 609d8a0..776a8c4 100644
--- a/core/Lucy/Test.cfh
+++ b/core/Lucy/Test.cfh
@@ -46,9 +46,12 @@ class Lucy::Test::TestBatch inherits Clownfish::Obj {
void
Plan(TestBatch *self);
+ bool
+ Run(TestBatch *self);
+
/* Will made be abstract later. */
void
- Run(TestBatch *self);
+ Run_Tests(TestBatch *self);
int64_t
Get_Num_Planned(TestBatch *self);
http://git-wip-us.apache.org/repos/asf/lucy/blob/4072c56f/core/Lucy/Test/Highlight/TestHeatMap.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Highlight/TestHeatMap.c b/core/Lucy/Test/Highlight/TestHeatMap.c
index 081d8c7..0f9d96c 100644
--- a/core/Lucy/Test/Highlight/TestHeatMap.c
+++ b/core/Lucy/Test/Highlight/TestHeatMap.c
@@ -171,7 +171,7 @@ test_flatten_spans(TestBatch *batch) {
}
void
-TestHeatMap_run(TestHeatMap *self) {
+TestHeatMap_run_tests(TestHeatMap *self) {
TestBatch *batch = (TestBatch*)self;
test_calc_proximity_boost(batch);
test_flatten_spans(batch);
http://git-wip-us.apache.org/repos/asf/lucy/blob/4072c56f/core/Lucy/Test/Highlight/TestHeatMap.cfh
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Highlight/TestHeatMap.cfh b/core/Lucy/Test/Highlight/TestHeatMap.cfh
index 37d127a..799c6af 100644
--- a/core/Lucy/Test/Highlight/TestHeatMap.cfh
+++ b/core/Lucy/Test/Highlight/TestHeatMap.cfh
@@ -26,7 +26,7 @@ class Lucy::Test::Highlight::TestHeatMap
init(TestHeatMap *self);
void
- Run(TestHeatMap *self);
+ Run_Tests(TestHeatMap *self);
}