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 <gentoo-commits+bounces-346943-garchives=archives.gentoo.org@lists.gentoo.org>)
	id 1QOTgJ-0006Xo-UF
	for garchives@archives.gentoo.org; Mon, 23 May 2011 11:52:20 +0000
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 0FE59E027D;
	Mon, 23 May 2011 11:52:12 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	by pigeon.gentoo.org (Postfix) with ESMTP id D03A2E027D
	for <gentoo-commits@lists.gentoo.org>; Mon, 23 May 2011 11:52:12 +0000 (UTC)
Received: from pelican.gentoo.org (unknown [66.219.59.40])
	(using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id CDA401B400E
	for <gentoo-commits@lists.gentoo.org>; Mon, 23 May 2011 11:52:11 +0000 (UTC)
Received: from localhost.localdomain (localhost [127.0.0.1])
	by pelican.gentoo.org (Postfix) with ESMTP id 0F9D980505
	for <gentoo-commits@lists.gentoo.org>; Mon, 23 May 2011 11:52:11 +0000 (UTC)
From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" <mgorny@gentoo.org>
Message-ID: <a237c87d8da957b3d0a1904294b1645ba9204d91.mgorny@gentoo>
Subject: [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/library/
X-VCS-Repository: proj/pms-test-suite
X-VCS-Files: PMSTestSuite/library/__init__.py PMSTestSuite/library/case.py
X-VCS-Directories: PMSTestSuite/library/
X-VCS-Committer: mgorny
X-VCS-Committer-Name: Michał Górny
X-VCS-Revision: a237c87d8da957b3d0a1904294b1645ba9204d91
Date: Mon, 23 May 2011 11:52:11 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: quoted-printable
X-Archives-Salt: 
X-Archives-Hash: 165f111701c15cf22b9038e132a9a3ae

commit:     a237c87d8da957b3d0a1904294b1645ba9204d91
Author:     Micha=C5=82 G=C3=B3rny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon May 23 11:52:08 2011 +0000
Commit:     Micha=C5=82 G=C3=B3rny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon May 23 11:52:08 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=3Dproj/pms-test-suit=
e.git;a=3Dcommit;h=3Da237c87d

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/__in=
it__.py
index 8447d04..ba6867a 100644
--- a/PMSTestSuite/library/__init__.py
+++ b/PMSTestSuite/library/__init__.py
@@ -9,6 +9,8 @@
 >>> t =3D [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': ...}
 """
=20
 from PMSTestSuite.library.case import TestCase
@@ -32,7 +34,8 @@ class TestLibrary(object):
 			modname =3D '%s.%s' % (self.modname, modname)
 			mod =3D __import__(modname, {}, {}, [clsname], 0)
 			cls =3D getattr(mod, clsname)
-			yield cls()
+			for i in cls.inst_all():
+				yield i
=20
 	def __init__(self, modname):
 		self.modname =3D 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=C5=82 G=C3=B3rny <mgorny@gentoo.org>
 # Released under the terms of the 2-clause BSD license.
=20
+ebuild_header =3D '''# 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
=20
 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'] =3D eapi
+			yield cls(*args, **kwargs)
+
+	def __init__(self, eapi):
+		self.eapi =3D eapi
+
+	def get_output_files(self):
+		pn =3D self.__class__.__name__.lower()
+		fn =3D 'pms-test/%s/%s-%s.ebuild' % (pn, pn, self.eapi)
+		contents =3D [ebuild_header]
+
+		for k, v in self.ebuild_vars.items():
+			contents.append('%s=3D"%s"\n' % (k, v)) # XXX: escaping
+
+		for f, lines in self.phase_funcs.items():
+			if f =3D=3D '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)}