public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/pm/, PMSTestSuite/
Date: Tue, 31 May 2011 12:14:38 +0000 (UTC)	[thread overview]
Message-ID: <ac639401c717d43e69efc048acd9f755d9818938.mgorny@gentoo> (raw)

commit:     ac639401c717d43e69efc048acd9f755d9818938
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue May 31 12:12:58 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue May 31 12:12:58 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=ac639401

Use GLib main loop to asynchronically call emerge.

---
 PMSTestSuite/pm/__init__.py  |   10 ++++++++++
 PMSTestSuite/pm/portagepm.py |    9 +++++++++
 PMSTestSuite/testrunner.py   |   18 ++++++++++++++----
 3 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/PMSTestSuite/pm/__init__.py b/PMSTestSuite/pm/__init__.py
index cc6d3d5..f4e6355 100644
--- a/PMSTestSuite/pm/__init__.py
+++ b/PMSTestSuite/pm/__init__.py
@@ -81,6 +81,16 @@ class PackageManager(object):
 		"""
 		raise NotImplementedError('Please override the lookup_vardb() method.')
 
+	# async methods which are supposed to run in background and return pids
+	def merge_async(self, cpvs):
+		"""
+		Run PM asynchronically to merge <cpvs>.
+
+		Returns the PID of spawned process, or raises an exception if spawning
+		one fails.
+		"""
+		raise NotImplementedError('Please override the merge_async() method.')
+
 def get_package_managers():
 	""" Return the list of supported Package Managers. """
 

diff --git a/PMSTestSuite/pm/portagepm.py b/PMSTestSuite/pm/portagepm.py
index d73406b..4b1e751 100644
--- a/PMSTestSuite/pm/portagepm.py
+++ b/PMSTestSuite/pm/portagepm.py
@@ -48,6 +48,15 @@ class PortagePM(PackageManager):
 		ret = self.call_emerge(cpvs, ['--unmerge'])
 		return ret == 0
 
+	def spawn_emerge(self, cpvs, opts = []):
+		p = subprocess.Popen([self.emerge_path] + opts + self.pm_options
+				+ ['=%s' % cpv for cpv in cpvs],
+				env = {'PORTDIR_OVERLAY': ' '.join(self.repo_paths)})
+		return p.pid
+
+	def merge_async(self, cpvs):
+		return self.spawn_emerge(cpvs)
+
 	_vardb = None
 	@property
 	def vardb(self):

diff --git a/PMSTestSuite/testrunner.py b/PMSTestSuite/testrunner.py
index 703ae31..8ac4d6e 100644
--- a/PMSTestSuite/testrunner.py
+++ b/PMSTestSuite/testrunner.py
@@ -1,6 +1,13 @@
 from PMSTestSuite.ebuildgen import EbuildGenCLI
 
+import gobject
+
 class TestRunnerCLI(EbuildGenCLI):
+	def merge_done(self, pid, ret):
+		print(self.pm.lookup_vardb(self.cpvs))
+		self.ret = 0
+		self.loop.quit()
+
 	def main(self, argv):
 		print('-> Generating ebuilds...')
 		ret = EbuildGenCLI.main(self, argv)
@@ -8,14 +15,17 @@ class TestRunnerCLI(EbuildGenCLI):
 			return ret
 
 		self.pm.append_repository(self.repository)
-		cpvs = [t.p for t in self.test_library]
+		self.cpvs = [t.p for t in self.test_library]
 
-		installedcpvs = self.pm.lookup_vardb(cpvs)
+		installedcpvs = self.pm.lookup_vardb(self.cpvs)
 		if installedcpvs:
 			print('-> Unmerging already-merged test ebuilds...')
 			self.pm.unmerge(installedcpvs)
 
 		print('-> Running PM...')
-		self.pm.merge(cpvs)
+		self.loop = gobject.MainLoop()
+		gobject.child_watch_add(self.pm.merge_async(self.cpvs),
+				self.merge_done)
+		self.loop.run()
 
-		return 0
+		return self.ret



             reply	other threads:[~2011-05-31 12:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-31 12:14 Michał Górny [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-06-16 17:22 [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/pm/, PMSTestSuite/ Michał Górny
2011-06-16 17:22 Michał Górny
2011-06-15 16:14 Michał Górny
2011-06-15 16:14 Michał Górny
2011-06-11  6:32 Michał Górny
2011-06-06  7:29 Michał Górny
2011-05-31 12:14 Michał Górny
2011-05-31  8:10 Michał Górny
2011-05-31  8:10 Michał Górny
2011-05-29 18:57 Michał Górny
2011-05-29 18:57 Michał Górny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ac639401c717d43e69efc048acd9f755d9818938.mgorny@gentoo \
    --to=mgorny@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox