* [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/library/standard/, PMSTestSuite/library/standard/basic/, ...
@ 2011-06-03 17:36 Michał Górny
0 siblings, 0 replies; 3+ messages in thread
From: Michał Górny @ 2011-06-03 17:36 UTC (permalink / raw
To: gentoo-commits
commit: a077b23813f9800351874b5d58618cd1c9c15bea
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Jun 3 17:35:58 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Jun 3 17:35:58 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=a077b238
Move D-Bus related code to a separate eclass.
---
PMSTestSuite/library/case.py | 2 -
PMSTestSuite/library/standard/__init__.py | 10 +++++-
.../library/standard/basic/phase_function_order.py | 6 ++-
PMSTestSuite/library/standard/dbus_case.py | 37 ++++++++++++++++++++
PMSTestSuite/repository/pms_eclass.py | 31 +----------------
5 files changed, 51 insertions(+), 35 deletions(-)
diff --git a/PMSTestSuite/library/case.py b/PMSTestSuite/library/case.py
index 30fd819..d063ce3 100644
--- a/PMSTestSuite/library/case.py
+++ b/PMSTestSuite/library/case.py
@@ -110,8 +110,6 @@ class EbuildTestCase(TestCase):
continue
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')
diff --git a/PMSTestSuite/library/standard/__init__.py b/PMSTestSuite/library/standard/__init__.py
index 96021d2..628d4b1 100644
--- a/PMSTestSuite/library/standard/__init__.py
+++ b/PMSTestSuite/library/standard/__init__.py
@@ -2,9 +2,12 @@
# (c) 2011 Michał Górny <mgorny@gentoo.org>
# Released under the terms of the 2-clause BSD license.
+import os.path
+
from PMSTestSuite.library import TestLibrary
+from PMSTestSuite.library.standard.dbus_case import pms_dbus_eclass
-class ExampleLibrary(TestLibrary):
+class StandardTestLibrary(TestLibrary):
"""
Standard test library for the PMS Test Suite.
"""
@@ -13,3 +16,8 @@ class ExampleLibrary(TestLibrary):
'basic.phase_function_order.PhaseFunctionOrderTest',
'basic.doins_fail.DoInsFailureTest'
]
+
+ def get_common_files(self):
+ return {
+ os.path.join('eclass', 'pms-test-dbus.eclass'): pms_dbus_eclass
+ }
diff --git a/PMSTestSuite/library/standard/basic/phase_function_order.py b/PMSTestSuite/library/standard/basic/phase_function_order.py
index 64ce3aa..82889ca 100644
--- a/PMSTestSuite/library/standard/basic/phase_function_order.py
+++ b/PMSTestSuite/library/standard/basic/phase_function_order.py
@@ -12,8 +12,10 @@ class PhaseFunctionOrderTest(DBusEbuildTestCase):
'DESCRIPTION': 'Phase function execution order test'
}
- phase_funcs = dict([(x, ["pms-test_append_result %s" % x])
- for x in phase_func_names])
+ phase_funcs = dict([(x, [
+ "pms-test-dbus_pkg_setup" if x == 'pkg_setup' else "",
+ "pms-test-dbus_append_result %s" % x
+ ]) for x in phase_func_names])
def check_dbus_result(self, output, res):
if self.eapi < 2:
diff --git a/PMSTestSuite/library/standard/dbus_case.py b/PMSTestSuite/library/standard/dbus_case.py
index e69b646..977d6da 100644
--- a/PMSTestSuite/library/standard/dbus_case.py
+++ b/PMSTestSuite/library/standard/dbus_case.py
@@ -9,6 +9,41 @@ from PMSTestSuite.dbus_handler import DBusHandler, dbus_interface_name, dbus_obj
dbus_handler = DBusHandler()
+pms_dbus_eclass = """# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: $
+
+DEPEND="sys-apps/dbus"
+
+EXPORT_FUNCTIONS pkg_setup
+
+pms-test-dbus_call() {
+ local method=${1}
+ shift
+
+ PMS_TEST_DBUS_P=${P//-/_}
+ dbus-send \\
+ --system \\
+ --print-reply \\
+ --type=method_call \\
+ --dest=org.gentoo.PMSTestSuite \\
+ /org/gentoo/PMSTestSuite/${PMS_TEST_DBUS_P} \\
+ org.gentoo.PMSTestSuite.${method} \\
+ "${@}"
+}
+
+pms-test-dbus_pkg_setup() {
+ # XXX: only for dbus cases
+ pms-test-dbus_call test_started
+}
+
+pms-test-dbus_append_result() {
+ pms-test-dbus_call append_output \\
+ string:"${*}" \\
+ || die 'Failed to append the test result using dbus'
+}
+"""
+
class RunningTest(dbus.service.Object):
""" A class encapsulating a running test. """
@@ -42,6 +77,8 @@ class RunningTest(dbus.service.Object):
class DBusEbuildTestCase(EbuildTestCase):
""" D-Bus capable base test case. """
+ inherits = ['pms-test-dbus']
+
def __init__(self, *args, **kwargs):
""" Initialize the test case and the D-Bus object for it. """
EbuildTestCase.__init__(self, *args, **kwargs)
diff --git a/PMSTestSuite/repository/pms_eclass.py b/PMSTestSuite/repository/pms_eclass.py
index 6a6c756..62eeb5c 100644
--- a/PMSTestSuite/repository/pms_eclass.py
+++ b/PMSTestSuite/repository/pms_eclass.py
@@ -16,37 +16,8 @@ SLOT=${EAPI-0}
KEYWORDS="alpha amd64 arm hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86"
IUSE=""
-DEPEND="sys-apps/dbus"
-
S=${WORKDIR}
-
-EXPORT_FUNCTIONS pkg_setup
-
-pms-test__dbus_call() {
- local method=${1}
- shift
-
- PMS_TEST_DBUS_P=${P//-/_}
- dbus-send \\
- --system \\
- --print-reply \\
- --type=method_call \\
- --dest=org.gentoo.PMSTestSuite \\
- /org/gentoo/PMSTestSuite/${PMS_TEST_DBUS_P} \\
- org.gentoo.PMSTestSuite.${method} \\
- "${@}"
-}
-
-pms-test_pkg_setup() {
- # XXX: only for dbus cases
- pms-test__dbus_call test_started
-}
-
-pms-test_append_result() {
- pms-test__dbus_call append_output \\
- string:"${*}" \\
- || die 'Failed to append the test result using dbus'
-}"""
+"""
def get_common_eclass_files():
""" Return a EbuildRepository.write_files()-dict for the eclass. """
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/library/standard/, PMSTestSuite/library/standard/basic/, ...
@ 2011-06-13 19:16 Michał Górny
0 siblings, 0 replies; 3+ messages in thread
From: Michał Górny @ 2011-06-13 19:16 UTC (permalink / raw
To: gentoo-commits
commit: 12ec0581aba2550502c8659709aa2366127a1519
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Jun 13 19:04:42 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Jun 13 19:04:42 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=12ec0581
Some initial code for dependency resolution testing (incomplete).
---
PMSTestSuite/library/depend_case.py | 41 +++++++++++++++++++++++++
PMSTestSuite/library/standard/__init__.py | 3 +-
PMSTestSuite/library/standard/basic/depend.py | 20 ++++++++++++
3 files changed, 63 insertions(+), 1 deletions(-)
diff --git a/PMSTestSuite/library/depend_case.py b/PMSTestSuite/library/depend_case.py
new file mode 100644
index 0000000..9e83f81
--- /dev/null
+++ b/PMSTestSuite/library/depend_case.py
@@ -0,0 +1,41 @@
+# vim:fileencoding=utf-8
+# (c) 2011 Michał Górny <mgorny@gentoo.org>
+# Released under the terms of the 2-clause BSD license.
+
+from PMSTestSuite.library.case import EbuildTestCase
+
+class EbuildDependencyTestCase(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).
+ """
+
+ depend_classes = []
+ rdepend_classes = []
+
+ def __init__(self, eapi):
+ EbuildTestCase.__init__(self, eapi)
+
+ self.depend_objs = []
+ self.rdepend_objs = []
+
+ for class_list, obj_list in ((self.depend_classes, self.depend_objs),
+ (self.rdepend_classes, self.rdepend_objs)):
+ for d in class_list:
+ obj_list.append(d(eapi))
+
+ for v, obj_list in (('DEPEND', self.depend_objs),
+ ('RDEPEND', self.rdepend_objs)):
+ if v not in self.ebuild_vars:
+ self.ebuild_vars[v] = ''
+ for o in obj_list:
+ self.ebuild_vars[v] += '\n\t=%s' % o.cpv
diff --git a/PMSTestSuite/library/standard/__init__.py b/PMSTestSuite/library/standard/__init__.py
index 628d4b1..23b4895 100644
--- a/PMSTestSuite/library/standard/__init__.py
+++ b/PMSTestSuite/library/standard/__init__.py
@@ -14,7 +14,8 @@ class StandardTestLibrary(TestLibrary):
test_names=[
'basic.phase_function_order.PhaseFunctionOrderTest',
- 'basic.doins_fail.DoInsFailureTest'
+ 'basic.doins_fail.DoInsFailureTest',
+ 'basic.depend.DependTest'
]
def get_common_files(self):
diff --git a/PMSTestSuite/library/standard/basic/depend.py b/PMSTestSuite/library/standard/basic/depend.py
new file mode 100644
index 0000000..2ac57ff
--- /dev/null
+++ b/PMSTestSuite/library/standard/basic/depend.py
@@ -0,0 +1,20 @@
+# vim:fileencoding=utf-8
+# (c) 2011 Michał Górny <mgorny@gentoo.org>
+# Released under the terms of the 2-clause BSD license.
+
+from PMSTestSuite.library.standard.dbus_case import DBusEbuildTestCase
+from PMSTestSuite.library.depend_case import EbuildDependencyTestCase
+
+class EbuildToucher(DBusEbuildTestCase):
+ ebuild_vars = {
+ 'DESCRIPTION': 'A random dependency ebuild'
+ }
+
+class DependTest(EbuildDependencyTestCase):
+ relevant_eapis = (0,)
+
+ ebuild_vars = {
+ 'DESCRIPTION': 'DEPEND fulfilling test'
+ }
+
+ depend_classes = [EbuildToucher]
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/library/standard/, PMSTestSuite/library/standard/basic/, ...
@ 2011-06-16 19:49 Michał Górny
0 siblings, 0 replies; 3+ messages in thread
From: Michał Górny @ 2011-06-16 19:49 UTC (permalink / raw
To: gentoo-commits
commit: f40a652a80e3712d7167841657f9d1feb0afd22f
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 16 18:54:55 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Jun 16 18:54:55 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=f40a652a
Test result checks use PM directly now.
---
PMSTestSuite/cli.py | 22 ++++++++++----------
PMSTestSuite/library/case.py | 18 ++++++++++++++--
PMSTestSuite/library/standard/basic/doins_fail.py | 3 +-
PMSTestSuite/library/standard/dbus_case.py | 14 ++++++------
4 files changed, 35 insertions(+), 22 deletions(-)
diff --git a/PMSTestSuite/cli.py b/PMSTestSuite/cli.py
index 4b08bb8..183c3a3 100644
--- a/PMSTestSuite/cli.py
+++ b/PMSTestSuite/cli.py
@@ -105,6 +105,12 @@ class PMSTestSuiteCLI(object):
self.pm.package_limit = opts.limit_pkgs
def tests_done(self):
+ self.failed = []
+ for t in self.test_library:
+ res = t.check_result(self.pm)
+ if not res:
+ self.failed.append(t)
+
self.merged_pkgs = frozenset(self.pm.lookup_vardb(self.cpvs))
if self.merged_pkgs:
print('-> Unmerging test ebuilds...')
@@ -114,22 +120,16 @@ class PMSTestSuiteCLI(object):
self.all_done()
def all_done(self):
- failed = []
-
- for t in self.test_library:
- res = t.check_result(t.cpv in self.merged_pkgs)
- if not res:
- failed.append(t)
-
- if not failed:
+ if not self.failed:
print('%d tests completed successfully.' % len(self.cpvs))
else:
print('%d of %d tests completed successfully, %d failed:'
- % (len(self.cpvs) - len(failed), len(self.cpvs), len(failed)))
- for t in failed:
+ % (len(self.cpvs) - len(self.failed),
+ len(self.cpvs), len(self.failed)))
+ for t in self.failed:
print('- %s' % t.p)
- self.ret = 0 if not failed else 1
+ self.ret = 0 if not self.failed else 1
self.loop.quit()
def start_pm(self):
diff --git a/PMSTestSuite/library/case.py b/PMSTestSuite/library/case.py
index 8430d21..5718fe6 100644
--- a/PMSTestSuite/library/case.py
+++ b/PMSTestSuite/library/case.py
@@ -56,6 +56,16 @@ class TestCase(object):
self.ebuild_vars['DESCRIPTION'] = descdoc.rstrip('.')
+ def check_result(self, pm):
+ """
+ Check the correctness of the result of test execution.
+ <pm> points to the current PackageManager instance.
+
+ Shall return True if the results indicate that the test succeeded,
+ False otherwise.
+ """
+ raise NotImplementedError('Please override TestCase.check_result()')
+
class EbuildTestCase(TestCase):
"""
Test case using a single ebuild (per EAPI).
@@ -157,12 +167,14 @@ class EbuildTestCase(TestCase):
return {fn: EbuildTestCaseEbuildFile(self)}
- def check_result(self, merged):
+ def check_result(self, pm):
"""
- Check the correctness of the result of test execution. <merged> should
- indicate whether the ebuild was actually merged.
+ Check the correctness of the result of test execution. By default,
+ checks whether the ebuild was actually merged.
Returns True if the results indicate that the test succeeded, False
otherwise.
"""
+
+ merged = bool(pm.lookup_vardb((self.cpv,)))
return (merged != self.expect_failure)
diff --git a/PMSTestSuite/library/standard/basic/doins_fail.py b/PMSTestSuite/library/standard/basic/doins_fail.py
index 9242d16..7502fbf 100644
--- a/PMSTestSuite/library/standard/basic/doins_fail.py
+++ b/PMSTestSuite/library/standard/basic/doins_fail.py
@@ -16,7 +16,8 @@ class DoInsFailureTest(DBusEbuildTestCase):
]
}
- def check_dbus_result(self, output, res):
+ def check_dbus_result(self, output, pm):
# expect success in EAPI 0
# and failure in EAPI 4
+ res = DBusEbuildTestCase.check_dbus_result(self, output, pm)
return (res == (self.eapi == 0))
diff --git a/PMSTestSuite/library/standard/dbus_case.py b/PMSTestSuite/library/standard/dbus_case.py
index 53991ba..970c897 100644
--- a/PMSTestSuite/library/standard/dbus_case.py
+++ b/PMSTestSuite/library/standard/dbus_case.py
@@ -88,18 +88,18 @@ class DBusEbuildTestCase(EbuildTestCase):
if self.phase_funcs['pkg_setup']:
self.phase_funcs['pkg_setup'].insert(0, 'pms-test-dbus_pkg_setup')
- def check_dbus_result(self, output, merged):
+ def check_dbus_result(self, output, pm):
"""
Check whether the <output> sent through D-Bus matches expected test
- output, and whether <merged> matches expected test result.
+ output.
Return True if it does, False otherwise.
- The default implementation uses self.expect_failure like the default
- check_result() of EbuildTestCase.
+ The default implementation simply checks whether the test was merged
+ alike EbuildTestCase.check_result().
"""
- return (merged != self.expect_failure)
+ return EbuildTestCase.check_result(self, pm)
- def check_result(self, res):
+ def check_result(self, pm):
return self.dbus_started \
- and self.check_dbus_result('\n'.join(self.dbus_output), res)
+ and self.check_dbus_result('\n'.join(self.dbus_output), pm)
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-06-16 19:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-03 17:36 [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/library/standard/, PMSTestSuite/library/standard/basic/, Michał Górny
-- strict thread matches above, loose matches on Subject: below --
2011-06-13 19:16 Michał Górny
2011-06-16 19:49 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