Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Unified Diff: tests/commit_queue_test.py

Issue 22866026: Log exceptions that terminate CQ loop (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/commit-queue@master
Patch Set: Fix tests with fake logger Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « commit_queue.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/commit_queue_test.py
diff --git a/tests/commit_queue_test.py b/tests/commit_queue_test.py
index 049c29b5f34e565120461e7550e8c19f9a62f60d..175672cf75fa2f5af7f72dbfda6c0d432691aa0a 100755
--- a/tests/commit_queue_test.py
+++ b/tests/commit_queue_test.py
@@ -5,10 +5,12 @@
"""Unit tests for commit_queue.py."""
+import logging
import os
import StringIO
import sys
import time
+import traceback
import unittest
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -73,6 +75,14 @@ class CommitQueueTest(auto_stub.TestCase):
self.mock(sys, 'stdout', StringIO.StringIO())
self.mock(sys, 'stderr', StringIO.StringIO())
self.mock(commit_queue.projects, 'load_project', None)
+ commit_queue.SetupLogging = lambda _: None
M-A Ruel 2013/08/26 19:23:39 self.mock(commit_queue, 'SetupLogging', lambda _:
+ # Setup logging attached to the mocked sys.stderr, printing
+ # only the exception name to make tests not fragile.
+ handler = logging.StreamHandler()
+ formatter = logging.Formatter()
+ formatter.formatException = lambda _: traceback.format_exc(0)
+ handler.setFormatter(formatter)
+ logging.getLogger().handlers = [handler]
self._time = 1
self.mock(time, 'time', self._get_time)
self.mock(creds, 'Credentials', self._get_cred)
@@ -142,7 +152,12 @@ class CommitQueueTest(auto_stub.TestCase):
'Using read-only Rietveld\n'
'Using read-only checkout\n'
'Using read-only chromium-status interface\n')
- self._check('stderr', 'Saving db... \nDone! \n')
+ self._check(
+ 'stderr',
+ 'CQ loop terminating\n'
+ 'Traceback (most recent call last):\n'
+ 'Stop\n\n'
+ 'Saving db...\ndb save successful.\n')
def testDryRun(self):
sys.argv.extend(('--project', 'chromium'))
@@ -166,7 +181,12 @@ class CommitQueueTest(auto_stub.TestCase):
'Using read-only Rietveld\n'
'Using read-only checkout\n'
'Using read-only chromium-status interface\n')
- self._check('stderr', 'Saving db... \nDone! \n')
+ self._check(
+ 'stderr',
+ 'CQ loop terminating\n'
+ 'Traceback (most recent call last):\n'
+ 'Stop\n\n'
+ 'Saving db...\ndb save successful.\n')
if __name__ == '__main__':
« no previous file with comments | « commit_queue.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698