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/
Date: Wed,  1 Jun 2011 12:30:15 +0000 (UTC)	[thread overview]
Message-ID: <29fa19fb5db1c860bc7c54df6426aea5aaac063d.mgorny@gentoo> (raw)

commit:     29fa19fb5db1c860bc7c54df6426aea5aaac063d
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Jun  1 11:23:32 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Jun  1 11:23:32 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=29fa19fb

Commonize the CLI code for single executable.

---
 PMSTestSuite/cli.py        |   55 ++++++++++++++++++++++++++++++++++++++++++-
 PMSTestSuite/testrunner.py |   55 --------------------------------------------
 pms-tester                 |    4 +-
 3 files changed, 55 insertions(+), 59 deletions(-)

diff --git a/PMSTestSuite/cli.py b/PMSTestSuite/cli.py
index 7db4713..f7eb7ae 100644
--- a/PMSTestSuite/cli.py
+++ b/PMSTestSuite/cli.py
@@ -3,6 +3,7 @@
 # Released under the terms of the 2-clause BSD license.
 
 import os.path, shlex
+import gobject
 
 from optparse import OptionParser
 
@@ -13,8 +14,7 @@ from PMSTestSuite.pm import get_package_managers
 
 class PMSTestSuiteCLI(object):
 	"""
-	A class encapsulating common CLI routines used by PMS Test Suite
-	scripts.
+	A class encapsulating CLI routines used by the PMS Test Suite.
 
 	Properties:
 	1) set during __init__():
@@ -84,3 +84,54 @@ class PMSTestSuiteCLI(object):
 			self.test_library = load_library(opts.library_name)
 		except (ImportError, TypeError) as e:
 			opt.error('Test library load failed: %s' % e)
+
+	def merge_done(self, pid, ret):
+		failed = []
+
+		cpvs = frozenset(self.pm.lookup_vardb(self.cpvs))
+		for t in self.test_library:
+			res = t.check_result(t.cpv in cpvs)
+			if not res:
+				failed.append(t)
+
+		if len(failed) != len(self.cpvs):
+			print('-> Unmerging test ebuilds...')
+			self.pm.unmerge(cpvs)
+
+		if not failed:
+			print('%d tests completed successfully.' % len(self.cpvs))
+		else:
+			print('%d of %d tests completed successfully, %d failed:'
+					% (len(self.cpvs) - len(failed), len(self.cpvs), len(failed)))
+			for t in failed:
+				print('- %s' % t.p)
+
+		self.ret = 0 if not failed else 1
+		self.loop.quit()
+
+	def main(self, argv):
+		self._start(*argv)
+
+		print('-> Generating ebuilds...')
+		files = {}
+		for t in self.test_library:
+			files.update(t.get_output_files())
+
+		self.repository.write_files(files)
+		self.repository.remanifest(files, self.pm)
+
+		self.pm.append_repository(self.repository)
+		self.cpvs = [t.cpv for t in self.test_library]
+
+		installedcpvs = self.pm.lookup_vardb(self.cpvs)
+		if installedcpvs:
+			print('-> Unmerging already-merged test ebuilds...')
+			self.pm.unmerge(installedcpvs)
+
+		print('-> Running PM...')
+		self.loop = gobject.MainLoop()
+		gobject.child_watch_add(self.pm.merge_async(self.cpvs),
+				self.merge_done)
+		self.loop.run()
+
+		return self.ret

diff --git a/PMSTestSuite/testrunner.py b/PMSTestSuite/testrunner.py
deleted file mode 100644
index 19c3749..0000000
--- a/PMSTestSuite/testrunner.py
+++ /dev/null
@@ -1,55 +0,0 @@
-from PMSTestSuite.ebuildgen import EbuildGenCLI
-
-import gobject
-
-class TestRunnerCLI(EbuildGenCLI):
-	def merge_done(self, pid, ret):
-		failed = []
-
-		cpvs = frozenset(self.pm.lookup_vardb(self.cpvs))
-		for t in self.test_library:
-			res = t.check_result(t.cpv in cpvs)
-			if not res:
-				failed.append(t)
-
-		if len(failed) != len(self.cpvs):
-			print('-> Unmerging test ebuilds...')
-			self.pm.unmerge(cpvs)
-
-		if not failed:
-			print('%d tests completed successfully.' % len(self.cpvs))
-		else:
-			print('%d of %d tests completed successfully, %d failed:'
-					% (len(self.cpvs) - len(failed), len(self.cpvs), len(failed)))
-			for t in failed:
-				print('- %s' % t.p)
-
-		self.ret = 0 if not failed else 1
-		self.loop.quit()
-
-	def main(self, argv):
-		self._start(*argv)
-
-		print('-> Generating ebuilds...')
-		files = {}
-		for t in self.test_library:
-			files.update(t.get_output_files())
-
-		self.repository.write_files(files)
-		self.repository.remanifest(files, self.pm)
-
-		self.pm.append_repository(self.repository)
-		self.cpvs = [t.cpv for t in self.test_library]
-
-		installedcpvs = self.pm.lookup_vardb(self.cpvs)
-		if installedcpvs:
-			print('-> Unmerging already-merged test ebuilds...')
-			self.pm.unmerge(installedcpvs)
-
-		print('-> Running PM...')
-		self.loop = gobject.MainLoop()
-		gobject.child_watch_add(self.pm.merge_async(self.cpvs),
-				self.merge_done)
-		self.loop.run()
-
-		return self.ret

diff --git a/pms-tester b/pms-tester
index ededbef..317b587 100755
--- a/pms-tester
+++ b/pms-tester
@@ -5,8 +5,8 @@
 
 import sys
 
-from PMSTestSuite.testrunner import TestRunnerCLI
+from PMSTestSuite.cli import PMSTestSuiteCLI
 
 if __name__ == '__main__':
-	cli = TestRunnerCLI()
+	cli = PMSTestSuiteCLI()
 	sys.exit(cli.main(sys.argv))



             reply	other threads:[~2011-06-01 12:30 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-01 12:30 Michał Górny [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-01-03 15:52 [gentoo-commits] proj/pms-test-suite:master commit in: /, pmstestsuite/ Michał Górny
2011-06-27 21:24 Michał Górny
2011-06-01 12:30 [gentoo-commits] proj/pms-test-suite:master commit in: /, PMSTestSuite/ Michał Górny
2011-05-29 18:57 Michał Górny
2011-05-29 17:55 Michał Górny
2011-05-29 17:55 Michał Górny
2011-05-29 17:46 Michał Górny
2011-05-29 17:46 Michał Górny
2011-05-29 17:13 Michał Górny
2011-05-22  9:17 Michał Górny
2011-05-16 20:00 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=29fa19fb5db1c860bc7c54df6426aea5aaac063d.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