public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/library/
@ 2011-05-23  9:51 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-05-23  9:51 UTC (permalink / raw
  To: gentoo-commits

commit:     b91b96cc78bd2ee8917f898c83db7751a22bef59
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon May 23 09:51:30 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon May 23 09:51:30 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=b91b96cc

Drop grabmodule().

---
 PMSTestSuite/library/__init__.py |   53 +++++++++++++------------------------
 1 files changed, 19 insertions(+), 34 deletions(-)

diff --git a/PMSTestSuite/library/__init__.py b/PMSTestSuite/library/__init__.py
index 5c56ba6..8447d04 100644
--- a/PMSTestSuite/library/__init__.py
+++ b/PMSTestSuite/library/__init__.py
@@ -13,34 +13,6 @@
 
 from PMSTestSuite.library.case import TestCase
 
-def grabmodule(modname, baseclass):
-	"""
-	Import Python module <modname> and find subclasses of <baseclass> there.
-	
-	Returns an iterator over subclasses or raises one of the following
-	exceptions:
-	- ImportError if module import fails,
-	- TypeError if no matching class is found.
-	"""
-	mod = __import__(modname, {}, {}, ['.'], 0)
-	fail = True
-
-	for k in dir(mod):
-		modvar = getattr(mod, k)
-		# the !issubclass() check is necessary to omit TestLibrary class
-		# imported for the subclass
-		try:
-			if issubclass(modvar, baseclass) and \
-					not issubclass(baseclass, modvar):
-				fail = False
-				yield modvar
-		except TypeError:
-			pass
-
-	if fail:
-		raise TypeError('Unable to find a %s subclass in %s'
-				% (baseclass.__name__, modname))
-
 class TestLibrary(object):
 	""" Base class for a test library. """
 
@@ -51,10 +23,11 @@ class TestLibrary(object):
 
 		Returns an iterator over TestCase subclass instances or raises one
 		of the following exceptions:
-		- ImportError if submodule import fails,
-		- TypeError if no TestCase subclass is found in a submodule.
+		- ImportError if submodule import fails.
 		"""
+
 		for t in self.test_names:
+			# XXX: tests without a '.' in __init__?
 			modname, clsname = t.rsplit('.', 1)
 			modname = '%s.%s' % (self.modname, modname)
 			mod = __import__(modname, {}, {}, [clsname], 0)
@@ -76,9 +49,21 @@ def load_library(name):
 	"""
 
 	modname = 'PMSTestSuite.library.%s' % name
-	cls = list(grabmodule(modname, TestLibrary))
-	if len(cls) > 1:
-		raise TypeError('%s ambiguous - more than a single TestLibrary subclass found.'
+	mod = __import__(modname, {}, {}, ['.'], 0)
+
+	for k in dir(mod):
+		modvar = getattr(mod, k)
+		# the !issubclass() check is necessary to omit TestLibrary class
+		# imported for the subclass
+		try:
+			if issubclass(modvar, TestLibrary) and \
+					not issubclass(TestLibrary, modvar):
+				cls = modvar
+				break
+		except TypeError:
+			pass
+	else:
+		raise TypeError('Unable to find a TestLibrary subclass in %s'
 				% modname)
 
-	return cls[0](modname)
+	return cls(modname)



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/library/
@ 2011-05-23 11:52 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-05-23 11:52 UTC (permalink / raw
  To: gentoo-commits

commit:     a237c87d8da957b3d0a1904294b1645ba9204d91
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon May 23 11:52:08 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon May 23 11:52:08 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=a237c87d

Add a simple ebuild generation code.

---
 PMSTestSuite/library/__init__.py |    5 ++++-
 PMSTestSuite/library/case.py     |   36 +++++++++++++++++++++++++++++++++++-
 2 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/PMSTestSuite/library/__init__.py b/PMSTestSuite/library/__init__.py
index 8447d04..ba6867a 100644
--- a/PMSTestSuite/library/__init__.py
+++ b/PMSTestSuite/library/__init__.py
@@ -9,6 +9,8 @@
 >>> t = [x for x in l][0]
 >>> t # doctest: +ELLIPSIS
 <PMSTestSuite.library.test.random_test.ExampleCase object at ...>
+>>> t.get_output_files() # doctest: +ELLIPSIS
+{'pms-test/examplecase/examplecase-0.ebuild': ...}
 """
 
 from PMSTestSuite.library.case import TestCase
@@ -32,7 +34,8 @@ class TestLibrary(object):
 			modname = '%s.%s' % (self.modname, modname)
 			mod = __import__(modname, {}, {}, [clsname], 0)
 			cls = getattr(mod, clsname)
-			yield cls()
+			for i in cls.inst_all():
+				yield i
 
 	def __init__(self, modname):
 		self.modname = modname

diff --git a/PMSTestSuite/library/case.py b/PMSTestSuite/library/case.py
index 6eb3f09..f2115e2 100644
--- a/PMSTestSuite/library/case.py
+++ b/PMSTestSuite/library/case.py
@@ -2,10 +2,44 @@
 # (c) 2011 Michał Górny <mgorny@gentoo.org>
 # Released under the terms of the 2-clause BSD license.
 
+ebuild_header = '''# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: $
+
+inherit pms-test
+
+'''
+
 class TestCase(object):
 	""" Base class for a test case. """
 	pass
 
 class EbuildTestCase(TestCase):
 	""" Test case using a single ebuild (per EAPI). """
-	pass
+
+	@classmethod
+	def inst_all(cls, *args, **kwargs):
+		for eapi in cls.relevant_eapis:
+			kwargs['eapi'] = eapi
+			yield cls(*args, **kwargs)
+
+	def __init__(self, eapi):
+		self.eapi = eapi
+
+	def get_output_files(self):
+		pn = self.__class__.__name__.lower()
+		fn = 'pms-test/%s/%s-%s.ebuild' % (pn, pn, self.eapi)
+		contents = [ebuild_header]
+
+		for k, v in self.ebuild_vars.items():
+			contents.append('%s="%s"\n' % (k, v)) # XXX: escaping
+
+		for f, lines in self.phase_funcs.items():
+			if f == 'pkg_setup':
+				lines.insert(0, 'pms-test_pkg_setup')
+			contents.append('\n%s() {\n' % f)
+			for l in lines:
+				contents.append('\t%s\n' % l) # XXX: smarter tabs
+			contents.append('}\n')
+
+		return {fn: ''.join(contents)}



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/library/
@ 2011-05-24  8:11 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-05-24  8:11 UTC (permalink / raw
  To: gentoo-commits

commit:     f3554b599e4f59f2c31da7057b081689a02740d4
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue May 24 07:49:23 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue May 24 07:49:23 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=f3554b59

Use a class to lazily generate ebuild contents.

---
 PMSTestSuite/library/__init__.py |    4 +++-
 PMSTestSuite/library/case.py     |   34 +++++++++++++++++++++-------------
 2 files changed, 24 insertions(+), 14 deletions(-)

diff --git a/PMSTestSuite/library/__init__.py b/PMSTestSuite/library/__init__.py
index ba6867a..b127108 100644
--- a/PMSTestSuite/library/__init__.py
+++ b/PMSTestSuite/library/__init__.py
@@ -9,8 +9,10 @@
 >>> t = [x for x in l][0]
 >>> t # doctest: +ELLIPSIS
 <PMSTestSuite.library.test.random_test.ExampleCase object at ...>
->>> t.get_output_files() # doctest: +ELLIPSIS
+>>> files = t.get_output_files()
+>>> files # doctest: +ELLIPSIS
 {'pms-test/examplecase/examplecase-0.ebuild': ...}
+>>> f = files.values()[0]
 """
 
 from PMSTestSuite.library.case import TestCase

diff --git a/PMSTestSuite/library/case.py b/PMSTestSuite/library/case.py
index f2115e2..f6ae90b 100644
--- a/PMSTestSuite/library/case.py
+++ b/PMSTestSuite/library/case.py
@@ -27,19 +27,27 @@ class EbuildTestCase(TestCase):
 		self.eapi = eapi
 
 	def get_output_files(self):
-		pn = self.__class__.__name__.lower()
-		fn = 'pms-test/%s/%s-%s.ebuild' % (pn, pn, self.eapi)
-		contents = [ebuild_header]
+		class EbuildTestCaseEbuildFile(object):
+			def __init__(self, parent):
+				self._parent = parent
+
+			def __str__(self):
+				contents = [ebuild_header]
+
+				for k, v in self._parent.ebuild_vars.items():
+					contents.append('%s="%s"\n' % (k, v)) # XXX: escaping
 
-		for k, v in self.ebuild_vars.items():
-			contents.append('%s="%s"\n' % (k, v)) # XXX: escaping
+				for f, lines in self._parent.phase_funcs.items():
+					if f == 'pkg_setup':
+						lines.insert(0, 'pms-test_pkg_setup')
+					contents.append('\n%s() {\n' % f)
+					for l in lines:
+						contents.append('\t%s\n' % l) # XXX: smarter tabs
+					contents.append('}\n')
 
-		for f, lines in self.phase_funcs.items():
-			if f == 'pkg_setup':
-				lines.insert(0, 'pms-test_pkg_setup')
-			contents.append('\n%s() {\n' % f)
-			for l in lines:
-				contents.append('\t%s\n' % l) # XXX: smarter tabs
-			contents.append('}\n')
+				return ''.join(contents)
+
+		pn = self.__class__.__name__.lower()
+		fn = 'pms-test/%s/%s-%s.ebuild' % (pn, pn, self.eapi)
 
-		return {fn: ''.join(contents)}
+		return {fn: EbuildTestCaseEbuildFile(self)}



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/library/
@ 2011-05-24  8:11 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-05-24  8:11 UTC (permalink / raw
  To: gentoo-commits

commit:     a641f60b71f214376147384567d268d20dd18f5b
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue May 24 07:54:49 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue May 24 07:54:49 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=a641f60b

Add a minimal keyword-test for ebuild generation.

---
 PMSTestSuite/library/__init__.py |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/PMSTestSuite/library/__init__.py b/PMSTestSuite/library/__init__.py
index b127108..af7765f 100644
--- a/PMSTestSuite/library/__init__.py
+++ b/PMSTestSuite/library/__init__.py
@@ -13,6 +13,8 @@
 >>> files # doctest: +ELLIPSIS
 {'pms-test/examplecase/examplecase-0.ebuild': ...}
 >>> f = files.values()[0]
+>>> str(f) # doctest: +ELLIPSIS
+'# Copyright 1999...inherit pms-test...pms-test_pkg_setup...die...'
 """
 
 from PMSTestSuite.library.case import TestCase



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/library/
@ 2011-05-24  8:11 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-05-24  8:11 UTC (permalink / raw
  To: gentoo-commits

commit:     db82b2a77ea002c6a82da3a895e9f3dd8d2366a3
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue May 24 08:11:05 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue May 24 08:11:25 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=db82b2a7

Docs for PMSTestSuite.library.case.

---
 PMSTestSuite/library/case.py |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/PMSTestSuite/library/case.py b/PMSTestSuite/library/case.py
index f6ae90b..a3dcf4e 100644
--- a/PMSTestSuite/library/case.py
+++ b/PMSTestSuite/library/case.py
@@ -19,19 +19,35 @@ class EbuildTestCase(TestCase):
 
 	@classmethod
 	def inst_all(cls, *args, **kwargs):
+		"""
+		Instantiate the test case for all relevant EAPIs.
+
+		Returns an iterator over a list of test case instances.
+		"""
 		for eapi in cls.relevant_eapis:
 			kwargs['eapi'] = eapi
 			yield cls(*args, **kwargs)
 
 	def __init__(self, eapi):
+		""" Instiantate the test case for a particular EAPI. """
 		self.eapi = eapi
 
 	def get_output_files(self):
+		"""
+		Get a dict of files to output in the repository for the test case.
+		
+		Returns a dict with keys being filenames relative to the repository root
+		and associated values being classes evaluating to the file contents.
+		"""
 		class EbuildTestCaseEbuildFile(object):
+			""" Lazy ebuild contents evaluator for EbuildTestCase. """
 			def __init__(self, parent):
+				""" Instantiate the evaluator for test case <parent>. """
+				assert(isinstance(parent, EbuildTestCase))
 				self._parent = parent
 
 			def __str__(self):
+				""" Return the ebuild contents as string. """
 				contents = [ebuild_header]
 
 				for k, v in self._parent.ebuild_vars.items():



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/library/
@ 2011-05-24 14:28 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-05-24 14:28 UTC (permalink / raw
  To: gentoo-commits

commit:     f649f284cb33e439fc47b8d7014e78d98bb20a56
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue May 24 14:27:44 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue May 24 14:27:44 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=f649f284

Fix mutating phase func lines.

---
 PMSTestSuite/library/case.py |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/PMSTestSuite/library/case.py b/PMSTestSuite/library/case.py
index a3dcf4e..05cd99e 100644
--- a/PMSTestSuite/library/case.py
+++ b/PMSTestSuite/library/case.py
@@ -54,9 +54,9 @@ class EbuildTestCase(TestCase):
 					contents.append('%s="%s"\n' % (k, v)) # XXX: escaping
 
 				for f, lines in self._parent.phase_funcs.items():
-					if f == 'pkg_setup':
-						lines.insert(0, 'pms-test_pkg_setup')
 					contents.append('\n%s() {\n' % f)
+					if f == 'pkg_setup':
+						contents.append('\tpms-test_pkg_setup\n')
 					for l in lines:
 						contents.append('\t%s\n' % l) # XXX: smarter tabs
 					contents.append('}\n')



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/library/
@ 2011-05-25 20:40 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-05-25 20:40 UTC (permalink / raw
  To: gentoo-commits

commit:     fd6f6f613a327d4fcd757944c1871d7e14f3d90c
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed May 25 20:34:26 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed May 25 20:34:26 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=fd6f6f61

Declare phase funcs by default.

---
 PMSTestSuite/library/case.py |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/PMSTestSuite/library/case.py b/PMSTestSuite/library/case.py
index 05cd99e..9e72a2d 100644
--- a/PMSTestSuite/library/case.py
+++ b/PMSTestSuite/library/case.py
@@ -17,6 +17,12 @@ class TestCase(object):
 class EbuildTestCase(TestCase):
 	""" Test case using a single ebuild (per EAPI). """
 
+	phase_funcs = dict([(func, []) for func in (
+		'pkg_pretend', 'pkg_setup', 'src_unpack', 'src_prepare',
+		'src_configure', 'src_compile', 'src_install',
+		'pkg_preinst', 'pkg_postinst'
+		)])
+
 	@classmethod
 	def inst_all(cls, *args, **kwargs):
 		"""
@@ -54,6 +60,9 @@ class EbuildTestCase(TestCase):
 					contents.append('%s="%s"\n' % (k, v)) # XXX: escaping
 
 				for f, lines in self._parent.phase_funcs.items():
+					if not lines:
+						continue
+
 					contents.append('\n%s() {\n' % f)
 					if f == 'pkg_setup':
 						contents.append('\tpms-test_pkg_setup\n')



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/library/
@ 2011-05-26  6:35 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-05-26  6:35 UTC (permalink / raw
  To: gentoo-commits

commit:     9fb404f9c26c3007e158d5f597f03b0491b973fa
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu May 26 06:19:48 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu May 26 06:19:48 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=9fb404f9

Fix mutating shared phase funcs.

---
 PMSTestSuite/library/case.py  |   13 +++++++------
 PMSTestSuite/library/standard |    2 +-
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/PMSTestSuite/library/case.py b/PMSTestSuite/library/case.py
index 9e72a2d..084edd8 100644
--- a/PMSTestSuite/library/case.py
+++ b/PMSTestSuite/library/case.py
@@ -2,6 +2,13 @@
 # (c) 2011 Michał Górny <mgorny@gentoo.org>
 # Released under the terms of the 2-clause BSD license.
 
+# XXX: move to some consts module?
+phase_func_names = [
+	'pkg_pretend', 'pkg_setup', 'src_unpack', 'src_prepare',
+	'src_configure', 'src_compile', 'src_install',
+	'pkg_preinst', 'pkg_postinst'
+]
+
 ebuild_header = '''# Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 # $Header: $
@@ -17,12 +24,6 @@ class TestCase(object):
 class EbuildTestCase(TestCase):
 	""" Test case using a single ebuild (per EAPI). """
 
-	phase_funcs = dict([(func, []) for func in (
-		'pkg_pretend', 'pkg_setup', 'src_unpack', 'src_prepare',
-		'src_configure', 'src_compile', 'src_install',
-		'pkg_preinst', 'pkg_postinst'
-		)])
-
 	@classmethod
 	def inst_all(cls, *args, **kwargs):
 		"""

diff --git a/PMSTestSuite/library/standard b/PMSTestSuite/library/standard
index a678eb2..ec868c9 160000
--- a/PMSTestSuite/library/standard
+++ b/PMSTestSuite/library/standard
@@ -1 +1 @@
-Subproject commit a678eb23b92b05685552da6a09642d14fdc38972
+Subproject commit ec868c966605b4d333240c27ed86811c1d154406



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/library/
@ 2011-05-26  7:25 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-05-26  7:25 UTC (permalink / raw
  To: gentoo-commits

commit:     8a0fabc3d56d57f69f86643d2add3ce535e9bd0d
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu May 26 07:22:23 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu May 26 07:22:23 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=8a0fabc3

Move class name -> PM code into separate function.

---
 PMSTestSuite/library/case.py |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/PMSTestSuite/library/case.py b/PMSTestSuite/library/case.py
index 2908342..02a3b9f 100644
--- a/PMSTestSuite/library/case.py
+++ b/PMSTestSuite/library/case.py
@@ -21,6 +21,15 @@ inherit pms-test
 
 pn_re = re.compile('(.)([A-Z])')
 
+def cleanup_test_case_name(classname):
+	"""
+	Create the ebuild PN from <classname>.
+	"""
+
+	if classname.endswith('Test'):
+		classname = classname[:-4]
+	return pn_re.sub('\\1-\\2', classname).lower()
+
 class TestCase(object):
 	""" Base class for a test case. """
 	pass
@@ -77,10 +86,7 @@ class EbuildTestCase(TestCase):
 
 				return ''.join(contents)
 
-		pn = self.__class__.__name__
-		if pn.endswith('Test'):
-			pn = pn[:-4]
-		pn = pn_re.sub('\\1-\\2', pn).lower()
+		pn = cleanup_test_case_name(self.__class__.__name__)
 		fn = 'pms-test/%s/%s-%s.ebuild' % (pn, pn, self.eapi)
 
 		return {fn: EbuildTestCaseEbuildFile(self)}



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/library/
@ 2011-05-29 18:17 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-05-29 18:17 UTC (permalink / raw
  To: gentoo-commits

commit:     3db0ba1d928414bedb4e697ff79464d59ab8a783
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun May 29 18:14:11 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun May 29 18:14:11 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=3db0ba1d

Initialize PN for test earlier and store it.

---
 PMSTestSuite/library/case.py |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/PMSTestSuite/library/case.py b/PMSTestSuite/library/case.py
index 120b71c..a9b27d3 100644
--- a/PMSTestSuite/library/case.py
+++ b/PMSTestSuite/library/case.py
@@ -60,6 +60,7 @@ class EbuildTestCase(TestCase):
 	def __init__(self, eapi):
 		""" Instiantate the test case for a particular EAPI. """
 		self.eapi = eapi
+		self.pn = cleanup_test_case_name(self.__class__.__name__)
 
 	def get_output_files(self):
 		"""
@@ -95,7 +96,7 @@ class EbuildTestCase(TestCase):
 
 				return ''.join(contents)
 
-		pn = cleanup_test_case_name(self.__class__.__name__)
+		pn = self.pn
 		fn = 'pms-test/%s/%s-%s.ebuild' % (pn, pn, self.eapi)
 
 		return {fn: EbuildTestCaseEbuildFile(self)}



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/library/
@ 2011-05-29 18:57 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-05-29 18:57 UTC (permalink / raw
  To: gentoo-commits

commit:     5337c280c32ad6534c713adc5047920014c5a6a3
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun May 29 18:32:49 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun May 29 18:32:49 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=5337c280

Cache instantiated tests.

---
 PMSTestSuite/library/__init__.py |   25 +++++++++++++++++--------
 1 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/PMSTestSuite/library/__init__.py b/PMSTestSuite/library/__init__.py
index 52aa8d2..a473888 100644
--- a/PMSTestSuite/library/__init__.py
+++ b/PMSTestSuite/library/__init__.py
@@ -22,6 +22,8 @@ from PMSTestSuite.library.case import TestCase
 class TestLibrary(object):
 	""" Base class for a test library. """
 
+	tests = None
+
 	def __iter__(self):
 		"""
 		Iterate over all the tests in a test library, loading its modules
@@ -32,14 +34,21 @@ class TestLibrary(object):
 		- ImportError if submodule import fails.
 		"""
 
-		for t in self.test_names:
-			# XXX: tests without a '.' in __init__?
-			modname, clsname = t.rsplit('.', 1)
-			modname = '%s.%s' % (self.modname, modname)
-			mod = __import__(modname, {}, {}, [clsname], 0)
-			cls = getattr(mod, clsname)
-			for i in cls.inst_all():
-				yield i
+		if self.tests is not None:
+			# tests already instantiated
+			for t in self.tests:
+				yield t
+		else:
+			self.tests = []
+			for t in self.test_names:
+				# XXX: tests without a '.' in __init__?
+				modname, clsname = t.rsplit('.', 1)
+				modname = '%s.%s' % (self.modname, modname)
+				mod = __import__(modname, {}, {}, [clsname], 0)
+				cls = getattr(mod, clsname)
+				for i in cls.inst_all():
+					self.tests.append(i)
+					yield i
 
 	def __init__(self, modname):
 		self.modname = modname



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/library/
@ 2011-05-29 18:57 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-05-29 18:57 UTC (permalink / raw
  To: gentoo-commits

commit:     d817e9ddcfec5a573f5be2f61b41d731de299445
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun May 29 18:32:16 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun May 29 18:32:16 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=d817e9dd

Set EbuildTestCase.p as well.

---
 PMSTestSuite/library/case.py |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/PMSTestSuite/library/case.py b/PMSTestSuite/library/case.py
index a9b27d3..1f8cf43 100644
--- a/PMSTestSuite/library/case.py
+++ b/PMSTestSuite/library/case.py
@@ -61,6 +61,7 @@ class EbuildTestCase(TestCase):
 		""" Instiantate the test case for a particular EAPI. """
 		self.eapi = eapi
 		self.pn = cleanup_test_case_name(self.__class__.__name__)
+		self.p = '%s-%s' % (self.pn, eapi)
 
 	def get_output_files(self):
 		"""
@@ -96,7 +97,6 @@ class EbuildTestCase(TestCase):
 
 				return ''.join(contents)
 
-		pn = self.pn
-		fn = 'pms-test/%s/%s-%s.ebuild' % (pn, pn, self.eapi)
+		fn = 'pms-test/%s/%s.ebuild' % (self.pn, self.p)
 
 		return {fn: EbuildTestCaseEbuildFile(self)}



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/library/
@ 2011-05-29 18:57 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-05-29 18:57 UTC (permalink / raw
  To: gentoo-commits

commit:     8c73247fd7fe389dba9edd6cab2a436ef3a0c2d9
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun May 29 18:57:12 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun May 29 18:57:12 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=8c73247f

Output EAPI in ebuilds.

---
 PMSTestSuite/library/case.py |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/PMSTestSuite/library/case.py b/PMSTestSuite/library/case.py
index 1f8cf43..103d822 100644
--- a/PMSTestSuite/library/case.py
+++ b/PMSTestSuite/library/case.py
@@ -15,6 +15,8 @@ ebuild_header = '''# Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 # $Header: $
 
+EAPI=%d
+
 inherit pms-test
 
 '''
@@ -79,7 +81,7 @@ class EbuildTestCase(TestCase):
 
 			def __str__(self):
 				""" Return the ebuild contents as string. """
-				contents = [ebuild_header]
+				contents = [ebuild_header % self._parent.eapi]
 
 				for k, v in self._parent.ebuild_vars.items():
 					contents.append('%s="%s"\n' % (k, v)) # XXX: escaping



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/library/
@ 2011-05-31 17:19 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-05-31 17:19 UTC (permalink / raw
  To: gentoo-commits

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

Update the library to use D-Bus.

---
 PMSTestSuite/library/standard |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/PMSTestSuite/library/standard b/PMSTestSuite/library/standard
index ec868c9..1be532a 160000
--- a/PMSTestSuite/library/standard
+++ b/PMSTestSuite/library/standard
@@ -1 +1 @@
-Subproject commit ec868c966605b4d333240c27ed86811c1d154406
+Subproject commit 1be532a0d975ec2aebefc6e8bd6369b7b0e5146d



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/library/
@ 2011-06-03 17:36 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-06-03 17:36 UTC (permalink / raw
  To: gentoo-commits

commit:     9897ef14df1f728247856ecf17ee145fcaf18528
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Jun  3 17:29:26 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Jun  3 17:29:26 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=9897ef14

Support specifying additional inherits for test cases.

---
 PMSTestSuite/library/case.py |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/PMSTestSuite/library/case.py b/PMSTestSuite/library/case.py
index 8d70f93..30fd819 100644
--- a/PMSTestSuite/library/case.py
+++ b/PMSTestSuite/library/case.py
@@ -17,7 +17,7 @@ ebuild_header = '''# Copyright 1999-2011 Gentoo Foundation
 
 EAPI=%d
 
-inherit pms-test
+inherit %s
 
 '''
 
@@ -50,12 +50,16 @@ class EbuildTestCase(TestCase):
 	Test case using a single ebuild (per EAPI).
 	
 	Properties:
+	- ebuild_vars - additional global variables (a list),
 	- expect_failure - if set to False (the default), the test is supposed
 		to merge successfully. Otherwise, the test ebuild is supposed to fail
-		to merge (die).
+		to merge (die),
+	- inherits - additional eclasses to inherit (a list),
+	- phase_funcs - phase function contents (a dict of lists).
 	"""
 
 	expect_failure = False
+	inherits = []
 
 	@classmethod
 	def inst_all(cls, *args, **kwargs):
@@ -95,7 +99,8 @@ class EbuildTestCase(TestCase):
 
 			def __str__(self):
 				""" Return the ebuild contents as string. """
-				contents = [ebuild_header % self._parent.eapi]
+				contents = [ebuild_header % (self._parent.eapi,
+					' '.join(['pms-test'] + self._parent.inherits))]
 
 				for k, v in self._parent.ebuild_vars.items():
 					contents.append('%s="%s"\n' % (k, v)) # XXX: escaping



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/library/
@ 2011-06-07 17:22 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-06-07 17:22 UTC (permalink / raw
  To: gentoo-commits

commit:     b3632fa191a094b8e6f0212b6d0d29f0597ffe4c
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Jun  7 17:22:25 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Jun  7 17:22:25 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=b3632fa1

Don't expect pms-test_pkg_setup anymore.

---
 PMSTestSuite/library/__init__.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/PMSTestSuite/library/__init__.py b/PMSTestSuite/library/__init__.py
index bcf8f6f..545a211 100644
--- a/PMSTestSuite/library/__init__.py
+++ b/PMSTestSuite/library/__init__.py
@@ -14,7 +14,7 @@
 {'pms-test/random-example/random-example-0.ebuild': ...}
 >>> f = files.values()[0]
 >>> str(f) # doctest: +ELLIPSIS
-'# Copyright 1999...inherit pms-test...pms-test_pkg_setup...die...'
+'# Copyright 1999...inherit pms-test...die...'
 """
 
 from PMSTestSuite.library.case import TestCase



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/library/
@ 2011-06-13 19:16 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-06-13 19:16 UTC (permalink / raw
  To: gentoo-commits

commit:     4848a6e5cf8b0d5a76badd80f04d76aa0aa7cf0b
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Jun 13 18:53:31 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Jun 13 18:53:31 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=4848a6e5

Copy test lists and dicts when instantiating.

This way, we can avoid sharing data between different instances
of the test class and make modifying it much easier.

---
 PMSTestSuite/library/case.py |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/PMSTestSuite/library/case.py b/PMSTestSuite/library/case.py
index d063ce3..5f58b41 100644
--- a/PMSTestSuite/library/case.py
+++ b/PMSTestSuite/library/case.py
@@ -2,7 +2,7 @@
 # (c) 2011 Michał Górny <mgorny@gentoo.org>
 # Released under the terms of the 2-clause BSD license.
 
-import re
+import copy, re
 
 # XXX: move to some consts module?
 phase_func_names = [
@@ -50,16 +50,21 @@ class EbuildTestCase(TestCase):
 	Test case using a single ebuild (per EAPI).
 	
 	Properties:
-	- ebuild_vars - additional global variables (a list),
+	- ebuild_vars - additional global variables (a dict of strings),
 	- expect_failure - if set to False (the default), the test is supposed
 		to merge successfully. Otherwise, the test ebuild is supposed to fail
 		to merge (die),
-	- inherits - additional eclasses to inherit (a list),
+	- inherits - additional eclasses to inherit (a list of strings),
 	- phase_funcs - phase function contents (a dict of lists).
+
+	The __init__() function is going to clone (deepcopy()) all the above
+	properties to allow modifying instance variables easily.
 	"""
 
+	ebuild_vars = {}
 	expect_failure = False
 	inherits = []
+	phase_funcs = {}
 
 	@classmethod
 	def inst_all(cls, *args, **kwargs):
@@ -83,6 +88,9 @@ class EbuildTestCase(TestCase):
 		self.pn = cleanup_test_case_name(self.__class__.__name__)
 		self.p = '%s-%s' % (self.pn, eapi)
 
+		for v in ('ebuild_vars', 'inherits', 'phase_funcs'):
+			setattr(self, v, copy.deepcopy(getattr(self, v)))
+
 	def get_output_files(self):
 		"""
 		Get a dict of files to output in the repository for the test case.



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/library/
@ 2011-06-13 19:16 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-06-13 19:16 UTC (permalink / raw
  To: gentoo-commits

commit:     3d16982edcdd1b9de22cec32fde91645a1e6378f
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Jun 13 19:07:52 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Jun 13 19:08:18 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=3d16982e

Add dependency output files to EbuildDependencyTestCases.

---
 PMSTestSuite/library/depend_case.py |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/PMSTestSuite/library/depend_case.py b/PMSTestSuite/library/depend_case.py
index 9e83f81..34de0bf 100644
--- a/PMSTestSuite/library/depend_case.py
+++ b/PMSTestSuite/library/depend_case.py
@@ -39,3 +39,10 @@ class EbuildDependencyTestCase(EbuildTestCase):
 				self.ebuild_vars[v] = ''
 			for o in obj_list:
 				self.ebuild_vars[v] += '\n\t=%s' % o.cpv
+
+	def get_output_files(self):
+		of = EbuildTestCase.get_output_files(self)
+		for o in self.depend_objs + self.rdepend_objs:
+			of.update(o.get_output_files())
+
+		return of



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/library/
@ 2011-06-14  8:32 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-06-14  8:32 UTC (permalink / raw
  To: gentoo-commits

commit:     0ab45433e1c2e28a592f4c2101a7c9f6a82a2277
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 14 07:23:21 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Jun 14 07:26:07 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=0ab45433

Support test case object finalization.

This allows superclasses to perform additional modifications or checks
before outputting the files.

---
 PMSTestSuite/library/case.py |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/PMSTestSuite/library/case.py b/PMSTestSuite/library/case.py
index d3e1126..291149b 100644
--- a/PMSTestSuite/library/case.py
+++ b/PMSTestSuite/library/case.py
@@ -43,7 +43,13 @@ def cleanup_test_case_name(classname):
 
 class TestCase(object):
 	""" Base class for a test case. """
-	pass
+
+	def _finalize(self):
+		"""
+		Do any final modifications to test case data. Mark it finalized.
+		This function shall be called at most once per object.
+		"""
+		self._finalized = True
 
 class EbuildTestCase(TestCase):
 	"""
@@ -66,6 +72,8 @@ class EbuildTestCase(TestCase):
 	inherits = []
 	phase_funcs = {}
 
+	_finalized = False
+
 	@classmethod
 	def inst_all(cls, *args, **kwargs):
 		"""
@@ -127,6 +135,9 @@ class EbuildTestCase(TestCase):
 
 				return ''.join(contents)
 
+		if not self._finalized:
+			self._finalize()
+
 		fn = 'pms-test/%s/%s.ebuild' % (self.pn, self.p)
 
 		return {fn: EbuildTestCaseEbuildFile(self)}



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/library/
@ 2011-06-14  8:32 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-06-14  8:32 UTC (permalink / raw
  To: gentoo-commits

commit:     081caddccff7b449226277e6aa9cb34da7b96164
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 14 07:16:09 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Jun 14 07:16:09 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=081caddc

Create empty phase functions for convenience.

---
 PMSTestSuite/library/case.py |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/PMSTestSuite/library/case.py b/PMSTestSuite/library/case.py
index 5f58b41..d3e1126 100644
--- a/PMSTestSuite/library/case.py
+++ b/PMSTestSuite/library/case.py
@@ -90,6 +90,9 @@ class EbuildTestCase(TestCase):
 
 		for v in ('ebuild_vars', 'inherits', 'phase_funcs'):
 			setattr(self, v, copy.deepcopy(getattr(self, v)))
+		for pf in phase_func_names:
+			if pf not in self.phase_funcs:
+				self.phase_funcs[pf] = []
 
 	def get_output_files(self):
 		"""



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/library/
@ 2011-06-14 12:35 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-06-14 12:35 UTC (permalink / raw
  To: gentoo-commits

commit:     2aec55d843e01e7eef52d867e174a69faf3e19ce
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 14 12:09:13 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Jun 14 12:09:13 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=2aec55d8

Use properties to get EbuildTestCase PN/PV/P.

---
 PMSTestSuite/library/case.py |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/PMSTestSuite/library/case.py b/PMSTestSuite/library/case.py
index 33f66ac..8430d21 100644
--- a/PMSTestSuite/library/case.py
+++ b/PMSTestSuite/library/case.py
@@ -91,6 +91,18 @@ class EbuildTestCase(TestCase):
 			yield cls(*args, **kwargs)
 
 	@property
+	def pn(self):
+		return cleanup_test_case_name(self.__class__.__name__)
+
+	@property
+	def pv(self):
+		return self.eapi
+
+	@property
+	def p(self):
+		return '%s-%s' % (self.pn, self.pv)
+
+	@property
 	def cpv(self):
 		""" Return CPV for the test. """
 		return 'pms-test/%s' % self.p
@@ -98,8 +110,6 @@ class EbuildTestCase(TestCase):
 	def __init__(self, eapi):
 		""" Instiantate the test case for a particular EAPI. """
 		self.eapi = eapi
-		self.pn = cleanup_test_case_name(self.__class__.__name__)
-		self.p = '%s-%s' % (self.pn, eapi)
 
 		for v in ('ebuild_vars', 'inherits', 'phase_funcs'):
 			setattr(self, v, copy.deepcopy(getattr(self, v)))



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/library/
@ 2011-06-16 19:49 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-06-16 19:49 UTC (permalink / raw
  To: gentoo-commits

commit:     4ce7a1639489bd5e6777548b9a89c9d8d91012a4
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 16 19:30:16 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Jun 16 19:30:16 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=4ce7a163

Support grabbing test count through len(test_library).

---
 PMSTestSuite/library/__init__.py |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/PMSTestSuite/library/__init__.py b/PMSTestSuite/library/__init__.py
index fe045f9..3c7f6b1 100644
--- a/PMSTestSuite/library/__init__.py
+++ b/PMSTestSuite/library/__init__.py
@@ -52,6 +52,14 @@ class TestLibrary(object):
 					self.tests.append(i)
 					yield i
 
+	def __len__(self):
+		if self.tests is None:
+			# pre-init, shouldn't be needed
+			for t in self:
+				pass
+
+		return len(self.tests)
+
 	def __init__(self, modname):
 		self.modname = modname
 



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/library/
@ 2011-06-16 19:49 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-06-16 19:49 UTC (permalink / raw
  To: gentoo-commits

commit:     cbca0a6305bd26c900d883e9ba4115a726662582
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 16 19:39:14 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Jun 16 19:39:14 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=cbca0a63

Set DESCRIPTION in _finalize() only for ebuild cases.

---
 PMSTestSuite/library/case.py |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/PMSTestSuite/library/case.py b/PMSTestSuite/library/case.py
index 8328a5f..d16cedd 100644
--- a/PMSTestSuite/library/case.py
+++ b/PMSTestSuite/library/case.py
@@ -44,6 +44,8 @@ def cleanup_test_case_name(classname):
 class TestCase(object):
 	""" Base class for a test case. """
 
+	_finalized = False
+
 	def _finalize(self):
 		"""
 		Do any final modifications to test case data. Mark it finalized.
@@ -51,11 +53,6 @@ class TestCase(object):
 		"""
 		self._finalized = True
 
-		if 'DESCRIPTION' not in self.ebuild_vars:
-			descdoc = ' '.join(self.__doc__.split())
-
-			self.ebuild_vars['DESCRIPTION'] = descdoc.rstrip('.')
-
 	def clean(self, pm):
 		"""
 		Schedule cleaning the test using PackageManager instance <pm>.
@@ -99,8 +96,6 @@ class EbuildTestCase(TestCase):
 	inherits = []
 	phase_funcs = {}
 
-	_finalized = False
-
 	@classmethod
 	def inst_all(cls, *args, **kwargs):
 		"""
@@ -129,6 +124,14 @@ class EbuildTestCase(TestCase):
 		""" Return CPV for the test. """
 		return 'pms-test/%s' % self.p
 
+	def _finalize(self):
+		TestCase._finalize(self)
+
+		if 'DESCRIPTION' not in self.ebuild_vars:
+			descdoc = ' '.join(self.__doc__.split())
+
+			self.ebuild_vars['DESCRIPTION'] = descdoc.rstrip('.')
+
 	def __init__(self, eapi):
 		""" Instiantate the test case for a particular EAPI. """
 		self.eapi = eapi



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/library/
@ 2011-06-17  5:59 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-06-17  5:59 UTC (permalink / raw
  To: gentoo-commits

commit:     5788660e337207a42b0aa7562bc7e8dd1b176591
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Jun 17 05:52:14 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Jun 17 05:52:14 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=5788660e

Unmerge test dependencies as well.

---
 PMSTestSuite/library/depend_case.py |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/PMSTestSuite/library/depend_case.py b/PMSTestSuite/library/depend_case.py
index 34de0bf..e474010 100644
--- a/PMSTestSuite/library/depend_case.py
+++ b/PMSTestSuite/library/depend_case.py
@@ -40,6 +40,11 @@ class EbuildDependencyTestCase(EbuildTestCase):
 			for o in obj_list:
 				self.ebuild_vars[v] += '\n\t=%s' % o.cpv
 
+	def clean(self, pm):
+		EbuildTestCase.clean(self, pm)
+		for o in self.depend_objs + self.rdepend_objs:
+			o.clean(pm)
+
 	def get_output_files(self):
 		of = EbuildTestCase.get_output_files(self)
 		for o in self.depend_objs + self.rdepend_objs:



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/library/
@ 2011-06-17 15:07 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-06-17 15:07 UTC (permalink / raw
  To: gentoo-commits

commit:     9ff1355f482b6bf6301c09c8da136f55ec5cc163
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Jun 17 15:00:33 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Jun 17 15:00:33 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=9ff1355f

Use dependant test results to determine the dependency test result.

---
 PMSTestSuite/library/depend_case.py |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/PMSTestSuite/library/depend_case.py b/PMSTestSuite/library/depend_case.py
index e474010..c7a7c56 100644
--- a/PMSTestSuite/library/depend_case.py
+++ b/PMSTestSuite/library/depend_case.py
@@ -51,3 +51,9 @@ class EbuildDependencyTestCase(EbuildTestCase):
 			of.update(o.get_output_files())
 
 		return of
+
+	def check_result(self, pm):
+		res = EbuildTestCase.check_result(self, pm)
+		for o in self.depend_objs + self.rdepend_objs:
+			res &= o.check_result(pm)
+		return res



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/library/
@ 2011-06-20 19:20 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-06-20 19:20 UTC (permalink / raw
  To: gentoo-commits

commit:     1f52e33b1425eec4f65dfc61b69b84938feaac87
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Jun 20 19:09:42 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Jun 20 19:09:42 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=1f52e33b

Declare get_output_files() in TestCase.

---
 PMSTestSuite/library/case.py |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/PMSTestSuite/library/case.py b/PMSTestSuite/library/case.py
index 4126c26..dc33e99 100644
--- a/PMSTestSuite/library/case.py
+++ b/PMSTestSuite/library/case.py
@@ -53,6 +53,15 @@ class TestCase(object):
 		"""
 		self._finalized = True
 
+	def get_output_files(self):
+		"""
+		Get a dict of files to output in the repository for the test case.
+		
+		Returns a dict with keys being filenames relative to the repository root
+		and associated values evaluating to a file contents (as strings).
+		"""
+		raise NotImplementedError('Please override TestCase.get_output_files()')
+
 	def clean(self, pm):
 		"""
 		Schedule cleaning the test using PackageManager instance <pm>.



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/library/
@ 2011-06-23 21:14 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-06-23 21:14 UTC (permalink / raw
  To: gentoo-commits

commit:     d18c788c123ecd352ff76d12fb062fb5d096d1ea
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 23 21:04:46 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Jun 23 21:04:46 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=d18c788c

EbuildDependencyTestCase: support PDEPEND as well.

---
 PMSTestSuite/library/depend_case.py |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/PMSTestSuite/library/depend_case.py b/PMSTestSuite/library/depend_case.py
index ca111fb..5d80d3c 100644
--- a/PMSTestSuite/library/depend_case.py
+++ b/PMSTestSuite/library/depend_case.py
@@ -21,6 +21,7 @@ class EbuildDependencyTestCase(EbuildTestCase):
 
 	depend_classes = []
 	rdepend_classes = []
+	pdepend_classes = []
 
 	def __init__(self, eapi):
 		EbuildTestCase.__init__(self, eapi)
@@ -28,7 +29,8 @@ class EbuildDependencyTestCase(EbuildTestCase):
 		self.dependant_ebuilds = []
 
 		for class_list, v in ((self.depend_classes, 'DEPEND'),
-				(self.rdepend_classes, 'RDEPEND')):
+				(self.rdepend_classes, 'RDEPEND'),
+				(self.pdepend_classes, 'PDEPEND')):
 			if v not in self.ebuild_vars:
 				self.ebuild_vars[v] = ''
 



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/library/
@ 2011-06-23 21:14 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-06-23 21:14 UTC (permalink / raw
  To: gentoo-commits

commit:     12662825666c17d462e20d5610af926c0cea1db4
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 23 21:12:13 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Jun 23 21:12:13 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=12662825

Fix adding a hyphen between two capital letters.

---
 PMSTestSuite/library/case.py |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/PMSTestSuite/library/case.py b/PMSTestSuite/library/case.py
index 8d222df..9a0b37a 100644
--- a/PMSTestSuite/library/case.py
+++ b/PMSTestSuite/library/case.py
@@ -23,7 +23,7 @@ inherit %s
 
 '''
 
-pn_re = re.compile('(.)([A-Z])')
+pn_re = re.compile('([^A-Z])([A-Z])')
 
 def cleanup_test_case_name(classname):
 	"""
@@ -37,6 +37,8 @@ def cleanup_test_case_name(classname):
 	'test-zor'
 	>>> cleanup_test_case_name('veryRandomCamelCaseTest')
 	'very-random-camel-case'
+	>>> cleanup_test_case_name('RDependTest')
+	'rdepend'
 	"""
 
 	if classname.endswith('Test'):



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/library/
@ 2011-06-29 17:52 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-06-29 17:52 UTC (permalink / raw
  To: gentoo-commits

commit:     34e2d2cb95110c1155a96f385db7d95b93d942e5
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 29 17:05:40 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Jun 29 17:05:40 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=34e2d2cb

Set defaults for supported_ and relevant_eapis.

---
 pmstestsuite/library/case.py |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/pmstestsuite/library/case.py b/pmstestsuite/library/case.py
index 0843677..e87f15d 100644
--- a/pmstestsuite/library/case.py
+++ b/pmstestsuite/library/case.py
@@ -2,7 +2,7 @@
 # (c) 2011 Michał Górny <mgorny@gentoo.org>
 # Released under the terms of the 2-clause BSD license.
 
-import copy, re
+import copy, random, re
 
 from abc import ABCMeta, abstractmethod, abstractproperty
 
@@ -118,12 +118,12 @@ class EbuildTestCase(TestCase):
 	def supported_eapis(self):
 		"""
 		A list of EAPIs for which the test is able to run and gives
-		predictible results.
+		predictible results. Defaults to all available EAPIs.
 
 		For example, if a feature is required in EAPI 3+ and optional
 		in earlier EAPIs, this variable should contain (3,4).
 		"""
-		pass
+		return (0, 1, 2, 3, 4)
 
 	@property
 	def relevant_eapis(self):
@@ -131,8 +131,10 @@ class EbuildTestCase(TestCase):
 		A list of EAPIs for which the test should be run by default (in
 		non-thorough mode). This should list all the EAPIs where
 		a change of behaviour occurs.
+
+		When unset, defaults to a random element of .supported_eapis().
 		"""
-		pass
+		return random.choice(self.supported_eapis)
 
 	@classmethod
 	def inst_all(cls, *args, **kwargs):



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/library/
@ 2011-06-29 17:52 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-06-29 17:52 UTC (permalink / raw
  To: gentoo-commits

commit:     4b45ef360b363c7fc472e6d746ee68e70ee61837
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 29 17:30:32 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Jun 29 17:32:35 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=4b45ef36

Support grabbing relevant_ and supported_eapis from a prop.

As Python doesn't supply us with class properties, we need a little
function to handle transforming them as necessary. Hopefully it won't be
an ugly hack as it uses the property object public API.

---
 pmstestsuite/library/case.py |   23 +++++++++++++++++++----
 1 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/pmstestsuite/library/case.py b/pmstestsuite/library/case.py
index e87f15d..3ab5197 100644
--- a/pmstestsuite/library/case.py
+++ b/pmstestsuite/library/case.py
@@ -114,8 +114,20 @@ class EbuildTestCase(TestCase):
 	inherits = []
 	phase_funcs = {}
 
+	@classmethod
+	def _eval_prop(cls, prop_or_obj):
+		"""
+		Evaluate and return the value of a property when passed a property
+		object, or return the passed value otherwise.
+		"""
+
+		if isinstance(prop_or_obj, property):
+			return prop_or_obj.fget(cls)
+		else:
+			return prop_or_obj
+
 	@property
-	def supported_eapis(self):
+	def supported_eapis(cls):
 		"""
 		A list of EAPIs for which the test is able to run and gives
 		predictible results. Defaults to all available EAPIs.
@@ -126,7 +138,7 @@ class EbuildTestCase(TestCase):
 		return (0, 1, 2, 3, 4)
 
 	@property
-	def relevant_eapis(self):
+	def relevant_eapis(cls):
 		"""
 		A list of EAPIs for which the test should be run by default (in
 		non-thorough mode). This should list all the EAPIs where
@@ -134,7 +146,7 @@ class EbuildTestCase(TestCase):
 
 		When unset, defaults to a random element of .supported_eapis().
 		"""
-		return random.choice(self.supported_eapis)
+		return (random.choice(cls._eval_prop(cls.supported_eapis)),)
 
 	@classmethod
 	def inst_all(cls, *args, **kwargs):
@@ -143,7 +155,10 @@ class EbuildTestCase(TestCase):
 
 		Returns an iterator over a list of test case instances.
 		"""
-		for eapi in cls.relevant_eapis:
+
+		# sadly, no @classproperty
+		# but property object attributes are official
+		for eapi in cls._eval_prop(cls.relevant_eapis):
 			kwargs['eapi'] = eapi
 			yield cls(*args, **kwargs)
 



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/library/
@ 2011-06-29 17:52 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-06-29 17:52 UTC (permalink / raw
  To: gentoo-commits

commit:     3c8e1b589caf1b71b68bc7516711e7e10bcd3e4c
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 29 16:57:41 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Jun 29 16:57:41 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=3c8e1b58

Add supported_eapis variable for EbuildTestCase.

---
 pmstestsuite/library/case.py |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/pmstestsuite/library/case.py b/pmstestsuite/library/case.py
index 9a0b37a..0843677 100644
--- a/pmstestsuite/library/case.py
+++ b/pmstestsuite/library/case.py
@@ -114,6 +114,26 @@ class EbuildTestCase(TestCase):
 	inherits = []
 	phase_funcs = {}
 
+	@property
+	def supported_eapis(self):
+		"""
+		A list of EAPIs for which the test is able to run and gives
+		predictible results.
+
+		For example, if a feature is required in EAPI 3+ and optional
+		in earlier EAPIs, this variable should contain (3,4).
+		"""
+		pass
+
+	@property
+	def relevant_eapis(self):
+		"""
+		A list of EAPIs for which the test should be run by default (in
+		non-thorough mode). This should list all the EAPIs where
+		a change of behaviour occurs.
+		"""
+		pass
+
 	@classmethod
 	def inst_all(cls, *args, **kwargs):
 		"""



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/library/
@ 2011-06-29 17:52 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-06-29 17:52 UTC (permalink / raw
  To: gentoo-commits

commit:     a90c5dcab9a1b5ae0c9b4a4246c307709754b9c6
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 29 17:39:00 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Jun 29 17:39:00 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=a90c5dca

Support passing kwargs to the library constructor.

---
 pmstestsuite/library/__init__.py |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/pmstestsuite/library/__init__.py b/pmstestsuite/library/__init__.py
index 00891f6..a638b62 100644
--- a/pmstestsuite/library/__init__.py
+++ b/pmstestsuite/library/__init__.py
@@ -84,10 +84,10 @@ class TestLibrary(object):
 		""" Return common files necessary for the library (e.g. eclasses). """
 		return {}
 
-def load_library(name):
+def load_library(name, **kwargs):
 	"""
 	Try to load a test library <name>. Instiantiate the first TestLibrary
-	subclass found there.
+	subclass found there. Pass kwargs to the __init__() function.
 
 	Returns a new TestLibrary subclass instance or raises one of the following
 	exceptions:
@@ -113,4 +113,4 @@ def load_library(name):
 		raise TypeError('Unable to find a TestLibrary subclass in %s'
 				% modname)
 
-	return cls(modname)
+	return cls(modname, **kwargs)



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/library/
@ 2011-06-29 17:52 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-06-29 17:52 UTC (permalink / raw
  To: gentoo-commits

commit:     488599349fcf9b124ed3f04488bdb09704b2a793
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 29 17:42:55 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Jun 29 17:42:55 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=48859934

EbuildTestCase: drop unused args to inst_all().

---
 pmstestsuite/library/case.py |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/pmstestsuite/library/case.py b/pmstestsuite/library/case.py
index 3ab5197..3eba089 100644
--- a/pmstestsuite/library/case.py
+++ b/pmstestsuite/library/case.py
@@ -149,7 +149,7 @@ class EbuildTestCase(TestCase):
 		return (random.choice(cls._eval_prop(cls.supported_eapis)),)
 
 	@classmethod
-	def inst_all(cls, *args, **kwargs):
+	def inst_all(cls):
 		"""
 		Instantiate the test case for all relevant EAPIs.
 
@@ -159,8 +159,7 @@ class EbuildTestCase(TestCase):
 		# sadly, no @classproperty
 		# but property object attributes are official
 		for eapi in cls._eval_prop(cls.relevant_eapis):
-			kwargs['eapi'] = eapi
-			yield cls(*args, **kwargs)
+			yield cls(eapi = eapi)
 
 	@property
 	def pn(self):



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/library/
@ 2011-06-29 17:52 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-06-29 17:52 UTC (permalink / raw
  To: gentoo-commits

commit:     f35a14a1d1f8cc7e2b79fdb3ae3054f038e9d407
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 29 17:46:51 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Jun 29 17:46:51 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=f35a14a1

Actually support the thorough mode.

---
 pmstestsuite/library/__init__.py |    2 +-
 pmstestsuite/library/case.py     |   14 +++++++++-----
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/pmstestsuite/library/__init__.py b/pmstestsuite/library/__init__.py
index 6499e3f..d65958f 100644
--- a/pmstestsuite/library/__init__.py
+++ b/pmstestsuite/library/__init__.py
@@ -48,7 +48,7 @@ class TestLibrary(object):
 				modname = '%s.%s' % (self.modname, modname)
 				mod = __import__(modname, {}, {}, [clsname], 0)
 				cls = getattr(mod, clsname)
-				for i in cls.inst_all():
+				for i in cls.inst_all(thorough = self.thorough):
 					self.tests.append(i)
 					yield i
 

diff --git a/pmstestsuite/library/case.py b/pmstestsuite/library/case.py
index 3eba089..3327c33 100644
--- a/pmstestsuite/library/case.py
+++ b/pmstestsuite/library/case.py
@@ -149,16 +149,20 @@ class EbuildTestCase(TestCase):
 		return (random.choice(cls._eval_prop(cls.supported_eapis)),)
 
 	@classmethod
-	def inst_all(cls):
+	def inst_all(cls, thorough = False):
 		"""
-		Instantiate the test case for all relevant EAPIs.
+		Instantiate the test case for all relevant EAPIs. If in thorough
+		mode, assume all supported EAPIs are relevant.
 
 		Returns an iterator over a list of test case instances.
 		"""
 
-		# sadly, no @classproperty
-		# but property object attributes are official
-		for eapi in cls._eval_prop(cls.relevant_eapis):
+		if thorough:
+			eapis = cls.supported_eapis
+		else:
+			eapis = cls.relevant_eapis
+
+		for eapi in cls._eval_prop(eapis):
 			yield cls(eapi = eapi)
 
 	@property



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/library/
@ 2011-07-24 14:37 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-07-24 14:37 UTC (permalink / raw
  To: gentoo-commits

commit:     8e3f05a32064e31e0662e27488ae639c5c1d8283
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 24 08:25:43 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Jul 24 14:38:22 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=8e3f05a3

Add a base class for eclass dep tests.

---
 pmstestsuite/library/depend_case.py |   86 +++++++++++++++++++++++++++++++++++
 1 files changed, 86 insertions(+), 0 deletions(-)

diff --git a/pmstestsuite/library/depend_case.py b/pmstestsuite/library/depend_case.py
index 6a6afc3..f5f7327 100644
--- a/pmstestsuite/library/depend_case.py
+++ b/pmstestsuite/library/depend_case.py
@@ -3,6 +3,7 @@
 # Released under the terms of the 2-clause BSD license.
 
 from pmstestsuite.library.case import EbuildTestCase
+from pmstestsuite.library.eclass_case import EclassTestCase
 
 class EbuildDependencyTestCase(EbuildTestCase):
 	"""
@@ -69,3 +70,88 @@ class EbuildDependencyTestCase(EbuildTestCase):
 		for o in self.dependant_ebuilds:
 			res &= o.check_result(pm)
 		return res
+
+class EclassDependencyTestCase(EclassTestCase, EbuildDependencyTestCase):
+	"""
+	Test case utilizing multiple ebuilds in order to check dependency
+	resolution in an eclass.
+
+	In order to perform a dependency test, please:
+
+		1. create EbuildTestCase subclasses for the dependencies like usual,
+		2. create EclassDependencyTestCase and refer to the classes created
+		above in depend_classes, rdepend_classes and eclass_*.
+
+	The class is going to set up all ebuilds, DEPEND and RDEPEND automagically.
+	However, you need to provide phase functions to perform the actual
+	dependency test (i.e. check whether the dependency was merged successfully).
+
+	@cvar depend_classes: classes for DEPEND generation
+	@type depend_classes: iterable(L{EbuildTestCase})
+	@cvar rdepend_classes: classes for RDEPEND generation
+	@type rdepend_classes: iterable(L{EbuildTestCase})
+	@cvar pdepend_classes: classes for PDEPEND generation
+	@type pdepend_classes: iterable(L{EbuildTestCase})
+	@cvar eclass_depend_classes: classes for eclass DEPEND generation
+	@type eclass_depend_classes: iterable(L{EbuildTestCase})
+	@cvar eclass_rdepend_classes: classes for eclass RDEPEND generation
+	@type eclass_rdepend_classes: iterable(L{EbuildTestCase})
+	@cvar eclass_pdepend_classes: classes for eclass PDEPEND generation
+	@type eclass_pdepend_classes: iterable(L{EbuildTestCase})
+	"""
+
+	depend_classes = []
+	rdepend_classes = []
+	pdepend_classes = []
+	eclass_depend_classes = []
+	eclass_rdepend_classes = []
+	eclass_pdepend_classes = []
+
+	def __init__(self, eapi):
+		"""
+		Instantiate the dependency test case and dependant sub-cases. Set
+		C{DEPEND}, C{RDEPEND} and C{PDEPEND}.
+		"""
+
+		EclassTestCase.__init__(self, eapi)
+
+		self.dependant_ebuilds = []
+
+		for class_list, v in ((self.depend_classes, 'DEPEND'),
+				(self.rdepend_classes, 'RDEPEND'),
+				(self.pdepend_classes, 'PDEPEND')):
+			if v not in self.ebuild_vars:
+				self.ebuild_vars[v] = ''
+
+			for d in class_list:
+				o = d(eapi)
+				self.ebuild_vars[v] += '\n\t=%s' % o.cpv
+				self.dependant_ebuilds.append(o)
+
+		for class_list, v in ((self.eclass_depend_classes, 'DEPEND'),
+				(self.eclass_rdepend_classes, 'RDEPEND'),
+				(self.eclass_pdepend_classes, 'PDEPEND')):
+
+			ev = ''
+			for d in class_list:
+				o = d(eapi)
+				ev += '\n\t=%s' % o.cpv
+				self.dependant_ebuilds.append(o)
+			self.eclass_contents = '%s="%s"\n%s' % (v, ev,
+					self.eclass_contents)
+
+	def clean(self, pm):
+		EbuildDependencyTestCase.clean(self, pm)
+
+	def get_output_files(self):
+		of = EclassTestCase.get_output_files(self)
+		for o in self.dependant_ebuilds:
+			of.update(o.get_output_files())
+
+		return of
+
+	def check_result(self, pm):
+		res = EclassTestCase.check_result(self, pm)
+		for o in self.dependant_ebuilds:
+			res &= o.check_result(pm)
+		return res



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/library/
@ 2011-08-02 18:53 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-08-02 18:53 UTC (permalink / raw
  To: gentoo-commits

commit:     e1e9de99067427288827b52c53a8de3871e930ef
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Aug  2 18:12:15 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Aug  2 18:12:15 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=e1e9de99

Add .assertEqual()/.assertNotEqual() for the test cases.

---
 pmstestsuite/library/case.py |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/pmstestsuite/library/case.py b/pmstestsuite/library/case.py
index a11bafe..6a37524 100644
--- a/pmstestsuite/library/case.py
+++ b/pmstestsuite/library/case.py
@@ -154,6 +154,34 @@ class TestCase(ABCObject):
 		if needle not in container:
 			raise AssertionError(msg)
 
+	def assertEqual(self, value, expect, msg):
+		"""
+		Assert that the value is equal to expected one.
+
+		@param value: the actual value
+		@type value: any
+		@param expect: the expected value
+		@type expect: any
+		@param msg: assertion description
+		@type msg: string
+		"""
+		if value != expect:
+			raise AssertionError(msg)
+
+	def assertNotEqual(self, value, unallowed, msg):
+		"""
+		Assert that the value is other than an unallowed one.
+
+		@param value: the actual value
+		@type value: any
+		@param expect: the unallowed value
+		@type expect: any
+		@param msg: assertion description
+		@type msg: string
+		"""
+		if value == unallowed:
+			raise AssertionError(msg)
+
 	@abstractmethod
 	def check_result(self, pm):
 		"""



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/library/
@ 2011-08-02 18:53 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-08-02 18:53 UTC (permalink / raw
  To: gentoo-commits

commit:     9abfc2a16d5687cea4050dfa77ae3fa615bb9bab
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Aug  2 18:11:51 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Aug  2 18:11:51 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=9abfc2a1

Remove double definition of assertTrue().

---
 pmstestsuite/library/case.py |   12 ------------
 1 files changed, 0 insertions(+), 12 deletions(-)

diff --git a/pmstestsuite/library/case.py b/pmstestsuite/library/case.py
index 0dd64b8..a11bafe 100644
--- a/pmstestsuite/library/case.py
+++ b/pmstestsuite/library/case.py
@@ -138,18 +138,6 @@ class TestCase(ABCObject):
 		if bool(cond) != expect:
 			raise AssertionError(msg)
 
-	def assertTrue(self, cond, msg):
-		"""
-		Assert that the condition evaluates to True.
-
-		@param cond: the condition
-		@type cond: bool
-		@param msg: assertion description
-		@type msg: string
-		"""
-		if not cond:
-			raise AssertionError(msg)
-
 	def assertContains(self, needle, container, msg = None):
 		"""
 		Assert the following condition: C{needle in container}.



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/library/
@ 2011-08-02 18:53 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-08-02 18:53 UTC (permalink / raw
  To: gentoo-commits

commit:     3988b15b0c30acd827bba1f96dc10d72cc5cbd8e
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Aug  2 18:24:15 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Aug  2 18:24:15 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=3988b15b

Use test class names in str().

---
 pmstestsuite/library/case.py |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/pmstestsuite/library/case.py b/pmstestsuite/library/case.py
index 6a37524..956a1a3 100644
--- a/pmstestsuite/library/case.py
+++ b/pmstestsuite/library/case.py
@@ -314,7 +314,8 @@ class EbuildTestCase(TestCase):
 
 	def __str__(self):
 		""" Return freetext test description. """
-		return '%s (%s)' % (self.p, self._stripped_docstring)
+		return '%s:%s (%s)' % (self.__class__.__name__, self.eapi,
+				self._stripped_docstring)
 
 	def __init__(self, eapi):
 		"""



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/library/
@ 2011-08-02 18:53 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-08-02 18:53 UTC (permalink / raw
  To: gentoo-commits

commit:     c8f668f617583998ed87b85f051846036631dbef
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Aug  2 18:54:02 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Aug  2 18:54:02 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=c8f668f6

Store assertion results.

---
 pmstestsuite/library/case.py |  109 ++++++++++++++++++++++++++++++++++++++----
 1 files changed, 100 insertions(+), 9 deletions(-)

diff --git a/pmstestsuite/library/case.py b/pmstestsuite/library/case.py
index 956a1a3..5295002 100644
--- a/pmstestsuite/library/case.py
+++ b/pmstestsuite/library/case.py
@@ -3,7 +3,7 @@
 # Released under the terms of the 2-clause BSD license.
 
 import copy, random, re
-from gentoopm.util import ABCObject
+from gentoopm.util import ABCObject, BoolCompat
 
 from abc import ABCMeta, abstractmethod, abstractproperty
 
@@ -53,6 +53,92 @@ def cleanup_test_case_name(classname):
 		classname = classname[:-4]
 	return pn_re.sub('\\1-\\2', classname).lower()
 
+class AssertionResult(ABCObject, BoolCompat):
+	def __init__(self, name):
+		self._name = name
+
+	@property
+	def name(self):
+		return self._name
+
+	@abstractproperty
+	def expected(self):
+		pass
+
+	@abstractproperty
+	def actual(self):
+		pass
+
+	@abstractmethod
+	def __bool__(self):
+		pass
+
+	def __str__(self):
+		return '%s == %s' % (self.actual, self.expected)
+
+class BoolAssertionResult(AssertionResult):
+	def __init__(self, name, expect, cond):
+		AssertionResult.__init__(self, name)
+		self._expect = bool(expect)
+		self._cond = bool(cond)
+
+	@property
+	def expected(self):
+		return self._expect
+
+	@property
+	def actual(self):
+		return self._cond
+
+	def __bool__(self):
+		return self._cond == self._expect
+
+class ContainsAssertionResult(AssertionResult):
+	def __init__(self, name, needle, container):
+		AssertionResult.__init__(self, name)
+		self._cont = container
+		self._need = needle
+
+	@property
+	def expected(self):
+		return 'contains %s' % repr(self._need)
+
+	@property
+	def actual(self):
+		return repr(self._cont)
+
+	def __bool__(self):
+		return self._need in self._cont
+
+class EqualAssertionResult(AssertionResult):
+	def __init__(self, name, expect, value):
+		AssertionResult.__init__(self, name)
+		self._expect = expect
+		self._value = value
+
+	@property
+	def expected(self):
+		return repr(self._expect)
+
+	@property
+	def actual(self):
+		return repr(self._value)
+
+	def __bool__(self):
+		return self._value == self._expect
+
+class NotEqualAssertionResult(EqualAssertionResult):
+	def __bool__(self):
+		return self._value != self._expect
+
+	@property
+	def expected(self):
+		return 'not %s' % repr(self._expect)
+
+	def __str__(self):
+		return '%s != %s' % (self.actual,
+				repr(self._expect))
+
 class TestCase(ABCObject):
 	"""
 	Base class for a test case.
@@ -64,6 +150,9 @@ class TestCase(ABCObject):
 
 	_finalized = False
 
+	def __init__(self):
+		self.assertions = []
+
 	def _finalize(self):
 		"""
 		Do any final modifications to test case data. Mark it finalized.
@@ -102,6 +191,11 @@ class TestCase(ABCObject):
 		"""
 		pass
 
+	def _append_assert(self, a):
+		self.assertions.append(a)
+		if not a:
+			raise AssertionError(str(a))
+
 	def assertTrue(self, cond, msg):
 		"""
 		Assert that the condition evaluates to True.
@@ -135,8 +229,7 @@ class TestCase(ABCObject):
 		@param msg: assertion description
 		@type msg: string
 		"""
-		if bool(cond) != expect:
-			raise AssertionError(msg)
+		self._append_assert(BoolAssertionResult(msg, expect, cond))
 
 	def assertContains(self, needle, container, msg = None):
 		"""
@@ -151,8 +244,7 @@ class TestCase(ABCObject):
 		"""
 		if msg is None:
 			msg = '%s in %s' % (repr(needle), repr(container))
-		if needle not in container:
-			raise AssertionError(msg)
+		self._append_assert(ContainsAssertionResult(msg, needle, container))
 
 	def assertEqual(self, value, expect, msg):
 		"""
@@ -165,8 +257,7 @@ class TestCase(ABCObject):
 		@param msg: assertion description
 		@type msg: string
 		"""
-		if value != expect:
-			raise AssertionError(msg)
+		self._append_assert(EqualAssertionResult(msg, expect, value))
 
 	def assertNotEqual(self, value, unallowed, msg):
 		"""
@@ -179,8 +270,7 @@ class TestCase(ABCObject):
 		@param msg: assertion description
 		@type msg: string
 		"""
-		if value == unallowed:
-			raise AssertionError(msg)
+		self._append_assert(NotEqualAssertionResult(msg, unallowed, value))
 
 	@abstractmethod
 	def check_result(self, pm):
@@ -324,6 +414,7 @@ class EbuildTestCase(TestCase):
 		@param eapi: the EAPI
 		@type eapi: string
 		"""
+		TestCase.__init__(self)
 		self.eapi = eapi
 
 		for v in ('ebuild_vars', 'inherits', 'phase_funcs'):



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/library/
@ 2011-08-03  8:17 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-08-03  8:17 UTC (permalink / raw
  To: gentoo-commits

commit:     5a0e0675a2d75b907ea1578fb0c80e8279cb5b91
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Aug  3 08:05:47 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Aug  3 08:05:47 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=5a0e0675

Drop '==' from .assertContains stringification.

---
 pmstestsuite/library/case.py |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/pmstestsuite/library/case.py b/pmstestsuite/library/case.py
index 5295002..80b4e4b 100644
--- a/pmstestsuite/library/case.py
+++ b/pmstestsuite/library/case.py
@@ -107,6 +107,9 @@ class ContainsAssertionResult(AssertionResult):
 	def actual(self):
 		return repr(self._cont)
 
+	def __str__(self):
+		return '%s %s' % (self.actual, self.expected)
+
 	def __bool__(self):
 		return self._need in self._cont
 



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/library/
@ 2011-08-03 20:17 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-08-03 20:17 UTC (permalink / raw
  To: gentoo-commits

commit:     52476d69f2c7f7b134bb3b5c4fdbb58cdf9b1efc
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Aug  3 18:10:40 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Aug  3 18:10:40 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=52476d69

Assertions: use expected value on left side of comparisons.

This way, we can easily adjust __eq__() & __ne__() there.

---
 pmstestsuite/library/case.py |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/pmstestsuite/library/case.py b/pmstestsuite/library/case.py
index 80b4e4b..9ff757a 100644
--- a/pmstestsuite/library/case.py
+++ b/pmstestsuite/library/case.py
@@ -91,7 +91,7 @@ class BoolAssertionResult(AssertionResult):
 		return self._cond
 
 	def __bool__(self):
-		return self._cond == self._expect
+		return self._expect == self._cond
 
 class ContainsAssertionResult(AssertionResult):
 	def __init__(self, name, needle, container):
@@ -128,11 +128,11 @@ class EqualAssertionResult(AssertionResult):
 		return repr(self._value)
 
 	def __bool__(self):
-		return self._value == self._expect
+		return self._expect == self._value
 
 class NotEqualAssertionResult(EqualAssertionResult):
 	def __bool__(self):
-		return self._value != self._expect
+		return self._expect != self._value
 
 	@property
 	def expected(self):



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/library/
@ 2011-08-03 20:17 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-08-03 20:17 UTC (permalink / raw
  To: gentoo-commits

commit:     880baa08f9cbd31b15fe03e946d243c5fcb2464a
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Aug  3 20:16:26 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Aug  3 20:16:26 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=880baa08

Commonize out some of dependency test case code.

---
 pmstestsuite/library/depend_case.py |  106 ++++++++++++++++-------------------
 1 files changed, 48 insertions(+), 58 deletions(-)

diff --git a/pmstestsuite/library/depend_case.py b/pmstestsuite/library/depend_case.py
index 793d7ce..1185a16 100644
--- a/pmstestsuite/library/depend_case.py
+++ b/pmstestsuite/library/depend_case.py
@@ -5,26 +5,13 @@
 from pmstestsuite.library.case import EbuildTestCase
 from pmstestsuite.library.eclass_case import EclassTestCase
 
-class EbuildDependencyTestCase(EbuildTestCase):
+class BaseDependencyTestCase(object):
 	"""
-	Test case utilizing multiple ebuilds in order to check dependency
-	resolution.
-
-	In order to perform a dependency test, please:
-
-		1. create EbuildTestCase subclasses for the dependencies like usual,
-		2. create EbuildDependencyTestCase and refer to the classes created
-		above in depend_classes or rdepend_classes.
-
-	The class is going to set up all ebuilds, DEPEND and RDEPEND automagically.
-	However, you need to provide phase functions to perform the actual
-	dependency test (i.e. check whether the dependency was merged successfully).
-
-	@cvar depend_classes: classes for DEPEND generation
+	@cvar depend_classes: classes for C{DEPEND} generation
 	@type depend_classes: iterable(L{EbuildTestCase})
-	@cvar rdepend_classes: classes for RDEPEND generation
+	@cvar rdepend_classes: classes for C{RDEPEND} generation
 	@type rdepend_classes: iterable(L{EbuildTestCase})
-	@cvar pdepend_classes: classes for PDEPEND generation
+	@cvar pdepend_classes: classes for C{PDEPEND} generation
 	@type pdepend_classes: iterable(L{EbuildTestCase})
 	"""
 
@@ -32,14 +19,12 @@ class EbuildDependencyTestCase(EbuildTestCase):
 	rdepend_classes = []
 	pdepend_classes = []
 
-	def __init__(self, eapi):
+	def __init__(self, *args, **kwargs):
 		"""
 		Instantiate the dependency test case and dependant sub-cases. Set
 		C{DEPEND}, C{RDEPEND} and C{PDEPEND}.
 		"""
 
-		EbuildTestCase.__init__(self, eapi)
-
 		self.dependant_ebuilds = []
 
 		for class_list, v in ((self.depend_classes, 'DEPEND'),
@@ -49,28 +34,56 @@ class EbuildDependencyTestCase(EbuildTestCase):
 				self.ebuild_vars[v] = ''
 
 			for d in class_list:
-				o = d(eapi)
+				o = d(*args, **kwargs)
 				self.ebuild_vars[v] += '\n\t=%s' % o.cpv
 				self.dependant_ebuilds.append(o)
 
 	def clean(self, pm):
-		EbuildTestCase.clean(self, pm)
 		for o in self.dependant_ebuilds:
 			o.clean(pm)
 
-	def get_output_files(self):
-		of = EbuildTestCase.get_output_files(self)
+	def _append_output_files(self, of):
 		for o in self.dependant_ebuilds:
 			of.update(o.get_output_files())
 
+	def check_result(self, pm):
+		for o in self.dependant_ebuilds:
+			o.check_result(pm)
+
+class EbuildDependencyTestCase(BaseDependencyTestCase, EbuildTestCase):
+	"""
+	Test case utilizing multiple ebuilds in order to check dependency
+	resolution.
+
+	In order to perform a dependency test, please:
+
+		1. create EbuildTestCase subclasses for the dependencies like usual,
+		2. create EbuildDependencyTestCase and refer to the classes created
+		above in depend_classes or rdepend_classes.
+
+	The class is going to set up all ebuilds, DEPEND and RDEPEND automagically.
+	However, you need to provide phase functions to perform the actual
+	dependency test (i.e. check whether the dependency was merged successfully).
+	"""
+
+	def __init__(self, *args, **kwargs):
+		EbuildTestCase.__init__(self, *args, **kwargs)
+		BaseDependencyTestCase.__init__(self, *args, **kwargs)
+
+	def clean(self, pm):
+		EbuildTestCase.clean(self, pm)
+		BaseDependencyTestCase.clean(self, pm)
+
+	def get_output_files(self):
+		of = EbuildTestCase.get_output_files(self)
+		BaseDependencyTestCase._append_output_files(self, of)
 		return of
 
 	def check_result(self, pm):
 		EbuildTestCase.check_result(self, pm)
-		for o in self.dependant_ebuilds:
-			o.check_result(pm)
+		BaseDependencyTestCase.check_result(self, pm)
 
-class EclassDependencyTestCase(EclassTestCase, EbuildDependencyTestCase):
+class EclassDependencyTestCase(BaseDependencyTestCase, EclassTestCase):
 	"""
 	Test case utilizing multiple ebuilds in order to check dependency
 	resolution in an eclass.
@@ -85,12 +98,6 @@ class EclassDependencyTestCase(EclassTestCase, EbuildDependencyTestCase):
 	However, you need to provide phase functions to perform the actual
 	dependency test (i.e. check whether the dependency was merged successfully).
 
-	@cvar depend_classes: classes for DEPEND generation
-	@type depend_classes: iterable(L{EbuildTestCase})
-	@cvar rdepend_classes: classes for RDEPEND generation
-	@type rdepend_classes: iterable(L{EbuildTestCase})
-	@cvar pdepend_classes: classes for PDEPEND generation
-	@type pdepend_classes: iterable(L{EbuildTestCase})
 	@cvar eclass_depend_classes: classes for eclass DEPEND generation
 	@type eclass_depend_classes: iterable(L{EbuildTestCase})
 	@cvar eclass_rdepend_classes: classes for eclass RDEPEND generation
@@ -99,33 +106,18 @@ class EclassDependencyTestCase(EclassTestCase, EbuildDependencyTestCase):
 	@type eclass_pdepend_classes: iterable(L{EbuildTestCase})
 	"""
 
-	depend_classes = []
-	rdepend_classes = []
-	pdepend_classes = []
 	eclass_depend_classes = []
 	eclass_rdepend_classes = []
 	eclass_pdepend_classes = []
 
-	def __init__(self, eapi):
+	def __init__(self, *args, **kwargs):
 		"""
 		Instantiate the dependency test case and dependant sub-cases. Set
 		C{DEPEND}, C{RDEPEND} and C{PDEPEND}.
 		"""
 
-		EclassTestCase.__init__(self, eapi)
-
-		self.dependant_ebuilds = []
-
-		for class_list, v in ((self.depend_classes, 'DEPEND'),
-				(self.rdepend_classes, 'RDEPEND'),
-				(self.pdepend_classes, 'PDEPEND')):
-			if v not in self.ebuild_vars:
-				self.ebuild_vars[v] = ''
-
-			for d in class_list:
-				o = d(eapi)
-				self.ebuild_vars[v] += '\n\t=%s' % o.cpv
-				self.dependant_ebuilds.append(o)
+		EclassTestCase.__init__(self, *args, **kwargs)
+		BaseDependencyTestCase.__init__(self, *args, **kwargs)
 
 		for class_list, v in ((self.eclass_depend_classes, 'DEPEND'),
 				(self.eclass_rdepend_classes, 'RDEPEND'),
@@ -133,23 +125,21 @@ class EclassDependencyTestCase(EclassTestCase, EbuildDependencyTestCase):
 
 			ev = ''
 			for d in class_list:
-				o = d(eapi)
+				o = d(*args, **kwargs)
 				ev += '\n\t=%s' % o.cpv
 				self.dependant_ebuilds.append(o)
 			self.eclass_contents = '%s="%s"\n%s' % (v, ev,
 					self.eclass_contents)
 
 	def clean(self, pm):
-		EbuildDependencyTestCase.clean(self, pm)
+		EclassTestCase.clean(self, pm)
+		BaseDependencyTestCase.clean(self, pm)
 
 	def get_output_files(self):
 		of = EclassTestCase.get_output_files(self)
-		for o in self.dependant_ebuilds:
-			of.update(o.get_output_files())
-
+		BaseDependencyTestCase._append_output_files(self, of)
 		return of
 
 	def check_result(self, pm):
 		EclassTestCase.check_result(self, pm)
-		for o in self.dependant_ebuilds:
-			o.check_result(pm)
+		BaseDependencyTestCase.check_result(self, pm)



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/library/
@ 2011-08-06 14:25 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-08-06 14:25 UTC (permalink / raw
  To: gentoo-commits

commit:     79af36f94cc8096e81026536c204a99faca57dcb
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Aug  6 14:14:26 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Aug  6 14:14:26 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=79af36f9

Support passing 'undefined' to assertions.

---
 pmstestsuite/library/case.py |   40 ++++++++++++++++++++++++++++------------
 1 files changed, 28 insertions(+), 12 deletions(-)

diff --git a/pmstestsuite/library/case.py b/pmstestsuite/library/case.py
index 55dfa43..4502571 100644
--- a/pmstestsuite/library/case.py
+++ b/pmstestsuite/library/case.py
@@ -212,7 +212,7 @@ class TestCase(ABCObject):
 		if not a.undefined and not a:
 			raise AssertionError(str(a))
 
-	def assertTrue(self, cond, msg):
+	def assertTrue(self, cond, msg, undefined = False):
 		"""
 		Assert that the condition evaluates to True.
 
@@ -220,10 +220,12 @@ class TestCase(ABCObject):
 		@type cond: bool
 		@param msg: assertion description
 		@type msg: string
+		@param undefined: whether the result is undefined
+		@type undefined: bool
 		"""
-		self.assertBool(True, cond, msg)
+		self.assertBool(True, cond, msg, undefined)
 
-	def assertFalse(self, cond, msg):
+	def assertFalse(self, cond, msg, undefined = False):
 		"""
 		Assert that the condition evaluates to False.
 
@@ -231,10 +233,12 @@ class TestCase(ABCObject):
 		@type cond: bool
 		@param msg: assertion description
 		@type msg: string
+		@param undefined: whether the result is undefined
+		@type undefined: bool
 		"""
-		self.assertBool(False, cond, msg)
+		self.assertBool(False, cond, msg, undefined)
 
-	def assertBool(self, expect, cond, msg):
+	def assertBool(self, expect, cond, msg, undefined = False):
 		"""
 		Assert that the condition evaluates to expected boolean result.
 
@@ -244,10 +248,13 @@ class TestCase(ABCObject):
 		@type cond: bool
 		@param msg: assertion description
 		@type msg: string
+		@param undefined: whether the result is undefined
+		@type undefined: bool
 		"""
-		self._append_assert(BoolAssertionResult(msg, expect, cond))
+		self._append_assert(BoolAssertionResult(msg, expect, cond),
+				undefined = undefined)
 
-	def assertContains(self, needle, container, msg = None):
+	def assertContains(self, needle, container, msg = None, undefined = False):
 		"""
 		Assert the following condition: C{needle in container}.
 
@@ -257,12 +264,15 @@ class TestCase(ABCObject):
 		@type container: iterable
 		@param msg: assertion description or C{None} for default one
 		@type msg: string/C{None}
+		@param undefined: whether the result is undefined
+		@type undefined: bool
 		"""
 		if msg is None:
 			msg = '%s in %s' % (repr(needle), repr(container))
-		self._append_assert(ContainsAssertionResult(msg, needle, container))
+		self._append_assert(ContainsAssertionResult(msg, needle, container),
+				undefined = undefined)
 
-	def assertEqual(self, value, expect, msg):
+	def assertEqual(self, value, expect, msg, undefined = False):
 		"""
 		Assert that the value is equal to expected one.
 
@@ -272,10 +282,13 @@ class TestCase(ABCObject):
 		@type expect: any
 		@param msg: assertion description
 		@type msg: string
+		@param undefined: whether the result is undefined
+		@type undefined: bool
 		"""
-		self._append_assert(EqualAssertionResult(msg, expect, value))
+		self._append_assert(EqualAssertionResult(msg, expect, value),
+				undefined = undefined)
 
-	def assertNotEqual(self, value, unallowed, msg):
+	def assertNotEqual(self, value, unallowed, msg, undefined = False):
 		"""
 		Assert that the value is other than an unallowed one.
 
@@ -285,8 +298,11 @@ class TestCase(ABCObject):
 		@type expect: any
 		@param msg: assertion description
 		@type msg: string
+		@param undefined: whether the result is undefined
+		@type undefined: bool
 		"""
-		self._append_assert(NotEqualAssertionResult(msg, unallowed, value))
+		self._append_assert(NotEqualAssertionResult(msg, unallowed, value),
+				undefined = undefined)
 
 	@abstractmethod
 	def check_result(self, pm):



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/library/
@ 2011-08-06 14:25 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-08-06 14:25 UTC (permalink / raw
  To: gentoo-commits

commit:     45ad5a275babd570743c09eaefa59bf0d55163fc
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Aug  6 14:20:27 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Aug  6 14:25:21 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=45ad5a27

Support 'None' as actual assertion result.

---
 pmstestsuite/library/case.py |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/pmstestsuite/library/case.py b/pmstestsuite/library/case.py
index 4502571..6cf7ebd 100644
--- a/pmstestsuite/library/case.py
+++ b/pmstestsuite/library/case.py
@@ -89,7 +89,7 @@ class BoolAssertionResult(AssertionResult):
 	def __init__(self, name, expect, cond):
 		AssertionResult.__init__(self, name)
 		self._expect = bool(expect)
-		self._cond = bool(cond)
+		self._cond = bool(cond) if cond is not None else None
 
 	@property
 	def expected(self):
@@ -97,9 +97,11 @@ class BoolAssertionResult(AssertionResult):
 
 	@property
 	def actual(self):
-		return self._cond
+		return self._cond if self._cond is not None else '?'
 
 	def __bool__(self):
+		if self._cond is None:
+			return False
 		return self._expect == self._cond
 
 class ContainsAssertionResult(AssertionResult):
@@ -114,12 +116,14 @@ class ContainsAssertionResult(AssertionResult):
 
 	@property
 	def actual(self):
-		return repr(self._cont)
+		return repr(self._cont) if self._cont is not None else '?'
 
 	def __str__(self):
 		return '%s %s' % (self.actual, self.expected)
 
 	def __bool__(self):
+		if self._cont is None:
+			return False
 		return self._need in self._cont
 
 class EqualAssertionResult(AssertionResult):
@@ -134,13 +138,15 @@ class EqualAssertionResult(AssertionResult):
 
 	@property
 	def actual(self):
-		return repr(self._value)
+		return repr(self._value) if self._value is not None else '?'
 
 	def __bool__(self):
 		return self._expect == self._value
 
 class NotEqualAssertionResult(EqualAssertionResult):
 	def __bool__(self):
+		if self._value is None:
+			return False
 		return self._expect != self._value
 
 	@property



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/library/
@ 2011-08-06 14:26 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-08-06 14:26 UTC (permalink / raw
  To: gentoo-commits

commit:     b88ac72d0c043605688d306dadfbffaf0362dbda
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Aug  6 14:27:39 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Aug  6 14:27:39 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=b88ac72d

Fix random.choice() failure.

---
 pmstestsuite/library/case.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/pmstestsuite/library/case.py b/pmstestsuite/library/case.py
index 6cf7ebd..06d7c2f 100644
--- a/pmstestsuite/library/case.py
+++ b/pmstestsuite/library/case.py
@@ -390,7 +390,7 @@ class EbuildTestCase(TestCase):
 
 		@type: iterable(iterable(string))
 		"""
-		return (known_eapis,)
+		return (tuple(known_eapis),)
 
 	@classmethod
 	def inst_all(cls, thorough = False, undefined = False):



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/library/
@ 2011-08-11  8:53 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-08-11  8:53 UTC (permalink / raw
  To: gentoo-commits

commit:     4f7717a20f5f6cc473be837deeca1fe0a1c9a1be
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 11 08:48:35 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Aug 11 08:48:35 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=4f7717a2

Store short test names.

---
 pmstestsuite/library/__init__.py |    6 +++---
 pmstestsuite/library/case.py     |   31 ++++++++++++++++++++-----------
 2 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/pmstestsuite/library/__init__.py b/pmstestsuite/library/__init__.py
index 473e9b0..3f7554b 100644
--- a/pmstestsuite/library/__init__.py
+++ b/pmstestsuite/library/__init__.py
@@ -27,13 +27,13 @@ from pmstestsuite.library.case import TestCase
 class TestLibrary(ABCObject):
 	"""
 	Base class for a test library.
-	
+
 	@ivar tests: cache of instantiated tests
 	@type tests: list(L{TestCase})
 	"""
 
 	tests = None
-	
+
 	@abstractproperty
 	def test_names(self):
 		"""
@@ -66,7 +66,7 @@ class TestLibrary(ABCObject):
 				mod = __import__(modname, {}, {}, [clsname], 0)
 				cls = getattr(mod, clsname)
 				for i in cls.inst_all(thorough = self.thorough,
-						undefined = self.undefined):
+						undefined = self.undefined, short_name = t):
 					self.tests.append(i)
 					yield i
 

diff --git a/pmstestsuite/library/case.py b/pmstestsuite/library/case.py
index 06d7c2f..76011e9 100644
--- a/pmstestsuite/library/case.py
+++ b/pmstestsuite/library/case.py
@@ -168,8 +168,22 @@ class TestCase(ABCObject):
 
 	_finalized = False
 
-	def __init__(self):
+	def __init__(self, short_name):
 		self.assertions = []
+		self._short_name = short_name
+
+	@property
+	def short_name(self):
+		return self._short_name
+
+	@property
+	def _stripped_docstring(self):
+		descdoc = ' '.join(self.__doc__.split())
+		return descdoc.rstrip('.')
+
+	def __str__(self):
+		""" Return freetext test description. """
+		return '%s (%s)' % (self.short_name, self._stripped_docstring)
 
 	def _finalize(self):
 		"""
@@ -393,7 +407,7 @@ class EbuildTestCase(TestCase):
 		return (tuple(known_eapis),)
 
 	@classmethod
-	def inst_all(cls, thorough = False, undefined = False):
+	def inst_all(cls, short_name, thorough = False, undefined = False):
 		"""
 		Instantiate the test case, choosing a single EAPI from each EAPI group
 		listed in L{supported_eapis}. If thorough mode is enabled, all EAPIs
@@ -421,7 +435,7 @@ class EbuildTestCase(TestCase):
 			eapis = [random.choice(x) for x in supported_eapis]
 
 		for eapi in eapis:
-			yield cls(eapi = eapi)
+			yield cls(eapi = eapi, short_name = short_name)
 
 	@property
 	def pn(self):
@@ -444,11 +458,6 @@ class EbuildTestCase(TestCase):
 		""" Return atom for the test. """
 		return pm.Atom('=%s' % self.cpv)
 
-	@property
-	def _stripped_docstring(self):
-		descdoc = ' '.join(self.__doc__.split())
-		return descdoc.rstrip('.')
-
 	def _finalize(self):
 		TestCase._finalize(self)
 
@@ -457,17 +466,17 @@ class EbuildTestCase(TestCase):
 
 	def __str__(self):
 		""" Return freetext test description. """
-		return '%s:%s (%s)' % (self.__class__.__name__, self.eapi,
+		return '%s:%s (%s)' % (self.short_name, self.eapi,
 				self._stripped_docstring)
 
-	def __init__(self, eapi):
+	def __init__(self, eapi, short_name):
 		"""
 		Instiantate the test case for a particular EAPI.
 
 		@param eapi: the EAPI
 		@type eapi: string
 		"""
-		TestCase.__init__(self)
+		TestCase.__init__(self, short_name)
 		self.eapi = eapi
 
 		for v in ('ebuild_vars', 'inherits', 'phase_funcs'):



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/library/
@ 2011-08-11  8:54 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-08-11  8:54 UTC (permalink / raw
  To: gentoo-commits

commit:     e37e4b216c78b00e89b19b71869b99ee4f363eb7
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 11 08:55:50 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Aug 11 08:55:50 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=e37e4b21

Support passing random args to EclassTestCase().

---
 pmstestsuite/library/eclass_case.py |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/pmstestsuite/library/eclass_case.py b/pmstestsuite/library/eclass_case.py
index 864a983..582e05a 100644
--- a/pmstestsuite/library/eclass_case.py
+++ b/pmstestsuite/library/eclass_case.py
@@ -22,8 +22,8 @@ class EclassTestCase(EbuildTestCase):
 		"""
 		pass
 
-	def __init__(self, eapi):
-		EbuildTestCase.__init__(self, eapi)
+	def __init__(self, *args, **kwargs):
+		EbuildTestCase.__init__(self, *args, **kwargs)
 		self.inherits.append(self.pn)
 
 	def get_output_files(self):



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/library/
@ 2011-08-11 22:09 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-08-11 22:09 UTC (permalink / raw
  To: gentoo-commits

commit:     e4d476b68d9606a87ca66d9f8b31128227cff0ae
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 11 21:53:19 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Aug 11 21:53:19 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=e4d476b6

FIXUP!

---
 pmstestsuite/library/case.py |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/pmstestsuite/library/case.py b/pmstestsuite/library/case.py
index 76011e9..00a6cd4 100644
--- a/pmstestsuite/library/case.py
+++ b/pmstestsuite/library/case.py
@@ -67,6 +67,14 @@ class AssertionResult(ABCObject, BoolCompat):
 		return self._name
 
 	@property
+	def prefix(self):
+		return None
+
+	@property
+	def unprefixed_name(self):
+		return self.name
+
+	@property
 	def undefined(self):
 		return self._undefined
 



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/library/
@ 2011-08-11 22:09 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-08-11 22:09 UTC (permalink / raw
  To: gentoo-commits

commit:     07fb0188ef5b99c66b416953223d16a12e792f68
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 11 21:38:42 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Aug 11 21:38:42 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=07fb0188

Prefix dep assertions and add them to assert list.

---
 pmstestsuite/library/depend_case.py |   45 ++++++++++++++++++++++++++++++++--
 1 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/pmstestsuite/library/depend_case.py b/pmstestsuite/library/depend_case.py
index 1185a16..55e49cc 100644
--- a/pmstestsuite/library/depend_case.py
+++ b/pmstestsuite/library/depend_case.py
@@ -2,9 +2,44 @@
 # (c) 2011 Michał Górny <mgorny@gentoo.org>
 # Released under the terms of the 2-clause BSD license.
 
-from pmstestsuite.library.case import EbuildTestCase
+from pmstestsuite.library.case import EbuildTestCase, AssertionResult
 from pmstestsuite.library.eclass_case import EclassTestCase
 
+class DepWrappedAssertion(AssertionResult):
+	def __init__(self, assertion, prefix):
+		self._assert = assertion
+		self._prefix = prefix
+
+	@property
+	def name(self):
+		return '[%s] %s' % (self._prefix, self._assert.name)
+
+	@property
+	def prefix(self):
+		return self._prefix
+
+	@property
+	def unprefixed_name(self):
+		return self._assert.name
+
+	@property
+	def undefined(self):
+		return self._assert.undefined
+
+	@property
+	def expected(self):
+		return self._assert.expected
+
+	@property
+	def actual(self):
+		return self._assert.actual
+
+	def __bool__(self):
+		return bool(self._assert)
+
+	def __str__(self):
+		return str(self._assert)
+
 class BaseDependencyTestCase(object):
 	"""
 	@cvar depend_classes: classes for C{DEPEND} generation
@@ -33,8 +68,9 @@ class BaseDependencyTestCase(object):
 			if v not in self.ebuild_vars:
 				self.ebuild_vars[v] = ''
 
-			for d in class_list:
+			for i, d in enumerate(class_list):
 				o = d(*args, **kwargs)
+				o._dep_prefix = '%s %d' % (v[:-3], i)
 				self.ebuild_vars[v] += '\n\t=%s' % o.cpv
 				self.dependant_ebuilds.append(o)
 
@@ -49,6 +85,8 @@ class BaseDependencyTestCase(object):
 	def check_result(self, pm):
 		for o in self.dependant_ebuilds:
 			o.check_result(pm)
+			self.assertions.extend([DepWrappedAssertion(x, o._dep_prefix)
+				for x in o.assertions])
 
 class EbuildDependencyTestCase(BaseDependencyTestCase, EbuildTestCase):
 	"""
@@ -124,8 +162,9 @@ class EclassDependencyTestCase(BaseDependencyTestCase, EclassTestCase):
 				(self.eclass_pdepend_classes, 'PDEPEND')):
 
 			ev = ''
-			for d in class_list:
+			for i, d in enumerate(class_list):
 				o = d(*args, **kwargs)
+				o._dep_prefix = 'eclass %s %d' % (v[:-3], i)
 				ev += '\n\t=%s' % o.cpv
 				self.dependant_ebuilds.append(o)
 			self.eclass_contents = '%s="%s"\n%s' % (v, ev,



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/library/
@ 2011-08-12 20:55 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2011-08-12 20:55 UTC (permalink / raw
  To: gentoo-commits

commit:     2ab344aeddbc7c068395ecf62089764c15f90a61
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 12 20:51:19 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Aug 12 20:51:19 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=2ab344ae

Use relative imports in module loader.

---
 pmstestsuite/library/__init__.py |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/pmstestsuite/library/__init__.py b/pmstestsuite/library/__init__.py
index 349b98b..eb5bade 100644
--- a/pmstestsuite/library/__init__.py
+++ b/pmstestsuite/library/__init__.py
@@ -63,7 +63,7 @@ class TestLibrary(ABCObject):
 				# XXX: tests without a '.' in __init__?
 				modname, clsname = t.rsplit('.', 1)
 				modname = '%s.%s' % (self.modname, modname)
-				mod = __import__(modname, {}, {}, [clsname], 0)
+				mod = __import__(modname, fromlist=[clsname], globals=globals(), level=1)
 				cls = getattr(mod, clsname)
 				for i in cls.inst_all(thorough = self.thorough,
 						undefined = self.undefined, short_name = t):
@@ -118,8 +118,7 @@ def load_library(name, **kwargs):
 	@raise TypeError: if no matching class is found in the module
 	"""
 
-	modname = 'pmstestsuite.library.%s' % name
-	mod = __import__(modname, {}, {}, ['.'], 0)
+	mod = __import__(name, fromlist=['.'], globals=globals(), level=1)
 
 	for k in dir(mod):
 		modvar = getattr(mod, k)
@@ -134,6 +133,6 @@ def load_library(name, **kwargs):
 			pass
 	else:
 		raise TypeError('Unable to find a TestLibrary subclass in %s'
-				% modname)
+				% name)
 
-	return cls(modname, **kwargs)
+	return cls(name, **kwargs)



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/library/
@ 2012-01-02 22:26 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2012-01-02 22:26 UTC (permalink / raw
  To: gentoo-commits

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

Introduce expect_started to fix D-Bus dependency cases.

---
 pmstestsuite/library/case.py        |    8 +++++++-
 pmstestsuite/library/depend_case.py |    1 +
 2 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/pmstestsuite/library/case.py b/pmstestsuite/library/case.py
index 90406a0..e007cf6 100644
--- a/pmstestsuite/library/case.py
+++ b/pmstestsuite/library/case.py
@@ -451,6 +451,10 @@ class EbuildTestCase(TestCase):
 		to merge successfully. Otherwise, the test ebuild is supposed to fail
 		to merge (die)
 	@type expect_failure: bool
+	@ivar expect_started: if set to True (the default), the test is supposed
+		to be started (ack via D-Bus). Otherwise, the test ebuild is supposed
+		to not ever start
+	@type expect_started: bool
 	@ivar inherits: additional eclasses to inherit
 	@type inherits: list (string)
 	@ivar phase_funcs: phase function contents
@@ -459,6 +463,7 @@ class EbuildTestCase(TestCase):
 
 	ebuild_vars = {}
 	expect_failure = False
+	expect_started = True
 	inherits = []
 	phase_funcs = {}
 
@@ -694,5 +699,6 @@ 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.assertBool(self.expect_started, 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 3f34ca7..d03f973 100644
--- a/pmstestsuite/library/depend_case.py
+++ b/pmstestsuite/library/depend_case.py
@@ -67,6 +67,7 @@ class BaseDependencyTestCase(object):
 		"""
 
 		self.dependant_ebuilds = []
+		self.expect_started = not self.expect_failure
 
 		for class_list, v in ((self.depend_classes, 'DEPEND'),
 				(self.rdepend_classes, 'RDEPEND'),



^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/library/
@ 2012-01-03 15:52 Michał Górny
  0 siblings, 0 replies; 52+ messages in thread
From: Michał Górny @ 2012-01-03 15:52 UTC (permalink / raw
  To: gentoo-commits

commit:     6b0b371c056d926103bff2759e3e633aae778217
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Jan  3 12:11:20 2012 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Jan  3 12:11:20 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=6b0b371c

Proceed with output checks even if test fails to merge.

---
 pmstestsuite/library/case.py |   23 ++++++++++++++++++-----
 1 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/pmstestsuite/library/case.py b/pmstestsuite/library/case.py
index 7cf4b1c..0f63735 100644
--- a/pmstestsuite/library/case.py
+++ b/pmstestsuite/library/case.py
@@ -695,9 +695,22 @@ class EbuildTestCase(TestCase):
 		@type pm: L{PackageManager}
 		"""
 
-		merged = self.atom(pm) in pm.installed
-		self.assertBool(not self.expect_failure, merged,
-				'package merged')
-		self.assertBool(self.expect_started, self.dbus_started,
-				'build started')
+		exc = None
+
+		try:
+			merged = self.atom(pm) in pm.installed
+			self.assertBool(not self.expect_failure, merged,
+					'package merged')
+		except AssertionError as e:
+			exc = e
+
+		try:
+			self.assertBool(self.expect_started, self.dbus_started,
+					'build started')
+		except AssertionError as e:
+			exc = e
+
 		self.check_dbus_result(self._pop_dbus_output(), pm)
+
+		if exc is not None:
+			raise exc



^ permalink raw reply related	[flat|nested] 52+ messages in thread

end of thread, other threads:[~2012-01-03 15:53 UTC | newest]

Thread overview: 52+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-14  8:32 [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/library/ Michał Górny
  -- strict thread matches above, loose matches on Subject: below --
2012-01-03 15:52 [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/library/ Michał Górny
2012-01-02 22:26 Michał Górny
2011-08-12 20:55 Michał Górny
2011-08-11 22:09 Michał Górny
2011-08-11 22:09 Michał Górny
2011-08-11  8:54 Michał Górny
2011-08-11  8:53 Michał Górny
2011-08-06 14:26 Michał Górny
2011-08-06 14:25 Michał Górny
2011-08-06 14:25 Michał Górny
2011-08-03 20:17 Michał Górny
2011-08-03 20:17 Michał Górny
2011-08-03  8:17 Michał Górny
2011-08-02 18:53 Michał Górny
2011-08-02 18:53 Michał Górny
2011-08-02 18:53 Michał Górny
2011-08-02 18:53 Michał Górny
2011-07-24 14:37 Michał Górny
2011-06-29 17:52 Michał Górny
2011-06-29 17:52 Michał Górny
2011-06-29 17:52 Michał Górny
2011-06-29 17:52 Michał Górny
2011-06-29 17:52 Michał Górny
2011-06-29 17:52 Michał Górny
2011-06-23 21:14 [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/library/ Michał Górny
2011-06-23 21:14 Michał Górny
2011-06-20 19:20 Michał Górny
2011-06-17 15:07 Michał Górny
2011-06-17  5:59 Michał Górny
2011-06-16 19:49 Michał Górny
2011-06-16 19:49 Michał Górny
2011-06-14 12:35 Michał Górny
2011-06-14  8:32 Michał Górny
2011-06-13 19:16 Michał Górny
2011-06-13 19:16 Michał Górny
2011-06-07 17:22 Michał Górny
2011-06-03 17:36 Michał Górny
2011-05-31 17:19 Michał Górny
2011-05-29 18:57 Michał Górny
2011-05-29 18:57 Michał Górny
2011-05-29 18:57 Michał Górny
2011-05-29 18:17 Michał Górny
2011-05-26  7:25 Michał Górny
2011-05-26  6:35 Michał Górny
2011-05-25 20:40 Michał Górny
2011-05-24 14:28 Michał Górny
2011-05-24  8:11 Michał Górny
2011-05-24  8:11 Michał Górny
2011-05-24  8:11 Michał Górny
2011-05-23 11:52 Michał Górny
2011-05-23  9:51 Michał Górny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox