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/03/02 21:06:36 UTC
[lucy-commits] [12/15] git commit: refs/heads/c-bindings-wip2 - Catch exceptions
thrown during tests
Catch exceptions thrown during tests
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/3f21ac68
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/3f21ac68
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/3f21ac68
Branch: refs/heads/c-bindings-wip2
Commit: 3f21ac68c45af535c9b6c28faa196b4010dfeca2
Parents: c27fdf4
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sat Mar 2 17:00:11 2013 +0100
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Mar 2 17:00:11 2013 +0100
----------------------------------------------------------------------
core/Clownfish/Test/TestBatch.c | 24 +++++++++++++++++++++++-
1 files changed, 23 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy/blob/3f21ac68/core/Clownfish/Test/TestBatch.c
----------------------------------------------------------------------
diff --git a/core/Clownfish/Test/TestBatch.c b/core/Clownfish/Test/TestBatch.c
index 0119b0d..df72fb1 100644
--- a/core/Clownfish/Test/TestBatch.c
+++ b/core/Clownfish/Test/TestBatch.c
@@ -22,10 +22,18 @@
#define LUCY_USE_SHORT_NAMES
#include "Clownfish/Test/TestBatch.h"
#include "Clownfish/CharBuf.h"
+#include "Clownfish/Err.h"
#include "Clownfish/Test/TestFormatter.h"
#include "Clownfish/VArray.h"
#include "Clownfish/VTable.h"
+struct try_run_tests_context {
+ TestBatch *batch;
+};
+
+static void
+S_try_run_tests(void *context);
+
static bool
S_vtest_true(TestBatch *self, bool condition, const char *pattern,
va_list args);
@@ -62,9 +70,16 @@ bool
TestBatch_run(TestBatch *self) {
TestFormatter_Batch_Prologue(self->formatter, self);
- TestBatch_Run_Tests(self);
+ struct try_run_tests_context args;
+ args.batch = self;
+ Err *err = Err_trap(S_try_run_tests, &args);
bool failed = false;
+ if (err) {
+ failed = true;
+ CharBuf *mess = Err_Get_Mess(err);
+ TestFormatter_batch_comment(self->formatter, "%s", CB_Get_Ptr8(mess));
+ }
if (self->num_failed > 0) {
failed = true;
TestFormatter_batch_comment(self->formatter, "%d/%d tests failed.\n",
@@ -81,6 +96,13 @@ TestBatch_run(TestBatch *self) {
return !failed;
}
+static void
+S_try_run_tests(void *context) {
+ struct try_run_tests_context *args
+ = (struct try_run_tests_context*)context;
+ TestBatch_Run_Tests(args->batch);
+}
+
uint32_t
TestBatch_get_num_planned(TestBatch *self) {
return self->num_planned;