From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QZIeA-0002kq-M1 for garchives@archives.gentoo.org; Wed, 22 Jun 2011 08:18:51 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A84151C0CD; Wed, 22 Jun 2011 08:18:28 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 5EEB81C13A for ; Wed, 22 Jun 2011 08:18:28 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id D462A1B4002 for ; Wed, 22 Jun 2011 08:18:27 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 9E34980040 for ; Wed, 22 Jun 2011 08:18:26 +0000 (UTC) From: "Michał Górny" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" Message-ID: <27c9602f603f08ece5ed0b65fbad6624257eb368.mgorny@gentoo> Subject: [gentoo-commits] proj/pms-test-suite:master commit in: /, doc/ X-VCS-Repository: proj/pms-test-suite X-VCS-Files: doc/ebuild-test-case.md doc/library-format.md setup.py X-VCS-Directories: / doc/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: 27c9602f603f08ece5ed0b65fbad6624257eb368 Date: Wed, 22 Jun 2011 08:18:26 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 7be2f554097e05aa6c71bf3afb954cfa commit: 27c9602f603f08ece5ed0b65fbad6624257eb368 Author: Micha=C5=82 G=C3=B3rny gentoo org> AuthorDate: Wed Jun 22 07:44:23 2011 +0000 Commit: Micha=C5=82 G=C3=B3rny gentoo org> CommitDate: Wed Jun 22 07:44:23 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/pms-test-suit= e.git;a=3Dcommit;h=3D27c9602f 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 +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Quick description +----------------- + +`EbuildTestCase` is the most common test case implementation. It assumes +that a particular test case consists of a single ebuild which is suppose= d +to be run by PM. + +`EbuildTestCase` is declared in `PMSTestSuite.library.case` module. + +By default, `EbuildTestCase` checks the result result by checking whethe= r 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 =3D (0, 1, 2, 4) + expect_failure =3D True + + ebuild_vars =3D { + 'HOMEPAGE': 'http://example.com/' + } + phase_funcs =3D { + 'src_compile': [ + 'echo 11', + 'die 12' + ] + } + +Where: + +- the class name is used to construct the test name (it would `random-ex= ample` + here), +- the docstring is used to form the ebuild `DESCRIPTION` (it can be over= rode + 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 ebui= ld is + supposed to fail merge, +- `ebuild_vars` (_dict of str -> str_) specifies additional global ebuil= d + variables to declare in the ebuild, +- `phase_funcs` (_dict of str -> iterable of strings_) specifies the con= tents 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 =3D (0, 1, 2) + + phase_funcs =3D { + '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 =3D EbuildTestCase.check_result(self, pm) + return (res =3D=3D (self.eapi !=3D 2)) + +Overriding `__init__()` allows you to perform additional test modificati= ons when +it is instantiated for a particular EAPI. But remember to call superclas= s' +`__init__()` as well as it sets `self.eapi` and deepcopies all the stand= ard +variables (like `phase_funcs` and `ebuild_vars`). Without that, the phas= e func +change would be applied to a shared, class-defined variable! + +Overriding `check_result()` allows you to check the test results your ow= n way. +You can call superclass' `check_result()` to check whether the ebuild wa= s 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 !=3D 2` and fa= il +otherwise. + + 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` =20 - + 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 =3D [ - 'doc/library-format.md' + 'doc/library-format.md', + 'doc/ebuild-test-case.md' ], =20 classifiers =3D [