Make IpcDaemonTestCase use EbuildBuildDir for lock creation.
authorZac Medico <zmedico@gentoo.org>
Tue, 14 Sep 2010 07:32:43 +0000 (00:32 -0700)
committerZac Medico <zmedico@gentoo.org>
Tue, 14 Sep 2010 07:32:43 +0000 (00:32 -0700)
pym/portage/tests/ebuild/test_ipc_daemon.py

index 6e2fe36e1966787b50e5fbbc15c1c5f19d43c6c3..c4eb55b0d3312066bd0adb5de1d61c2823ffed12 100644 (file)
@@ -11,7 +11,9 @@ from portage.const import PORTAGE_BIN_PATH
 from portage.const import PORTAGE_PYM_PATH
 from portage.const import BASH_BINARY
 from portage.package.ebuild._ipc.ExitCommand import ExitCommand
+from portage.util import ensure_dirs
 from _emerge.SpawnProcess import SpawnProcess
+from _emerge.EbuildBuildDir import EbuildBuildDir
 from _emerge.EbuildIpcDaemon import EbuildIpcDaemon
 from _emerge.TaskScheduler import TaskScheduler
 
@@ -34,13 +36,20 @@ class IpcDaemonTestCase(TestCase):
                        env['PORTAGE_PYTHON'] = _python_interpreter
                        env['PORTAGE_BIN_PATH'] = PORTAGE_BIN_PATH
                        env['PORTAGE_PYM_PATH'] = PORTAGE_PYM_PATH
-                       env['PORTAGE_BUILDDIR'] = tmpdir
+                       env['PORTAGE_BUILDDIR'] = os.path.join(tmpdir, 'cat', 'pkg-1')
 
-                       input_fifo = os.path.join(tmpdir, '.ipc_in')
-                       output_fifo = os.path.join(tmpdir, '.ipc_out')
+                       task_scheduler = TaskScheduler(max_jobs=2)
+                       build_dir = EbuildBuildDir(dir_path=env['PORTAGE_BUILDDIR'],
+                               scheduler=task_scheduler.sched_iface,
+                               settings=env)
+                       build_dir.lock()
+                       ensure_dirs(env['PORTAGE_BUILDDIR'])
+
+                       input_fifo = os.path.join(env['PORTAGE_BUILDDIR'], '.ipc_in')
+                       output_fifo = os.path.join(env['PORTAGE_BUILDDIR'], '.ipc_out')
                        os.mkfifo(input_fifo)
                        os.mkfifo(output_fifo)
-                       task_scheduler = TaskScheduler(max_jobs=2)
+
                        for exitcode in (0, 1, 2):
                                exit_command = ExitCommand()
                                commands = {'exit' : exit_command}
@@ -108,5 +117,6 @@ class IpcDaemonTestCase(TestCase):
                                self.assertEqual(daemon.isAlive(), False)
                                self.assertEqual(proc.returncode == os.EX_OK, False)
 
+                       build_dir.unlock()
                finally:
                        shutil.rmtree(tmpdir)