[SCM] Samba Shared Repository - branch master updated

Jelmer Vernooij jelmer at samba.org
Thu Sep 30 01:29:37 MDT 2010


The branch, master has been updated
       via  e36f726 subunit: Import new upstream snapshot (adds subunit_progress())
       via  4118220 testtools: Import new upstream snapshot.
      from  1a9f5b4 s4-drepl: don't call UpdateRefs on a RODC

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit e36f72628173ad476744670a5dbf25a3335e0a19
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Thu Sep 30 09:29:42 2010 +0200

    subunit: Import new upstream snapshot (adds subunit_progress())

commit 41182200a35083a0010f95f622a4ce386c5f0518
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Thu Sep 30 09:18:01 2010 +0200

    testtools: Import new upstream snapshot.

-----------------------------------------------------------------------

Summary of changes:
 lib/subunit/c/include/subunit/child.h           |   17 ++++++++++
 lib/subunit/c/lib/child.c                       |   22 +++++++++++++
 lib/subunit/c/tests/test_child.c                |   39 +++++++++++++++++++++++
 lib/testtools/MANUAL                            |    5 +++
 lib/testtools/NEWS                              |    4 ++
 lib/testtools/testtools/__init__.py             |    2 +
 lib/testtools/testtools/testcase.py             |   19 +++++++++--
 lib/testtools/testtools/tests/test_testtools.py |   22 +++++++++++++
 lib/update-external.sh                          |    2 +
 9 files changed, 129 insertions(+), 3 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/subunit/c/include/subunit/child.h b/lib/subunit/c/include/subunit/child.h
index 0a4e601..896d2df 100644
--- a/lib/subunit/c/include/subunit/child.h
+++ b/lib/subunit/c/include/subunit/child.h
@@ -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
diff --git a/lib/subunit/c/lib/child.c b/lib/subunit/c/lib/child.c
index 2b59747..20f38da 100644
--- a/lib/subunit/c/lib/child.c
+++ b/lib/subunit/c/lib/child.c
@@ -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;
+	}
+}
diff --git a/lib/subunit/c/tests/test_child.c b/lib/subunit/c/tests/test_child.c
index 6399eeb..0744599 100644
--- a/lib/subunit/c/tests/test_child.c
+++ b/lib/subunit/c/tests/test_child.c
@@ -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;
 }
 
diff --git a/lib/testtools/MANUAL b/lib/testtools/MANUAL
index db21366..1a43e70 100644
--- a/lib/testtools/MANUAL
+++ b/lib/testtools/MANUAL
@@ -42,6 +42,11 @@ logic in a try/finally block or tearDown method.  e.g.::
         self.addCleanup(foo.unlock)
         ...
 
+Cleanups can also report multiple errors, if appropriate by wrapping them in
+a testtools.MultipleExceptions object::
+
+    raise MultipleExceptions(exc_info1, exc_info2)
+
 
 TestCase.addOnException
 ~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/lib/testtools/NEWS b/lib/testtools/NEWS
index 596df0d..89b942f 100644
--- a/lib/testtools/NEWS
+++ b/lib/testtools/NEWS
@@ -7,6 +7,10 @@ NEXT
 Improvements
 ------------
 
+* Cleanups can raise ``testtools.MultipleExceptions`` if they have multiple
+  exceptions to report. For instance, a cleanup which is itself responsible for
+  running several different internal cleanup routines might use this.
+
 * Code duplication between assertEqual and the matcher Equals has been removed.
 
 * In normal circumstances, a TestCase will no longer share details with clones
diff --git a/lib/testtools/testtools/__init__.py b/lib/testtools/testtools/__init__.py
index b1c9b66..2b76a5e 100644
--- a/lib/testtools/testtools/__init__.py
+++ b/lib/testtools/testtools/__init__.py
@@ -8,6 +8,7 @@ __all__ = [
     'ErrorHolder',
     'ExtendedToOriginalDecorator',
     'iterate_tests',
+    'MultipleExceptions',
     'MultiTestResult',
     'PlaceHolder',
     'TestCase',
@@ -28,6 +29,7 @@ from testtools.runtest import (
     )
 from testtools.testcase import (
     ErrorHolder,
+    MultipleExceptions,
     PlaceHolder,
     TestCase,
     clone_test_with_new_id,
diff --git a/lib/testtools/testtools/testcase.py b/lib/testtools/testtools/testcase.py
index 959c129..573cd84 100644
--- a/lib/testtools/testtools/testcase.py
+++ b/lib/testtools/testtools/testcase.py
@@ -5,6 +5,7 @@
 __metaclass__ = type
 __all__ = [
     'clone_test_with_new_id',
+    'MultipleExceptions',
     'TestCase',
     'skip',
     'skipIf',
@@ -60,6 +61,13 @@ except ImportError:
         """
 
 
+class MultipleExceptions(Exception):
+    """Represents many exceptions raised from some operation.
+
+    :ivar args: The sys.exc_info() tuples for each exception.
+    """
+
+
 class TestCase(unittest.TestCase):
     """Extensions to the basic TestCase.
 
@@ -188,9 +196,14 @@ class TestCase(unittest.TestCase):
             except KeyboardInterrupt:
                 raise
             except:
-                exc_info = sys.exc_info()
-                self._report_traceback(exc_info)
-                last_exception = exc_info[1]
+                exceptions = [sys.exc_info()]
+                while exceptions:
+                    exc_info = exceptions.pop()
+                    if exc_info[0] is MultipleExceptions:
+                        exceptions.extend(exc_info[1].args)
+                        continue
+                    self._report_traceback(exc_info)
+                    last_exception = exc_info[1]
         return last_exception
 
     def addCleanup(self, function, *arguments, **keywordArguments):
diff --git a/lib/testtools/testtools/tests/test_testtools.py b/lib/testtools/testtools/tests/test_testtools.py
index 5dfb355..8e253e6 100644
--- a/lib/testtools/testtools/tests/test_testtools.py
+++ b/lib/testtools/testtools/tests/test_testtools.py
@@ -8,6 +8,7 @@ import unittest
 
 from testtools import (
     ErrorHolder,
+    MultipleExceptions,
     PlaceHolder,
     TestCase,
     clone_test_with_new_id,
@@ -608,6 +609,27 @@ class TestAddCleanup(TestCase):
         self.assertRaises(
             KeyboardInterrupt, self.test.run, self.logging_result)
 
+    def test_all_errors_from_MultipleExceptions_reported(self):
+        # When a MultipleExceptions exception is caught, all the errors are
+        # reported.
+        def raiseMany():
+            try:
+                1/0
+            except Exception:
+                exc_info1 = sys.exc_info()
+            try:
+                1/0
+            except Exception:
+                exc_info2 = sys.exc_info()
+            raise MultipleExceptions(exc_info1, exc_info2)
+        self.test.addCleanup(raiseMany)
+        self.logging_result = ExtendedTestResult()
+        self.test.run(self.logging_result)
+        self.assertEqual(['startTest', 'addError', 'stopTest'],
+            [event[0] for event in self.logging_result._events])
+        self.assertEqual(set(['traceback', 'traceback-1']),
+            set(self.logging_result._events[1][2].keys()))
+
     def test_multipleCleanupErrorsReported(self):
         # Errors from all failing cleanups are reported as separate backtraces.
         self.test.addCleanup(lambda: 1/0)
diff --git a/lib/update-external.sh b/lib/update-external.sh
index fc2443b..0a85440 100755
--- a/lib/update-external.sh
+++ b/lib/update-external.sh
@@ -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..."


-- 
Samba Shared Repository


More information about the samba-cvs mailing list