diff options
author | Zac Medico <zmedico@gentoo.org> | 2007-06-19 07:22:18 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2007-06-19 07:22:18 +0000 |
commit | 6f2ba6d91f7f06adc4d36e96c0fa617493860bf5 (patch) | |
tree | dfb807b7ee84deeee58592c26320c429004ed313 | |
parent | 1016c4a232dbfd308858cc281f5f9359d92a73c2 (diff) | |
download | portage-6f2ba6d91f7f06adc4d36e96c0fa617493860bf5.tar.gz portage-6f2ba6d91f7f06adc4d36e96c0fa617493860bf5.tar.bz2 portage-6f2ba6d91f7f06adc4d36e96c0fa617493860bf5.zip |
Add a test case for the logfile functionality of portage.spawn().
svn path=/main/trunk/; revision=6870
-rw-r--r-- | pym/portage/tests/__init__.py | 3 | ||||
-rw-r--r-- | pym/portage/tests/ebuild/__init__.py | 3 | ||||
-rw-r--r-- | pym/portage/tests/ebuild/test_spawn.py | 36 |
3 files changed, 41 insertions, 1 deletions
diff --git a/pym/portage/tests/__init__.py b/pym/portage/tests/__init__.py index 60a19de6c..e3702e08e 100644 --- a/pym/portage/tests/__init__.py +++ b/pym/portage/tests/__init__.py @@ -7,7 +7,8 @@ import os, sys, time, unittest import portage.tests def main(): - testDirs = ["bin", "util","versions", "dep", "xpak", "env/config"] + testDirs = ["bin", "dep", "ebuild", + "env/config", "util", "versions", "xpak"] suite = unittest.TestSuite() basedir = os.path.dirname(__file__) for mydir in testDirs: diff --git a/pym/portage/tests/ebuild/__init__.py b/pym/portage/tests/ebuild/__init__.py new file mode 100644 index 000000000..d67b0cd85 --- /dev/null +++ b/pym/portage/tests/ebuild/__init__.py @@ -0,0 +1,3 @@ +# Copyright 1998-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ diff --git a/pym/portage/tests/ebuild/test_spawn.py b/pym/portage/tests/ebuild/test_spawn.py new file mode 100644 index 000000000..66e8f9ea7 --- /dev/null +++ b/pym/portage/tests/ebuild/test_spawn.py @@ -0,0 +1,36 @@ +# Copyright 1998-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +import errno, os, sys +from portage.tests import TestCase + +class SpawnTestCase(TestCase): + + def testLogfile(self): + from portage import settings, spawn + from tempfile import mkstemp + logfile = None + try: + fd, logfile = mkstemp() + os.close(fd) + null_fd = os.open('/dev/null', os.O_RDWR) + test_string = 2 * "blah blah blah\n" + spawn("echo -n '%s'" % test_string, settings, logfile=logfile, + fd_pipes={0:sys.stdin.fileno(), 1:null_fd, 2:null_fd}) + os.close(null_fd) + f = open(logfile, 'r') + log_content = f.read() + f.close() + # When logging passes through a pty, it's lines will be separated + # by '\r\n', so use splitlines before comparing results. + self.assertEqual(test_string.splitlines(), + log_content.splitlines()) + finally: + if logfile: + try: + os.unlink(logfile) + except EnvironmentError, e: + if e.errno != errno.ENOENT: + raise + del e |