[CalendarServer-changes] [11421] CalendarServer/branches/users/glyph/launchd-wrapper-bis/twext/ python/test/test_launchd.py
source_changes at macosforge.org
source_changes at macosforge.org
Wed Jun 26 01:16:30 PDT 2013
Revision: 11421
http://trac.calendarserver.org//changeset/11421
Author: glyph at apple.com
Date: 2013-06-26 01:16:30 -0700 (Wed, 26 Jun 2013)
Log Message:
-----------
Fully working test for tests.
Modified Paths:
--------------
CalendarServer/branches/users/glyph/launchd-wrapper-bis/twext/python/test/test_launchd.py
Modified: CalendarServer/branches/users/glyph/launchd-wrapper-bis/twext/python/test/test_launchd.py
===================================================================
--- CalendarServer/branches/users/glyph/launchd-wrapper-bis/twext/python/test/test_launchd.py 2013-06-26 08:16:10 UTC (rev 11420)
+++ CalendarServer/branches/users/glyph/launchd-wrapper-bis/twext/python/test/test_launchd.py 2013-06-26 08:16:30 UTC (rev 11421)
@@ -18,10 +18,13 @@
Tests for L{twext.python.launchd}.
"""
-import sys, os, plistlib
+import sys, os, plistlib, socket
if __name__ == '__main__':
- import socket
+ testID = sys.argv[1]
+ a, b = testID.rsplit(".", 1)
+ from twisted.python.reflect import namedAny
+ namedAny(".".join([a, b.replace("test_", "job_")]))()
skt = socket.socket()
skt.connect(("127.0.0.1", int(os.environ["TESTING_PORT"])))
sys.exit(0)
@@ -201,12 +204,13 @@
return port.stopListening()
env = dict(os.environ)
env["TESTING_PORT"] = repr(port.getHost().port)
+ self.stdout = fp.child("stdout.txt")
plist = {
"Label": "org.calendarserver.UNIT-TESTS." + repr(os.getpid()),
"ProgramArguments": [sys.executable, "-m", __name__, self.id()],
"EnvironmentVariables": env,
"KeepAlive": False,
- "StandardOutPath": fp.child("stdout.txt").path,
+ "StandardOutPath": self.stdout.path,
"StandardErrorPath": fp.child("stderr.txt").path,
"RunAtLoad": True,
}
@@ -216,13 +220,24 @@
return d
+ @classmethod
+ def job_test(self):
+ """
+ Do something observable in a subprocess.
+ """
+ sys.stdout.write("Sample Value.")
+ sys.stdout.flush()
+
+
def test_test(self):
"""
Since this test framework is somewhat finicky, let's just make sure
that a test can complete.
"""
+ self.assertEquals("Sample Value.", self.stdout.getContent())
+
def tearDown(self):
os.spawnlp(os.P_WAIT, "launchctl", "launchctl", "unload", self.job.path)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130626/0cc6a38c/attachment.html>
More information about the calendarserver-changes
mailing list