diff options
author | Zac Medico <zmedico@gentoo.org> | 2010-08-15 00:07:36 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2010-08-15 00:07:36 -0700 |
commit | 1a7f83e750c59a1ddaf8e94e1286a025b8f8702e (patch) | |
tree | 61d5c09a850532a5edfa9728f1c8996f6f059b2f /pym/portage | |
parent | df3921f0ea835a62ea417c9074f3c9ab87c59b64 (diff) | |
download | portage-1a7f83e750c59a1ddaf8e94e1286a025b8f8702e.tar.gz portage-1a7f83e750c59a1ddaf8e94e1286a025b8f8702e.tar.bz2 portage-1a7f83e750c59a1ddaf8e94e1286a025b8f8702e.zip |
DoebuildSpawnTestCase: Invoke portage.package.ebuild.doebuild.spawn()
with a minimal environment. This gives coverage to some of the ebuild
execution internals, like ebuild.sh, EbuildSpawnProcess, and
EbuildIpcDaemon.
Diffstat (limited to 'pym/portage')
-rw-r--r-- | pym/portage/tests/ebuild/test_doebuild_spawn.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/pym/portage/tests/ebuild/test_doebuild_spawn.py b/pym/portage/tests/ebuild/test_doebuild_spawn.py new file mode 100644 index 000000000..dd0ddcbad --- /dev/null +++ b/pym/portage/tests/ebuild/test_doebuild_spawn.py @@ -0,0 +1,47 @@ +# Copyright 2010 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +from portage import os +from portage import _shell_quote +from portage.const import EBUILD_SH_BINARY +from portage.package.ebuild.config import config +from portage.package.ebuild.doebuild import spawn as doebuild_spawn +from portage.tests import TestCase +from portage.tests.resolver.ResolverPlayground import ResolverPlayground + +class DoebuildSpawnTestCase(TestCase): + """ + Invoke portage.package.ebuild.doebuild.spawn() with a + minimal environment. This gives coverage to some of + the ebuild execution internals, like ebuild.sh, + EbuildSpawnProcess, and EbuildIpcDaemon. + """ + + def testDoebuildSpawn(self): + playground = ResolverPlayground() + try: + settings = config(clone=playground.settings) + cpv = 'sys-apps/portage-2.1' + metadata = {} + settings.setcpv(cpv, mydb=metadata) + settings['PORTAGE_BUILDDIR'] = os.path.join( + settings['PORTAGE_TMPDIR'], cpv) + settings['T'] = os.path.join( + settings['PORTAGE_BUILDDIR'], 'temp') + for x in ('PORTAGE_BUILDDIR', 'T'): + os.makedirs(settings[x]) + # Create a fake environment, to pretend as if the ebuild + # has been sourced already. + open(os.path.join(settings['T'], 'environment'), 'wb') + for enable_ipc in (False, True): + if enable_ipc: + settings['PORTAGE_IPC_DAEMON_ENABLE'] = '1' + else: + settings.pop('PORTAGE_IPC_DAEMON_ENABLE', None) + for phase in ('_internal_test',): + rval = doebuild_spawn( + "%s %s" % (_shell_quote(EBUILD_SH_BINARY), phase), + settings, free=1) + self.assertEqual(rval, os.EX_OK) + finally: + playground.cleanup() |