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/library/standard/, pmstestsuite/library/
Date: Mon,  2 Jan 2012 22:26:27 +0000 (UTC)	[thread overview]
Message-ID: <948bbafc0f1a2c2eeb524cca38ac98ea966bb475.mgorny@gentoo> (raw)

commit:     948bbafc0f1a2c2eeb524cca38ac98ea966bb475
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Jan  2 22:11:11 2012 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Jan  2 22:13:22 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=948bbafc

Merge D-Bus into main case classes.

---
 pmstestsuite/library/case.py               |   78 +++++++++++++++-
 pmstestsuite/library/depend_case.py        |    2 +-
 pmstestsuite/library/eclass_case.py        |    2 +-
 pmstestsuite/library/standard/dbus_case.py |  140 ++--------------------------
 4 files changed, 86 insertions(+), 136 deletions(-)

diff --git a/pmstestsuite/library/case.py b/pmstestsuite/library/case.py
index 614a500..90406a0 100644
--- a/pmstestsuite/library/case.py
+++ b/pmstestsuite/library/case.py
@@ -5,8 +5,14 @@
 import copy, itertools, random, re
 from gentoopm.util import ABCObject, BoolCompat
 
+import dbus.service
+
 from abc import ABCMeta, abstractmethod, abstractproperty
 
+from pmstestsuite.dbus_handler import DBusHandler, dbus_interface_name, dbus_object_prefix
+
+dbus_handler = DBusHandler()
+
 # XXX: move to some consts module?
 phase_func_names = [
 	'pkg_pretend', 'pkg_setup', 'src_unpack', 'src_prepare',
@@ -227,7 +233,7 @@ class NotEqualAssertionResult(EqualAssertionResult):
 		return '%s != %s' % (self.actual,
 				repr(self._expect))
 
-class TestCase(object): # was: ABCObject
+class TestCase(dbus.service.Object): # was: ABCObject
 	"""
 	Base class for a test case.
 
@@ -239,9 +245,19 @@ class TestCase(object): # was: ABCObject
 	_finalized = False
 
 	def __init__(self, short_name):
+		"""
+		Initialize the test class and the D-Bus interface for it.
+		"""
+
 		self.assertions = []
 		self._short_name = short_name
 
+		dbus.service.Object.__init__(
+				self,
+				dbus_handler.bus,
+				'%s/%s' % (dbus_object_prefix, self.p.replace('-', '_'))
+		)
+
 	@property
 	def short_name(self):
 		return self._short_name
@@ -258,6 +274,8 @@ class TestCase(object): # was: ABCObject
 	def _finalize(self):
 		"""
 		Do any final modifications to test case data. Mark it finalized.
+		Ensure that C{pkg_setup()} will be called.
+
 		This function shall be called at most once per object.
 		"""
 		self._finalized = True
@@ -531,6 +549,8 @@ class EbuildTestCase(TestCase):
 	def _finalize(self):
 		TestCase._finalize(self)
 
+		if self.phase_funcs['pkg_setup']:
+			self.phase_funcs['pkg_setup'].insert(0, 'pms-test_pkg_setup')
 		if 'DESCRIPTION' not in self.ebuild_vars:
 			self.ebuild_vars['DESCRIPTION'] = self._stripped_docstring
 
@@ -546,8 +566,9 @@ class EbuildTestCase(TestCase):
 		@param eapi: the EAPI
 		@type eapi: string
 		"""
-		TestCase.__init__(self, short_name)
 		self.eapi = eapi
+		self.reset()
+		TestCase.__init__(self, short_name)
 
 		for v in ('ebuild_vars', 'inherits', 'phase_funcs'):
 			setattr(self, v, copy.deepcopy(getattr(self, v)))
@@ -559,6 +580,34 @@ class EbuildTestCase(TestCase):
 		self.ebuild_vars['KEYWORDS'] = 'alpha amd64 arm hppa ia64 ' + \
 				'm68k ~mips ppc ppc64 s390 sh sparc x86'
 
+	def reset(self):
+		"""
+		Reset (D-Bus) test results.
+		"""
+		self.dbus_output = []
+		self.dbus_started = False
+
+	@dbus.service.method(
+			dbus_interface=dbus_interface_name,
+			in_signature='', out_signature='')
+	def test_started(self):
+		"""
+		Notify the test suite that a particular test has been started.
+		"""
+		self.dbus_started = True
+
+	@dbus.service.method(
+			dbus_interface=dbus_interface_name,
+			in_signature='s', out_signature='')
+	def append_output(self, l):
+		"""
+		Append the string to the test output.
+
+		@param l: result string
+		@type l: C{dbus.UTF8String}
+		"""
+		self.dbus_output.append(str(l))
+
 	def get_output_files(self):
 		class EbuildTestCaseEbuildFile(object):
 			""" Lazy ebuild contents evaluator for EbuildTestCase. """
@@ -610,6 +659,29 @@ class EbuildTestCase(TestCase):
 	def start(self, pm):
 		pm.merge(self.cpv)
 
+	def check_dbus_result(self, output, pm):
+		"""
+		Check whether the output sent through D-Bus matches expected test
+		output.
+
+		The default implementation simply checks whether the test was merged
+		alike L{EbuildTestCase.check_result()}.
+
+		@param output: the D-Bus output
+		@type output: list(str)
+		@param pm: the package manager instance
+		@type pm: L{PackageManager}
+		@return: C{True} if output matches expected test result, C{False}
+			otherwise
+		@rtype: bool
+		"""
+		pass
+
+	def _pop_dbus_output(self):
+		ret = self.dbus_output
+		self.reset()
+		return ret
+
 	def check_result(self, pm):
 		"""
 		Check the correctness of the result of test execution. By default,
@@ -622,3 +694,5 @@ class EbuildTestCase(TestCase):
 		merged = self.atom(pm) in pm.installed
 		self.assertBool(not self.expect_failure, merged,
 				'package merged')
+		self.assertTrue(self.dbus_started, 'build started')
+		self.check_dbus_result(self._pop_dbus_output(), pm)

diff --git a/pmstestsuite/library/depend_case.py b/pmstestsuite/library/depend_case.py
index bc06aa3..3f34ca7 100644
--- a/pmstestsuite/library/depend_case.py
+++ b/pmstestsuite/library/depend_case.py
@@ -1,5 +1,5 @@
 #	vim:fileencoding=utf-8
-# (c) 2011 Michał Górny <mgorny@gentoo.org>
+# (c) 2011-2012 Michał Górny <mgorny@gentoo.org>
 # Released under the terms of the 2-clause BSD license.
 
 from .case import EbuildTestCase, AssertionResult

diff --git a/pmstestsuite/library/eclass_case.py b/pmstestsuite/library/eclass_case.py
index cd64a9a..d409e0d 100644
--- a/pmstestsuite/library/eclass_case.py
+++ b/pmstestsuite/library/eclass_case.py
@@ -1,5 +1,5 @@
 #	vim:fileencoding=utf-8
-# (c) 2011 Michał Górny <mgorny@gentoo.org>
+# (c) 2011-2012 Michał Górny <mgorny@gentoo.org>
 # Released under the terms of the 2-clause BSD license.
 
 from abc import abstractproperty

diff --git a/pmstestsuite/library/standard/dbus_case.py b/pmstestsuite/library/standard/dbus_case.py
index ac9c4d1..14258b7 100644
--- a/pmstestsuite/library/standard/dbus_case.py
+++ b/pmstestsuite/library/standard/dbus_case.py
@@ -2,143 +2,19 @@
 # (c) 2011-2012 Michał Górny <mgorny@gentoo.org>
 # Released under the terms of the 2-clause BSD license.
 
-import dbus.service
-
 from pmstestsuite.library.case import EbuildTestCase
 from pmstestsuite.library.depend_case import EbuildDependencyTestCase, \
 		EclassDependencyTestCase
 from pmstestsuite.library.eclass_case import EclassTestCase
 
-from pmstestsuite.dbus_handler import DBusHandler, dbus_interface_name, dbus_object_prefix
-
-dbus_handler = DBusHandler()
-
-class DBusBaseTestCase(dbus.service.Object):
-	""" A base D-Bus test case class. """
-
-	def __init__(self):
-		"""
-		Initialize the D-Bus interface for the test.
-		"""
-		self.reset()
-		dbus.service.Object.__init__(
-				self,
-				dbus_handler.bus,
-				'%s/%s' % (dbus_object_prefix, self.p.replace('-', '_'))
-		)
-
-	def reset(self):
-		"""
-		Reset test results.
-		"""
-		self.dbus_output = []
-		self.dbus_started = False
-
-	@dbus.service.method(
-			dbus_interface=dbus_interface_name,
-			in_signature='', out_signature='')
-	def test_started(self):
-		"""
-		Notify the test suite that a particular test has been started.
-		"""
-		self.dbus_started = True
-
-	@dbus.service.method(
-			dbus_interface=dbus_interface_name,
-			in_signature='s', out_signature='')
-	def append_output(self, l):
-		"""
-		Append the string to the test output.
-
-		@param l: result string
-		@type l: C{dbus.UTF8String}
-		"""
-		self.dbus_output.append(str(l))
-
-	def _finalize(self):
-		"""
-		Finalize the object, ensuring that C{pkg_setup()} will be called.
-		"""
-		if self.phase_funcs['pkg_setup']:
-			self.phase_funcs['pkg_setup'].insert(0, 'pms-test_pkg_setup')
-
-	def check_dbus_result(self, output, pm):
-		"""
-		Check whether the output sent through D-Bus matches expected test
-		output.
-
-		The default implementation simply checks whether the test was merged
-		alike L{EbuildTestCase.check_result()}.
-
-		@param output: the D-Bus output
-		@type output: list(str)
-		@param pm: the package manager instance
-		@type pm: L{PackageManager}
-		@return: C{True} if output matches expected test result, C{False}
-			otherwise
-		@rtype: bool
-		"""
-		pass
-
-	def _pop_dbus_output(self):
-		ret = self.dbus_output
-		self.reset()
-		return ret
-
-	def check_result(self, pm):
-		self.assertTrue(self.dbus_started, 'build started')
-		self.check_dbus_result(self._pop_dbus_output(), pm)
-
-class DBusEbuildTestCase(DBusBaseTestCase, EbuildTestCase):
-	""" D-Bus capable ebuild test case. """
-
-	def __init__(self, *args, **kwargs):
-		""" Initialize the test case and the D-Bus object for it. """
-		EbuildTestCase.__init__(self, *args, **kwargs)
-		DBusBaseTestCase.__init__(self)
-
-	def check_dbus_result(self, output, pm):
-		EbuildTestCase.check_result(self, pm)
-
-class DBusEclassTestCase(DBusBaseTestCase, EclassTestCase):
-	""" D-Bus capable eclass test case. """
-
-	def __init__(self, *args, **kwargs):
-		""" Initialize the test case and the D-Bus object for it. """
-		EclassTestCase.__init__(self, *args, **kwargs)
-		DBusBaseTestCase.__init__(self)
-
-	def check_dbus_result(self, output, pm):
-		EclassTestCase.check_result(self, pm)
-
-class DBusEbuildDependencyTestCase(DBusBaseTestCase, EbuildDependencyTestCase):
-	""" D-Bus capable dependency test case. """
-
-	def __init__(self, *args, **kwargs):
-		""" Initialize the test case and the D-Bus object for it. """
-		EbuildDependencyTestCase.__init__(self, *args, **kwargs)
-		DBusBaseTestCase.__init__(self)
-
-	def check_dbus_result(self, output, pm):
-		EbuildDependencyTestCase.check_result(self, pm)
-
-	def check_result(self, pm):
-		started = self.dbus_started
-		self.check_dbus_result(self._pop_dbus_output(), pm)
-		self.assertBool(not self.expect_failure, started, 'build started')
-
-class DBusEclassDependencyTestCase(DBusBaseTestCase, EclassDependencyTestCase):
-	""" D-Bus capable eclass dependency test case. """
+class DBusEbuildTestCase(EbuildTestCase):
+	pass
 
-	def __init__(self, *args, **kwargs):
-		""" Initialize the test case and the D-Bus object for it. """
-		EclassDependencyTestCase.__init__(self, *args, **kwargs)
-		DBusBaseTestCase.__init__(self)
+class DBusEclassTestCase(EclassTestCase):
+	pass
 
-	def check_dbus_result(self, output, pm):
-		EclassDependencyTestCase.check_result(self, pm)
+class DBusEbuildDependencyTestCase(EbuildDependencyTestCase):
+	pass
 
-	def check_result(self, pm):
-		started = self.dbus_started
-		self.check_dbus_result(self._pop_dbus_output(), pm)
-		self.assertBool(not self.expect_failure, started, 'build started')
+class DBusEclassDependencyTestCase(EclassDependencyTestCase):
+	pass



             reply	other threads:[~2012-01-02 22:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-02 22:26 Michał Górny [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-01-02 22:03 [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/library/standard/, pmstestsuite/library/ Michał Górny
2011-08-11 22:09 Michał Górny
2011-07-18  6:32 Michał Górny
2011-06-17 15:07 [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/library/standard/, PMSTestSuite/library/ 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=948bbafc0f1a2c2eeb524cca38ac98ea966bb475.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