* [gentoo-commits] proj/pms-test-suite:master commit in: /, doc/
@ 2011-06-22 11:50 Michał Górny
0 siblings, 0 replies; 3+ messages in thread
From: Michał Górny @ 2011-06-22 11:50 UTC (permalink / raw
To: gentoo-commits
commit: 44f25db3f154f01c610dc50be6e84f211fe81108
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 22 11:50:47 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Jun 22 11:50:47 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=44f25db3
Add CSS for syntax highlighting.
---
doc/pygments_style.css | 62 ++++++++++++++++++++++++++++++++++++++++++++++++
setup.py | 3 +-
2 files changed, 64 insertions(+), 1 deletions(-)
diff --git a/doc/pygments_style.css b/doc/pygments_style.css
new file mode 100644
index 0000000..145bc13
--- /dev/null
+++ b/doc/pygments_style.css
@@ -0,0 +1,62 @@
+.syntax .hll { background-color: #ffffcc }
+.syntax { background: #f0f0f0; }
+.syntax .c { color: #60a0b0; font-style: italic } /* Comment */
+.syntax .err { border: 1px solid #FF0000 } /* Error */
+.syntax .k { color: #007020; font-weight: bold } /* Keyword */
+.syntax .o { color: #666666 } /* Operator */
+.syntax .cm { color: #60a0b0; font-style: italic } /* Comment.Multiline */
+.syntax .cp { color: #007020 } /* Comment.Preproc */
+.syntax .c1 { color: #60a0b0; font-style: italic } /* Comment.Single */
+.syntax .cs { color: #60a0b0; background-color: #fff0f0 } /* Comment.Special */
+.syntax .gd { color: #A00000 } /* Generic.Deleted */
+.syntax .ge { font-style: italic } /* Generic.Emph */
+.syntax .gr { color: #FF0000 } /* Generic.Error */
+.syntax .gh { color: #000080; font-weight: bold } /* Generic.Heading */
+.syntax .gi { color: #00A000 } /* Generic.Inserted */
+.syntax .go { color: #808080 } /* Generic.Output */
+.syntax .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */
+.syntax .gs { font-weight: bold } /* Generic.Strong */
+.syntax .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
+.syntax .gt { color: #0040D0 } /* Generic.Traceback */
+.syntax .kc { color: #007020; font-weight: bold } /* Keyword.Constant */
+.syntax .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */
+.syntax .kn { color: #007020; font-weight: bold } /* Keyword.Namespace */
+.syntax .kp { color: #007020 } /* Keyword.Pseudo */
+.syntax .kr { color: #007020; font-weight: bold } /* Keyword.Reserved */
+.syntax .kt { color: #902000 } /* Keyword.Type */
+.syntax .m { color: #40a070 } /* Literal.Number */
+.syntax .s { color: #4070a0 } /* Literal.String */
+.syntax .na { color: #4070a0 } /* Name.Attribute */
+.syntax .nb { color: #007020 } /* Name.Builtin */
+.syntax .nc { color: #0e84b5; font-weight: bold } /* Name.Class */
+.syntax .no { color: #60add5 } /* Name.Constant */
+.syntax .nd { color: #555555; font-weight: bold } /* Name.Decorator */
+.syntax .ni { color: #d55537; font-weight: bold } /* Name.Entity */
+.syntax .ne { color: #007020 } /* Name.Exception */
+.syntax .nf { color: #06287e } /* Name.Function */
+.syntax .nl { color: #002070; font-weight: bold } /* Name.Label */
+.syntax .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */
+.syntax .nt { color: #062873; font-weight: bold } /* Name.Tag */
+.syntax .nv { color: #bb60d5 } /* Name.Variable */
+.syntax .ow { color: #007020; font-weight: bold } /* Operator.Word */
+.syntax .w { color: #bbbbbb } /* Text.Whitespace */
+.syntax .mf { color: #40a070 } /* Literal.Number.Float */
+.syntax .mh { color: #40a070 } /* Literal.Number.Hex */
+.syntax .mi { color: #40a070 } /* Literal.Number.Integer */
+.syntax .mo { color: #40a070 } /* Literal.Number.Oct */
+.syntax .sb { color: #4070a0 } /* Literal.String.Backtick */
+.syntax .sc { color: #4070a0 } /* Literal.String.Char */
+.syntax .sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */
+.syntax .s2 { color: #4070a0 } /* Literal.String.Double */
+.syntax .se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */
+.syntax .sh { color: #4070a0 } /* Literal.String.Heredoc */
+.syntax .si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */
+.syntax .sx { color: #c65d09 } /* Literal.String.Other */
+.syntax .sr { color: #235388 } /* Literal.String.Regex */
+.syntax .s1 { color: #4070a0 } /* Literal.String.Single */
+.syntax .ss { color: #517918 } /* Literal.String.Symbol */
+.syntax .bp { color: #007020 } /* Name.Builtin.Pseudo */
+.syntax .vc { color: #bb60d5 } /* Name.Variable.Class */
+.syntax .vg { color: #bb60d5 } /* Name.Variable.Global */
+.syntax .vi { color: #bb60d5 } /* Name.Variable.Instance */
+.syntax .il { color: #40a070 } /* Literal.Number.Integer.Long */
\ No newline at end of file
diff --git a/setup.py b/setup.py
index 46a50f5..839b5a7 100755
--- a/setup.py
+++ b/setup.py
@@ -52,6 +52,7 @@ class DocCommand(Command):
return '''<?xml version="1.0" encoding="utf-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
+ <style type="text/css">@import 'pygments_style.css';</style>
<title>%s</title>
</head>
<body>
@@ -74,7 +75,7 @@ class DocCommand(Command):
md.treeprocessors.add('titlegrepper', self.TitleGrepper(ska), '_end')
md.treeprocessors.add('langadder', self.LangAdder(), '<hilite')
- m = markdown.Markdown(extensions = ['codehilite', PMSTSExts()])
+ m = markdown.Markdown(extensions = ['codehilite(css_class=syntax)', PMSTSExts()])
for f in self.docs:
d = '%s.html' % os.path.splitext(f)[0]
print('Creating %s (from %s)' % (d, f))
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [gentoo-commits] proj/pms-test-suite:master commit in: /, doc/
@ 2011-07-25 15:37 Michał Górny
0 siblings, 0 replies; 3+ messages in thread
From: Michał Górny @ 2011-07-25 15:37 UTC (permalink / raw
To: gentoo-commits
commit: 587ac83028d4ae851e4cc140687e03cbfeafc71c
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 25 15:38:34 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Jul 25 15:38:34 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=587ac830
Drop Markdown docs, API docs should be enough.
---
doc/ebuild-test-case.md | 102 -----------------------------------------------
doc/library-format.md | 92 ------------------------------------------
doc/pygments_style.css | 62 ----------------------------
setup.py | 78 ++----------------------------------
4 files changed, 4 insertions(+), 330 deletions(-)
diff --git a/doc/ebuild-test-case.md b/doc/ebuild-test-case.md
deleted file mode 100644
index 4078cf1..0000000
--- a/doc/ebuild-test-case.md
+++ /dev/null
@@ -1,102 +0,0 @@
-EbuildTestCase
-==============
-
-Quick description
------------------
-
-`EbuildTestCase` is the most common test case implementation. It assumes
-that a particular test case consists of a single ebuild which is supposed
-to be run by PM.
-
-`EbuildTestCase` is declared in `pmstestsuite.library.case` module.
-
-By default, `EbuildTestCase` checks the result result by checking whether it was
-merged.
-
-
-Using EbuildTestCase
---------------------
-
-An example use case would be like:
-
- from pmstestsuite.library.case import EbuildTestCase
-
- class RandomExampleTest(EbuildTestCase):
- """ An absolutely random test. """
-
- supported_eapis = (2, 3, 4)
- relevant_eapis = (3, 4)
- expect_failure = True
-
- ebuild_vars = {
- 'HOMEPAGE': 'http://example.com/'
- }
- phase_funcs = {
- 'src_compile': [
- 'echo 11',
- 'die 12'
- ]
- }
-
-Where:
-
-- the class name is used to construct the test name (it would `random-example`
- here),
-- the docstring is used to form the ebuild `DESCRIPTION` (it can be overrode
- using `ebuild_vars['DESCRIPTION']`,
-- `supported_eapis` (_iterable of strings_) specifies for which EAPIs the test
- gives predictible (useful) results. It defaults to all supported EAPIs,
-- `relevant_eapis` (_iterable of strings_) specifies for which EAPIs the test
- will be performed by default (i.e. for which the results are expected
- to change). It defaults to a random EAPI from `supported_eapis`,
-- `expect_failure` (_bool_, default: _False_) specifies whether the ebuild is
- supposed to fail merge,
-- `ebuild_vars` (_dict of str -> str_) specifies additional global ebuild
- variables to declare in the ebuild,
-- `phase_funcs` (_dict of str -> iterable of strings_) specifies the contents of
- ebuild phase functions. Each iterable element represents a single line.
-
-
-Extending EbuildTestCase
-------------------------
-
-If you'd like to create more complex test case, you'll probably need to override
-some methods of the `EbuildTestCase` class. It could look like:
-
- from pmstestsuite.library.case import EbuildTestCase
-
- class MoreComplexExampleTest(EbuildTestCase):
- """ Now overriding methods! """
-
- relevant_eapis = (0, 1, 2)
-
- phase_funcs = {
- 'src_compile': [
- 'echo 11',
- '[[ ${EAPI} -eq 2 ]] && die 12'
- ]
- }
-
- def __init__(self, eapi):
- EbuildTestCase.__init__(self, eapi)
- self.phase_funcs['src_install'].append('echo nah(%d)!' % eapi)
-
- def check_result(self, pm):
- res = EbuildTestCase.check_result(self, pm)
- return (res == (self.eapi != 2))
-
-Overriding `__init__()` allows you to perform additional test modifications when
-it is instantiated for a particular EAPI. But remember to call superclass'
-`__init__()` as well as it sets `self.eapi` and deepcopies all the standard
-variables (like `phase_funcs` and `ebuild_vars`). Without that, the phase func
-change would be applied to a shared, class-defined variable!
-
-Overriding `check_result()` allows you to check the test results your own way.
-You can call superclass' `check_result()` to check whether the ebuild was merged
-into vdb (or the opposite, if `expect_failure` is _True_).
-
-Thus, the above example just adds a random, EAPI-dependant output into
-`src_install()`, and expects the test to succeed if `eapi != 2` and fail
-otherwise.
-
-<!-- vim:se syn=markdown tw=80 :-->
diff --git a/doc/library-format.md b/doc/library-format.md
deleted file mode 100644
index 4ba6066..0000000
--- a/doc/library-format.md
+++ /dev/null
@@ -1,92 +0,0 @@
-PMS Test Suite -- test library format
-=====================================
-
-Basic concepts
---------------
-
-The basic unit of a test suite is a _test case_. A test case forms a single
-Python class. That class is then instantiated into one or more test case
-instances.
-
-A _test case instance_ corresponds to a single actual test. Each instance
-provides functions to:
-
-1. merge any number of files to the test repository,
-2. clean up the system before and after performing the tests,
-3. merge the tests,
-4. check the test results.
-
-A number of tests builds up a test library. Each _test library_ consists of one
-or more Python packages, providing a number of Python modules. Those modules
-shall contain at least the test case classes, and a single `TestLibrary`
-subclass, providing a complete list of test cases.
-
-
-The main library module
------------------------
-
-Each library has to supply a _main library module_. Such a module has to exist
-in the `pmstestsuite.library` namespace. The module name (with that prefix
-stripped) is considered the _test library name_ and is passed as the `-l`
-argument.
-
-For example, `-l foobar` would correspond to a module called
-`pmstestsuite.library.foobar`.
-
-The main library module has to declare a subclass of
-`pmstestsuite.library.TestLibrary` class. The subclass has to override
-the `test_names` property with a list of test class names with module paths
-relative to the main module.
-
-Example main module of a test library:
-
- from pmstestsuite.library import TestLibrary
-
- class FoobarTestLibrary(TestLibrary):
- """
- Foo bar?
- """
-
- test_names=[
- 'foo.BarTest',
- 'bar.FooTest'
- ]
-
-The above example would load two tests:
-
-- `BarTest` from `pmstestsuite.library.foobar.foo`,
-- and `FooTest` from `pmstestsuite.library.foobar.bar`.
-
-
-The test class
---------------
-
-Each _test case_ has to be a subclass of `pmstestsuite.library.case.TestCase`.
-That class represents a most general test case with an interface described
-above. A particular subclass needs to override the following methods:
-
-- `get_output_files()` returning a dict representing files which should be
- output to the test repository (keys being filenames relative
- to the repository root and values being file contents),
-- `clean()` removing any merged test data before and after performing the test,
-- `start()` starting (scheduling) the actual test,
-- `check_result()` checking the test results. It should return True if the test
- succeeded and False otherwise.
-
-The three latter functions will be passed a `PackageManager` instance, which
-methods `merge()`, `unmerge()` and `installed` property can be used. For more
-information, please see the docs of `pmstestsuite.pm` module.
-
-In most cases, though, you won't be subclassing `TestCase` directly but using
-one of its subclasses defined in the `pmstestsuite.library` submodules.
-
-
-More information
-----------------
-
-1. `pydoc pmstestsuite.library`
-2. `pydoc pmstestsuite.library.case`
-3. `pydoc pmstestsuite.pm.PackageManager`
-4. `pydoc pmstestsuite.library.depend_case`
-
-<!-- vim:se syn=markdown tw=80 :-->
diff --git a/doc/pygments_style.css b/doc/pygments_style.css
deleted file mode 100644
index 145bc13..0000000
--- a/doc/pygments_style.css
+++ /dev/null
@@ -1,62 +0,0 @@
-.syntax .hll { background-color: #ffffcc }
-.syntax { background: #f0f0f0; }
-.syntax .c { color: #60a0b0; font-style: italic } /* Comment */
-.syntax .err { border: 1px solid #FF0000 } /* Error */
-.syntax .k { color: #007020; font-weight: bold } /* Keyword */
-.syntax .o { color: #666666 } /* Operator */
-.syntax .cm { color: #60a0b0; font-style: italic } /* Comment.Multiline */
-.syntax .cp { color: #007020 } /* Comment.Preproc */
-.syntax .c1 { color: #60a0b0; font-style: italic } /* Comment.Single */
-.syntax .cs { color: #60a0b0; background-color: #fff0f0 } /* Comment.Special */
-.syntax .gd { color: #A00000 } /* Generic.Deleted */
-.syntax .ge { font-style: italic } /* Generic.Emph */
-.syntax .gr { color: #FF0000 } /* Generic.Error */
-.syntax .gh { color: #000080; font-weight: bold } /* Generic.Heading */
-.syntax .gi { color: #00A000 } /* Generic.Inserted */
-.syntax .go { color: #808080 } /* Generic.Output */
-.syntax .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */
-.syntax .gs { font-weight: bold } /* Generic.Strong */
-.syntax .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
-.syntax .gt { color: #0040D0 } /* Generic.Traceback */
-.syntax .kc { color: #007020; font-weight: bold } /* Keyword.Constant */
-.syntax .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */
-.syntax .kn { color: #007020; font-weight: bold } /* Keyword.Namespace */
-.syntax .kp { color: #007020 } /* Keyword.Pseudo */
-.syntax .kr { color: #007020; font-weight: bold } /* Keyword.Reserved */
-.syntax .kt { color: #902000 } /* Keyword.Type */
-.syntax .m { color: #40a070 } /* Literal.Number */
-.syntax .s { color: #4070a0 } /* Literal.String */
-.syntax .na { color: #4070a0 } /* Name.Attribute */
-.syntax .nb { color: #007020 } /* Name.Builtin */
-.syntax .nc { color: #0e84b5; font-weight: bold } /* Name.Class */
-.syntax .no { color: #60add5 } /* Name.Constant */
-.syntax .nd { color: #555555; font-weight: bold } /* Name.Decorator */
-.syntax .ni { color: #d55537; font-weight: bold } /* Name.Entity */
-.syntax .ne { color: #007020 } /* Name.Exception */
-.syntax .nf { color: #06287e } /* Name.Function */
-.syntax .nl { color: #002070; font-weight: bold } /* Name.Label */
-.syntax .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */
-.syntax .nt { color: #062873; font-weight: bold } /* Name.Tag */
-.syntax .nv { color: #bb60d5 } /* Name.Variable */
-.syntax .ow { color: #007020; font-weight: bold } /* Operator.Word */
-.syntax .w { color: #bbbbbb } /* Text.Whitespace */
-.syntax .mf { color: #40a070 } /* Literal.Number.Float */
-.syntax .mh { color: #40a070 } /* Literal.Number.Hex */
-.syntax .mi { color: #40a070 } /* Literal.Number.Integer */
-.syntax .mo { color: #40a070 } /* Literal.Number.Oct */
-.syntax .sb { color: #4070a0 } /* Literal.String.Backtick */
-.syntax .sc { color: #4070a0 } /* Literal.String.Char */
-.syntax .sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */
-.syntax .s2 { color: #4070a0 } /* Literal.String.Double */
-.syntax .se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */
-.syntax .sh { color: #4070a0 } /* Literal.String.Heredoc */
-.syntax .si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */
-.syntax .sx { color: #c65d09 } /* Literal.String.Other */
-.syntax .sr { color: #235388 } /* Literal.String.Regex */
-.syntax .s1 { color: #4070a0 } /* Literal.String.Single */
-.syntax .ss { color: #517918 } /* Literal.String.Symbol */
-.syntax .bp { color: #007020 } /* Name.Builtin.Pseudo */
-.syntax .vc { color: #bb60d5 } /* Name.Variable.Class */
-.syntax .vg { color: #bb60d5 } /* Name.Variable.Global */
-.syntax .vi { color: #bb60d5 } /* Name.Variable.Instance */
-.syntax .il { color: #40a070 } /* Literal.Number.Integer.Long */
\ No newline at end of file
diff --git a/setup.py b/setup.py
index 3cea20c..097d124 100755
--- a/setup.py
+++ b/setup.py
@@ -3,7 +3,7 @@
# (c) 2011 Michał Górny <mgorny@gentoo.org>
# Released under the terms of the 2-clause BSD license.
-from distutils.core import setup, Command, Distribution
+from distutils.core import setup, Command
import os.path, subprocess, sys
@@ -18,77 +18,15 @@ class DocCommand(Command):
user_options = []
def initialize_options(self):
- self.docs = self.distribution.docs
- self.outfiles = []
+ pass
def finalize_options(self):
pass
def run(self):
- try:
- import markdown
- except ImportError:
- sys.stderr.write('Doc generation requires the markdown module:\nhttp://www.freewisdom.org/projects/python-markdown\n')
- sys.exit(1)
-
- class PMSTSExts(markdown.Extension):
- class TitleGrepper(markdown.treeprocessors.Treeprocessor):
- def __init__(self, ska):
- self._ska = ska
-
- def run(self, root):
- for c in root:
- if c.tag == "h1":
- self._ska.title = c.text
- break
- return root
-
- class HTMLSkelAdder(markdown.postprocessors.Postprocessor):
- title = ''
-
- def run(self, text):
- return '''<?xml version="1.0" encoding="utf-8"?>
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <style type="text/css">@import 'pygments_style.css';</style>
- <title>%s</title>
-</head>
-<body>
-''' % self.title + text + '''
-</body>
-</html>'''
-
- class LangAdder(markdown.treeprocessors.Treeprocessor):
- def run(self, root):
- for c in root.getiterator('pre'):
- children = c.getchildren()
- if len(children) == 1 and children[0].tag == 'code':
- children[0].text = ':::python\n' + children[0].text
-
- return root
-
- def extendMarkdown(self, md, md_globals):
- ska = self.HTMLSkelAdder()
- md.postprocessors.add('htmlskeladder', ska, '_end')
- md.treeprocessors.add('titlegrepper', self.TitleGrepper(ska), '_end')
- md.treeprocessors.add('langadder', self.LangAdder(), '<hilite')
-
- m = markdown.Markdown(extensions = ['codehilite(css_class=syntax)', PMSTSExts()])
- for f in self.docs:
- d = '%s.html' % os.path.splitext(f)[0]
- print('Creating %s (from %s)' % (d, f))
- m.convertFile(f, d)
- self.outfiles.append(d)
-
print('Creating API docs')
subprocess.check_call(['epydoc', '--verbose', '--html',
- '--output', os.path.join('doc', 'html'), 'pmstestsuite'])
-
- def get_inputs(self):
- return self.docs or []
-
- def get_outputs(self):
- return self.outfiles
+ '--output', 'doc', 'pmstestsuite'])
class TestCommand(Command):
description = 'run tests'
@@ -116,9 +54,6 @@ class TestCommand(Command):
res = r.run(tests)
sys.exit(0 if res.wasSuccessful() else 1)
-class DocDistribution(Distribution):
- docs = []
-
setup(
name = 'pms-test-suite',
version = PV,
@@ -137,10 +72,6 @@ setup(
scripts = [
'pms-tester'
],
- docs = [
- 'doc/library-format.md',
- 'doc/ebuild-test-case.md'
- ],
data_files = [
('/etc/dbus-1/system.d', ['org.gentoo.pmstestsuite.conf'])
],
@@ -160,6 +91,5 @@ setup(
cmdclass = {
'doc': DocCommand,
'test': TestCommand
- },
- distclass = DocDistribution
+ }
)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [gentoo-commits] proj/pms-test-suite:master commit in: /, doc/
@ 2011-06-22 8:18 Michał Górny
0 siblings, 0 replies; 3+ messages in thread
From: Michał Górny @ 2011-06-22 8:18 UTC (permalink / raw
To: gentoo-commits
commit: 27c9602f603f08ece5ed0b65fbad6624257eb368
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 22 07:44:23 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Jun 22 07:44:23 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=27c9602f
Add docs on EbuildTestCase use.
---
doc/ebuild-test-case.md | 98 +++++++++++++++++++++++++++++++++++++++++++++++
doc/library-format.md | 2 +-
setup.py | 3 +-
3 files changed, 101 insertions(+), 2 deletions(-)
diff --git a/doc/ebuild-test-case.md b/doc/ebuild-test-case.md
new file mode 100644
index 0000000..c297a2a
--- /dev/null
+++ b/doc/ebuild-test-case.md
@@ -0,0 +1,98 @@
+EbuildTestCase
+==============
+
+Quick description
+-----------------
+
+`EbuildTestCase` is the most common test case implementation. It assumes
+that a particular test case consists of a single ebuild which is supposed
+to be run by PM.
+
+`EbuildTestCase` is declared in `PMSTestSuite.library.case` module.
+
+By default, `EbuildTestCase` checks the result result by checking whether it was
+merged.
+
+
+Using EbuildTestCase
+--------------------
+
+An example use case would be like:
+
+ from PMSTestSuite.library.case import EbuildTestCase
+
+ class RandomExampleTest(EbuildTestCase):
+ """ An absolutely random test. """
+
+ relevant_eapis = (0, 1, 2, 4)
+ expect_failure = True
+
+ ebuild_vars = {
+ 'HOMEPAGE': 'http://example.com/'
+ }
+ phase_funcs = {
+ 'src_compile': [
+ 'echo 11',
+ 'die 12'
+ ]
+ }
+
+Where:
+
+- the class name is used to construct the test name (it would `random-example`
+ here),
+- the docstring is used to form the ebuild `DESCRIPTION` (it can be overrode
+ using `ebuild_vars['DESCRIPTION']`,
+- `relevant_eapis` (_iterable of strings_) specifies for which EAPIs the test
+ will be performed,
+- `expect_failure` (_bool_, default: _False_) specifies whether the ebuild is
+ supposed to fail merge,
+- `ebuild_vars` (_dict of str -> str_) specifies additional global ebuild
+ variables to declare in the ebuild,
+- `phase_funcs` (_dict of str -> iterable of strings_) specifies the contents of
+ ebuild phase functions. Each iterable element represents a single line.
+
+
+Extending EbuildTestCase
+------------------------
+
+If you'd like to create more complex test case, you'll probably need to override
+some methods of the `EbuildTestCase` class. It could look like:
+
+ from PMSTestSuite.library.case import EbuildTestCase
+
+ class MoreComplexExampleTest(EbuildTestCase):
+ """ Now overriding methods! """
+
+ relevant_eapis = (0, 1, 2)
+
+ phase_funcs = {
+ 'src_compile': [
+ 'echo 11',
+ '[[ ${EAPI} -eq 2 ]] && die 12'
+ ]
+ }
+
+ def __init__(self, eapi):
+ EbuildTestCase.__init__(self, eapi)
+ self.phase_funcs['src_install'].append('echo nah(%d)!' % eapi)
+
+ def check_result(self, pm):
+ res = EbuildTestCase.check_result(self, pm)
+ return (res == (self.eapi != 2))
+
+Overriding `__init__()` allows you to perform additional test modifications when
+it is instantiated for a particular EAPI. But remember to call superclass'
+`__init__()` as well as it sets `self.eapi` and deepcopies all the standard
+variables (like `phase_funcs` and `ebuild_vars`). Without that, the phase func
+change would be applied to a shared, class-defined variable!
+
+Overriding `check_result()` allows you to check the test results your own way.
+You can call superclass' `check_result()` to check whether the ebuild was merged
+into vdb (or the opposite, if `expect_failure` is _True_).
+
+Thus, the above example just adds a random, EAPI-dependant output into
+`src_install()`, and expects the test to succeed if `eapi != 2` and fail
+otherwise.
+
+<!-- vim:se syn=markdown tw=80 :-->
diff --git a/doc/library-format.md b/doc/library-format.md
index 09ad8e3..265e631 100644
--- a/doc/library-format.md
+++ b/doc/library-format.md
@@ -89,4 +89,4 @@ More information
3. `pydoc PMSTestSuite.pm.PackageManager`
4. `pydoc PMSTestSuite.library.depend_case`
-<!-- vim:se syn=markdown :-->
+<!-- vim:se syn=markdown tw=80 :-->
diff --git a/setup.py b/setup.py
index a9beac7..a0e47ac 100755
--- a/setup.py
+++ b/setup.py
@@ -124,7 +124,8 @@ setup(
'pms-tester'
],
docs = [
- 'doc/library-format.md'
+ 'doc/library-format.md',
+ 'doc/ebuild-test-case.md'
],
classifiers = [
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-07-25 15:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-22 11:50 [gentoo-commits] proj/pms-test-suite:master commit in: /, doc/ Michał Górny
-- strict thread matches above, loose matches on Subject: below --
2011-07-25 15:37 Michał Górny
2011-06-22 8:18 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