Skip to content

Commit

Permalink
Add in test dependencies, enabled by the use flag 'test'
Browse files Browse the repository at this point in the history
  • Loading branch information
allenh1 committed Jan 26, 2018
1 parent 8da764e commit db458ab
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
21 changes: 20 additions & 1 deletion superflore/generators/ebuild/ebuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ def __init__(self):
self.rdepends_external = list()
self.depends = list()
self.depends_external = list()
self.tdepends = list()
self.tdepends_external = list()
self.distro = None
self.cmake_package = True
self.base_yml = None
Expand Down Expand Up @@ -86,6 +88,12 @@ def add_run_depend(self, rdepend, internal=True):
else:
self.rdepends_external.append(rdepend)

def add_test_depend(self, tdepend, internal=True):
if not internal:
self.tdepends_external.append(tdepend)
else:
self.tdepends.append(tdepend)

def add_keyword(self, keyword, stable=False):
self.keys.append(ebuild_keyword(keyword, stable))

Expand Down Expand Up @@ -138,10 +146,15 @@ def get_ebuild_text(self, distributor, license_text):
ret += "KEYWORDS=\""
ret += ' '.join([key.to_string() for key in self.keys])
ret += "\"\n"
if len(self.tdepends) or len(self.tdepends_external):
ret += 'IUSE="test"\n'
# RDEPEND
ret += "RDEPEND=\"\n"
for rdep in sorted(self.rdepends):
ret += " " + "ros-" + self.distro + "/" + rdep + "\n"
# internal test dependencies
for tdep in sorted(self.tdepends):
ret += " " + "test? ros-" + self.distro + "/" + tdep + "\n"
for rdep in sorted(self.rdepends_external):
try:
for res in resolve_dep(rdep, 'gentoo')[0]:
Expand All @@ -152,8 +165,14 @@ def get_ebuild_text(self, distributor, license_text):
ret += " " + res + "\n"
except UnresolvedDependency:
self.unresolved_deps.append(rdep)
# external test dependencies
for tdep in sorted(self.tdepends_external):
try:
for res in resolve_dep(tdep, 'gentoo')[0]:
ret += " test? " + res + "\n"
except UnresolvedDependency:
self.unresolved_deps.append(tdep)
ret += "\"\n"

# DEPEND
ret += "DEPEND=\"${RDEPEND}\n"
for bdep in sorted(self.depends):
Expand Down
5 changes: 5 additions & 0 deletions superflore/generators/ebuild/gen_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ def _gen_ebuild_for_package(distro, pkg_name, pkg,
pkg_buildtool_deps = pkg_dep_walker.get_depends(pkg_name, "buildtool")
pkg_build_deps = pkg_dep_walker.get_depends(pkg_name, "build")
pkg_run_deps = pkg_dep_walker.get_depends(pkg_name, "run")
pkg_test_deps = pkg_dep_walker.get_depends(pkg_name, "test")

pkg_keywords = ['x86', 'amd64', 'arm', 'arm64']

Expand All @@ -175,6 +176,10 @@ def _gen_ebuild_for_package(distro, pkg_name, pkg,
for tdep in pkg_buildtool_deps:
pkg_ebuild.add_build_depend(tdep, tdep in pkg_names[0])

# add test dependencies
for test_dep in pkg_test_deps:
pkg_ebuild.add_test_depend(test_dep, test_dep in pkg_names[0])

# add keywords
for key in pkg_keywords:
pkg_ebuild.add_keyword(key)
Expand Down

0 comments on commit db458ab

Please sign in to comment.