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/09 18:14:55 UTC
[lucy-commits] [13/16] git commit: refs/heads/c-bindings-wip3 - 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/c2f5daa1
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/c2f5daa1
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/c2f5daa1
Branch: refs/heads/c-bindings-wip3
Commit: c2f5daa1c19426053e6d5cc094f312f39afd39e3
Parents: c383707
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sat Mar 2 17:00:11 2013 +0100
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Mar 9 17:51:55 2013 +0100
----------------------------------------------------------------------
core/Clownfish/Test/TestBatch.c | 25 ++++++++++++++++++++++++-
1 files changed, 24 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy/blob/c2f5daa1/core/Clownfish/Test/TestBatch.c
----------------------------------------------------------------------
diff --git a/core/Clownfish/Test/TestBatch.c b/core/Clownfish/Test/TestBatch.c
index 0119b0d..403c224 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,17 @@ 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);
+ INCREF(mess);
+ Err_warn_mess(mess);
+ }
if (self->num_failed > 0) {
failed = true;
TestFormatter_batch_comment(self->formatter, "%d/%d tests failed.\n",
@@ -81,6 +97,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;