subunit: Import new upstream snapshot (adds subunit_progress())
authorJelmer Vernooij <jelmer@samba.org>
Thu, 30 Sep 2010 07:29:42 +0000 (09:29 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Thu, 30 Sep 2010 07:29:42 +0000 (09:29 +0200)
lib/subunit/c/include/subunit/child.h
lib/subunit/c/lib/child.c
lib/subunit/c/tests/test_child.c
lib/update-external.sh

index 0a4e60127bff64741bb7503bd9e2011c8578d27a..896d2dfad08ae01bd55d252f858f077c232beb7d 100644 (file)
@@ -74,6 +74,23 @@ extern void subunit_test_skip(char const * const name,
                              char const * const reason);
 
 
+enum subunit_progress_whence {
+       SUBUNIT_PROGRESS_SET,
+       SUBUNIT_PROGRESS_CUR,
+       SUBUNIT_PROGRESS_POP,
+       SUBUNIT_PROGRESS_PUSH,
+};
+
+/**
+ * subunit_progress:
+ *
+ * Report the progress of a test run.
+ * @whence: The type of progress update to report.
+ * @offset: Offset of the progress (only for SUBUNIT_PROGRESS_SET
+ *                     and SUBUNIT_PROGRESS_CUR).
+ */
+extern void subunit_progress(enum subunit_progress_whence whence, int offset);
+
 #ifdef __cplusplus
 }
 #endif
index 2b59747c0e96f4079bdb8f8179afda51ec2b2114..20f38da8c9052634c6663832f1ae418862fb9d2f 100644 (file)
@@ -80,3 +80,25 @@ subunit_test_skip(char const * const name, char const * const reason)
 {
   subunit_send_event("skip", name, reason);
 }
+
+void
+subunit_progress(enum subunit_progress_whence whence, int offset)
+{
+       switch (whence) {
+       case SUBUNIT_PROGRESS_SET:
+               printf("progress: %d\n", offset);
+               break;
+       case SUBUNIT_PROGRESS_CUR:
+               printf("progress: %+-d\n", offset);
+               break;
+       case SUBUNIT_PROGRESS_POP:
+               printf("progress: pop\n");
+               break;
+       case SUBUNIT_PROGRESS_PUSH:
+               printf("progress: push\n");
+               break;
+       default:
+               fprintf(stderr, "Invalid whence %d in subunit_progress()\n", whence);
+               break;
+       }
+}
index 6399eeb64526f433ae55fb973c3b8923cb80151b..0744599b9f96103faf57602de241d6f5223e5849 100644 (file)
@@ -164,6 +164,44 @@ START_TEST (test_skip)
 }
 END_TEST
 
+
+static void
+call_test_progress_pop(void)
+{
+       subunit_progress(SUBUNIT_PROGRESS_POP, 0);
+}
+
+static void
+call_test_progress_set(void)
+{
+       subunit_progress(SUBUNIT_PROGRESS_SET, 5);
+}
+
+static void
+call_test_progress_push(void)
+{
+       subunit_progress(SUBUNIT_PROGRESS_PUSH, 0);
+}
+
+static void
+call_test_progress_cur(void)
+{
+       subunit_progress(SUBUNIT_PROGRESS_CUR, -6);
+}
+
+START_TEST (test_progress)
+{
+       test_stdout_function("progress: pop\n",
+                        call_test_progress_pop);
+       test_stdout_function("progress: push\n",
+                        call_test_progress_push);
+       test_stdout_function("progress: 5\n",
+                        call_test_progress_set);
+       test_stdout_function("progress: -6\n",
+                        call_test_progress_cur);
+}
+END_TEST
+
 static Suite *
 child_suite(void)
 {
@@ -175,6 +213,7 @@ child_suite(void)
     tcase_add_test (tc_core, test_fail);
     tcase_add_test (tc_core, test_error);
     tcase_add_test (tc_core, test_skip);
+    tcase_add_test (tc_core, test_progress);
     return s;
 }
 
index fc2443b77e6ddd042d2ff0858c00ed41637828da..0a854406b527e8e5ccd7a942b4bfde7fdd5c5257 100755 (executable)
@@ -7,6 +7,8 @@ WORKDIR="`mktemp -d`"
 
 echo "Updating subunit..."
 bzr export "$WORKDIR/subunit" lp:subunit 
+# Preserve wscript file
+cp "$TARGETDIR/subunit/c/wscript" "$WORKDIR/subunit/c/wscript"
 rsync -avz --delete "$WORKDIR/subunit/" "$TARGETDIR/subunit/"
 
 echo "Updating testtools..."