Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions lib/rift/Package.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
Class to manipulate packages and package tests with Rift.
"""

import glob
import logging
import os
import shutil
Expand Down Expand Up @@ -170,10 +169,24 @@ def load(self, infopath=None):
self.sources = set(os.listdir(self.sourcesdir))

def tests(self):
"""An iterator over Test objects for each test files."""
testspattern = os.path.join(self.testsdir, '*.sh')
for testpath in glob.glob(testspattern):
yield Test(testpath)
"""
Return a Test object for each test present
in the "tests" directory of a Rift Package.
A test is any kind of file which the execution
permission.
"""

if not os.path.isdir(self.testsdir):
logging.info('%s not found, this package has no custom tests', self.testsdir)
return

for filepath in os.scandir(self.testsdir):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest: handling tests in sub-directories would be nice too, in case that ever happens. A simple recursive call should be enough.

if os.access(filepath, os.X_OK):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: if for any reason there are sub-directories, this condition will most likely be valid, as most directories as execution rights

logging.info("found '%s' executable file", filepath)
yield Test(filepath)

else:
logging.debug(f"'%s' is not executable, not considered as a test", filepath)

def build_srpm(self, mock, sign):
"""
Expand Down