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/18 20:50:20 UTC

[lucy-commits] [8/9] git commit: refs/heads/clownfish-test-v2 - Move code to unbuffer stdout

Move code to unbuffer stdout


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/001310fb
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/001310fb
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/001310fb

Branch: refs/heads/clownfish-test-v2
Commit: 001310fb642b1546db71ff5c8bfb2ec8a98285bc
Parents: a1de778
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Mon Feb 18 20:08:41 2013 +0100
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Mon Feb 18 20:14:56 2013 +0100

----------------------------------------------------------------------
 core/Lucy/Test.c |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/001310fb/core/Lucy/Test.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test.c b/core/Lucy/Test.c
index 1d0048e..88f0b55 100644
--- a/core/Lucy/Test.c
+++ b/core/Lucy/Test.c
@@ -96,6 +96,9 @@
 #include "Lucy/Test/Util/TestPriorityQueue.h"
 #include "Lucy/Test/Util/TestStringHelper.h"
 
+static void
+S_unbuffer_stdout();
+
 static bool
 S_vtest_true(TestBatch *self, bool condition, const char *pattern,
              va_list args);
@@ -181,6 +184,8 @@ S_all_test_batches() {
 
 bool
 Test_run_batch(CharBuf *class_name, TestFormatter *formatter) {
+    S_unbuffer_stdout();
+
     VArray   *batches = S_all_test_batches();
     uint32_t  size    = VA_Get_Size(batches);
 
@@ -201,6 +206,8 @@ Test_run_batch(CharBuf *class_name, TestFormatter *formatter) {
 
 bool
 Test_run_all_batches(TestFormatter *formatter) {
+    S_unbuffer_stdout();
+
     TestRunner *runner  = TestRunner_new(formatter);
     VArray     *batches = S_all_test_batches();
     uint32_t    size    = VA_Get_Size(batches);
@@ -217,6 +224,14 @@ Test_run_all_batches(TestFormatter *formatter) {
     return result;
 }
 
+static void
+S_unbuffer_stdout() {
+    int check_val = setvbuf(stdout, NULL, _IONBF, 0);
+    if (check_val != 0) {
+        fprintf(stderr, "Failed when trying to unbuffer stdout\n");
+    }
+}
+
 TestBatch*
 TestBatch_new(uint32_t num_planned) {
     TestBatch *self = (TestBatch*)VTable_Make_Obj(TESTBATCH);
@@ -235,12 +250,6 @@ TestBatch_init(TestBatch *self, uint32_t num_planned) {
     self->num_failed      = 0;
     self->num_skipped     = 0;
 
-    // Unbuffer stdout. TODO: move this elsewhere.
-    int check_val = setvbuf(stdout, NULL, _IONBF, 0);
-    if (check_val != 0) {
-        fprintf(stderr, "Failed when trying to unbuffer stdout\n");
-    }
-
     return self;
 }