* [gentoo-commits] proj/pms-test-suite:master commit in: /, pmstestsuite/, pmstestsuite/output/
@ 2011-08-05 10:04 Michał Górny
0 siblings, 0 replies; only message in thread
From: Michał Górny @ 2011-08-05 10:04 UTC (permalink / raw
To: gentoo-commits
commit: 7bb2877434ccc06aa39d2956485c2df86f7ab91b
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 5 10:05:18 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Aug 5 10:05:39 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=7bb28774
Support switchable output modules.
---
pmstestsuite/cli.py | 29 ++++++++++++-------------
pmstestsuite/output/__init__.py | 44 +++++++++++++++++++++++++++++++++++++++
pmstestsuite/output/cli.py | 25 ++++++++++++++++++++++
setup.py | 1 +
4 files changed, 84 insertions(+), 15 deletions(-)
diff --git a/pmstestsuite/cli.py b/pmstestsuite/cli.py
index 97dd8db..0c492e1 100644
--- a/pmstestsuite/cli.py
+++ b/pmstestsuite/cli.py
@@ -13,6 +13,7 @@ from pmstestsuite import PV
from pmstestsuite.library import load_library
from pmstestsuite.repository import NewEbuildRepository
from pmstestsuite.repository.pms_eclass import get_common_eclass_files
+from pmstestsuite.output import get_output_modules
from pmstestsuite.pm import get_package_managers
class PMSTestSuiteCLI(object):
@@ -45,6 +46,9 @@ class PMSTestSuiteCLI(object):
opt.add_option('-M', '--no-manifests', dest='no_manifests',
help='Disable Manifest generation/updates',
action='store_true', default=False)
+ opt.add_option('-o', '--output-module', dest='outputmod',
+ help='Output module to use',
+ default='cli')
# XXX: get list, autodetect, more magic
opt.add_option('-p', '--package-manager', dest='pm',
help='Package manager to use',
@@ -84,6 +88,13 @@ class PMSTestSuiteCLI(object):
if opts.repo_path and opts.repo_name:
opt.error('--repository-path and --repository-name are mutually exclusive')
+ for x in get_output_modules():
+ if x.name == opts.outputmod:
+ self.output = x()
+ break
+ else:
+ opt.error('Output module not available: %s' % opts.outputmod)
+
for x in get_package_managers():
if x.name == opts.pm:
try:
@@ -148,21 +159,9 @@ class PMSTestSuiteCLI(object):
self.all_done()
def all_done(self):
- failed = filter(lambda tr: not tr[1], self.results.items())
- if not failed and not self.verbose:
- print('%d tests completed successfully.' % len(self.results))
- else:
- print('%d of %d tests completed successfully, %d failed:'
- % (len(self.results) - len(failed),
- len(self.results), len(failed)))
- tl = failed if not self.verbose else self.results.items()
- for t, r in tl:
- print('- %s [%s]' % (t, 'OK' if r else 'FAILED'))
- for a in t.assertions:
- print('-> %s: %s [%s]' % (a.name, str(a),
- 'OK' if a else 'FAILED'))
-
- self.ret = 0 if not failed else 1
+ ret = self.output(self.results, verbose = self.verbose)
+
+ self.ret = 0 if ret else 1
self.loop.quit()
def start_pm(self):
diff --git a/pmstestsuite/output/__init__.py b/pmstestsuite/output/__init__.py
new file mode 100644
index 0000000..b6a1446
--- /dev/null
+++ b/pmstestsuite/output/__init__.py
@@ -0,0 +1,44 @@
+# vim:fileencoding=utf-8
+# (c) 2011 Michał Górny <mgorny@gentoo.org>
+# Released under the terms of the 2-clause BSD license.
+
+from gentoopm.util import ABCObject
+from abc import abstractmethod, abstractproperty
+
+class OutputModule(ABCObject):
+ """ A module handling test results output. """
+
+ @abstractproperty
+ def name(self):
+ """
+ Output module name.
+
+ @type: string
+ """
+ pass
+
+ @abstractmethod
+ def __call__(self, results, verbose = False):
+ """
+ Output the test results.
+
+ @param results: test result dict
+ @type results: dict(L{TestCase} -> bool)
+ @param verbose: whether to output the results verbosely
+ @type verbose: bool
+ @return: whether all of the tests succeeded
+ @rtype: bool
+ """
+ pass
+
+def get_output_modules():
+ """
+ Return the list of supported output modules.
+
+ @return: supported output modules
+ @rtype: L{OutputModule}
+ """
+
+ from pmstestsuite.output.cli import CLIOutput
+
+ return (CLIOutput,)
diff --git a/pmstestsuite/output/cli.py b/pmstestsuite/output/cli.py
new file mode 100644
index 0000000..f7d882f
--- /dev/null
+++ b/pmstestsuite/output/cli.py
@@ -0,0 +1,25 @@
+# vim:fileencoding=utf-8
+# (c) 2011 Michał Górny <mgorny@gentoo.org>
+# Released under the terms of the 2-clause BSD license.
+
+from pmstestsuite.output import OutputModule
+
+class CLIOutput(OutputModule):
+ name = 'cli'
+
+ def __call__(self, results, verbose = False):
+ failed = filter(lambda tr: not tr[1], results.items())
+ if not failed and not verbose:
+ print('%d tests completed successfully.' % len(results))
+ else:
+ print('%d of %d tests completed successfully, %d failed:'
+ % (len(results) - len(failed),
+ len(results), len(failed)))
+ tl = failed if not verbose else results.items()
+ for t, r in tl:
+ print('- %s [%s]' % (t, 'OK' if r else 'FAILED'))
+ for a in t.assertions:
+ print('-> %s: %s [%s]' % (a.name, str(a),
+ 'OK' if a else 'FAILED'))
+
+ return bool(failed)
diff --git a/setup.py b/setup.py
index 097d124..5b996ba 100755
--- a/setup.py
+++ b/setup.py
@@ -66,6 +66,7 @@ setup(
'pmstestsuite.library',
'pmstestsuite.library.standard',
'pmstestsuite.library.test',
+ 'pmstestsuite.output',
'pmstestsuite.pm',
'pmstestsuite.repository'
],
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2011-08-05 10:04 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-05 10:04 [gentoo-commits] proj/pms-test-suite:master commit in: /, pmstestsuite/, pmstestsuite/output/ 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