[zorg] r174134 - LitTestCommand: Add unittest scaffolding.

Daniel Dunbar daniel at zuster.org
Thu Jan 31 17:39:28 PST 2013


Author: ddunbar
Date: Thu Jan 31 19:39:27 2013
New Revision: 174134

URL: http://llvm.org/viewvc/llvm-project?rev=174134&view=rev
Log:
LitTestCommand: Add unittest scaffolding.
 - It's much more sensible to test this stuff with proxies than inside a real buildbot instance.

Modified:
    zorg/trunk/zorg/buildbot/commands/LitTestCommand.py

Modified: zorg/trunk/zorg/buildbot/commands/LitTestCommand.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/zorg/buildbot/commands/LitTestCommand.py?rev=174134&r1=174133&r2=174134&view=diff
==============================================================================
--- zorg/trunk/zorg/buildbot/commands/LitTestCommand.py (original)
+++ zorg/trunk/zorg/buildbot/commands/LitTestCommand.py Thu Jan 31 19:39:27 2013
@@ -85,3 +85,35 @@ class LitTestCommand(Test):
     for name, count in self.logObserver.resultCounts.iteritems():
         description.append('{0} {1}'.format(count, self.resultNames[name]))
     return description
+
+##
+
+import unittest
+
+class StepProxy(object):
+  def __init__(self):
+    self.logs = []
+
+  def addCompleteLog(self, name, text):
+    self.logs.append((name, text))
+
+class TestLogObserver(unittest.TestCase):
+  def parse_log(self, text):
+    observer = LitLogObserver()
+    observer.step = StepProxy()
+    for ln in text.split('\n'):
+      observer.outLineReceived(ln)
+    return observer
+
+  def test_basic(self):
+    obs = self.parse_log("""
+PASS: test-one (1 of 3)
+FAIL: test-two (2 of 3)
+PASS: test-three (3 of 3)
+""")
+
+    self.assertEqual(obs.resultCounts, { 'FAIL' : 1, 'PASS' : 2 })
+    self.assertEqual(obs.step.logs, [('test-two', 'FAIL: test-two (2 of 3)')])
+
+if __name__ == '__main__':
+  unittest.main()





More information about the llvm-commits mailing list