public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/tests/resolver/, lib/portage/tests/dbapi/
Date: Sat,  2 May 2020 22:03:04 +0000 (UTC)	[thread overview]
Message-ID: <1588456850.e4b3d6e57855ae635e0d9fffddb195d8f819e7c9.zmedico@gentoo> (raw)

commit:     e4b3d6e57855ae635e0d9fffddb195d8f819e7c9
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat May  2 21:41:30 2020 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat May  2 22:00:50 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=e4b3d6e5

AuxdbTestCase: test eclass inheritance

Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 lib/portage/tests/dbapi/test_auxdb.py            | 32 +++++++++++++++++++-----
 lib/portage/tests/resolver/ResolverPlayground.py | 16 +++++++++---
 2 files changed, 38 insertions(+), 10 deletions(-)

diff --git a/lib/portage/tests/dbapi/test_auxdb.py b/lib/portage/tests/dbapi/test_auxdb.py
index cfcabc8bb..85d64c15e 100644
--- a/lib/portage/tests/dbapi/test_auxdb.py
+++ b/lib/portage/tests/dbapi/test_auxdb.py
@@ -34,24 +34,44 @@ class AuxdbTestCase(TestCase):
 	def _test_mod(self, auxdbmodule):
 		ebuilds = {
 			"cat/A-1": {
-				"EAPI": "7"
+				"EAPI": "7",
+				"MISC_CONTENT": "inherit foo",
 			},
 			"cat/B-1": {
-				"EAPI": "7"
+				"EAPI": "7",
+				"MISC_CONTENT": "inherit foo",
 			},
 		}
 
-		playground = ResolverPlayground(ebuilds=ebuilds,
+		ebuild_inherited = frozenset(["bar", "foo"])
+		eclass_defined_phases = "prepare"
+		eclass_depend = "bar/foo"
+
+		eclasses = {
+			"foo": (
+				"inherit bar",
+			),
+			"bar": (
+				"EXPORT_FUNCTIONS src_prepare",
+				"DEPEND=\"{}\"".format(eclass_depend),
+				"bar_src_prepare() { default; }",
+			),
+		}
+
+		playground = ResolverPlayground(ebuilds=ebuilds, eclasses=eclasses,
 			user_config={'modules': ('portdbapi.auxdbmodule = %s' % auxdbmodule,)})
 
 		portdb = playground.trees[playground.eroot]["porttree"].dbapi
 
 		loop = asyncio._wrap_loop()
-		loop.run_until_complete(self._test_mod_async(ebuilds, portdb))
+		loop.run_until_complete(self._test_mod_async(ebuilds, ebuild_inherited, eclass_defined_phases, eclass_depend, portdb))
 
 	@coroutine
-	def _test_mod_async(self, ebuilds, portdb):
+	def _test_mod_async(self, ebuilds, ebuild_inherited, eclass_defined_phases, eclass_depend, portdb):
 
 		for cpv, metadata in ebuilds.items():
-			eapi, = yield portdb.async_aux_get(cpv, ['EAPI'])
+			defined_phases, depend, eapi, inherited = yield portdb.async_aux_get(cpv, ['DEFINED_PHASES', 'DEPEND', 'EAPI', 'INHERITED'])
+			self.assertEqual(defined_phases, eclass_defined_phases)
+			self.assertEqual(depend, eclass_depend)
 			self.assertEqual(eapi, metadata['EAPI'])
+			self.assertEqual(frozenset(inherited.split()), ebuild_inherited)

diff --git a/lib/portage/tests/resolver/ResolverPlayground.py b/lib/portage/tests/resolver/ResolverPlayground.py
index 0456ce2e2..98831e000 100644
--- a/lib/portage/tests/resolver/ResolverPlayground.py
+++ b/lib/portage/tests/resolver/ResolverPlayground.py
@@ -67,7 +67,7 @@ class ResolverPlayground(object):
 """
 
 	def __init__(self, ebuilds={}, binpkgs={}, installed={}, profile={}, repo_configs={}, \
-		user_config={}, sets={}, world=[], world_sets=[], distfiles={},
+		user_config={}, sets={}, world=[], world_sets=[], distfiles={}, eclasses={},
 		eprefix=None, targetroot=False, debug=False):
 		"""
 		ebuilds: cpv -> metadata mapping simulating available ebuilds.
@@ -159,7 +159,7 @@ class ResolverPlayground(object):
 		self._create_ebuilds(ebuilds)
 		self._create_binpkgs(binpkgs)
 		self._create_installed(installed)
-		self._create_profile(ebuilds, installed, profile, repo_configs, user_config, sets)
+		self._create_profile(ebuilds, eclasses, installed, profile, repo_configs, user_config, sets)
 		self._create_world(world, world_sets)
 
 		self.settings, self.trees = self._load_config()
@@ -346,7 +346,7 @@ class ResolverPlayground(object):
 				with open(ebuild_path, 'rb') as inputfile:
 					f.write(inputfile.read())
 
-	def _create_profile(self, ebuilds, installed, profile, repo_configs, user_config, sets):
+	def _create_profile(self, ebuilds, eclasses, installed, profile, repo_configs, user_config, sets):
 
 		user_config_dir = os.path.join(self.eroot, USER_CONFIG_PATH)
 
@@ -404,7 +404,15 @@ class ResolverPlayground(object):
 							f.write("masters =\n")
 
 			#Create $profile_dir/eclass (we fail to digest the ebuilds if it's not there)
-			os.makedirs(os.path.join(repo_dir, "eclass"))
+			eclass_dir = os.path.join(repo_dir, "eclass")
+			os.makedirs(eclass_dir)
+
+			for eclass_name, eclass_content in eclasses.items():
+				with open(os.path.join(eclass_dir, "{}.eclass".format(eclass_name)), 'wt') as f:
+					if isinstance(eclass_content, basestring):
+						eclass_content = [eclass_content]
+					for line in eclass_content:
+						f.write("{}\n".format(line))
 
 			# Temporarily write empty value of masters until it becomes default.
 			if not repo_config or "layout.conf" not in repo_config:


                 reply	other threads:[~2020-05-02 22:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1588456850.e4b3d6e57855ae635e0d9fffddb195d8f819e7c9.zmedico@gentoo \
    --to=zmedico@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox