Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter out tests with no programming environments #319

Merged
merged 9 commits into from
Jun 15, 2018
5 changes: 3 additions & 2 deletions reframe/frontend/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,9 @@ def main():
# Filter checks by prgenv
if not options.skip_prgenv_check:
checks_matched = filter(
lambda c: c if all(c.supports_environ(e)
for e in options.prgenv) else None,
lambda c: c if (c.valid_prog_environs
and all(c.supports_environ(e)
for e in options.prgenv)) else None,
Copy link
Contributor

Choose a reason for hiding this comment

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

This lambda gets a bit too complicated. Since this operation is quite useful, I suggest writing a function in utility doing that thing:

def allx(iterable):
    # we should check here specifically if `iterable` is actually an iterable, as real all() does
    if not iterable:
        return False

    return all(iterable)

Would it also make sense to provide a deferrable version of this function in this PR, too?

checks_matched
)

Expand Down
15 changes: 12 additions & 3 deletions unittests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,19 +257,19 @@ def test_checkpath_recursion(self):
self.checkpath = []
returncode, stdout, _ = self._run_reframe()
num_checks_default = re.search(
'Found (\d+) check', stdout, re.MULTILINE).group(1)
r'Found (\d+) check', stdout, re.MULTILINE).group(1)

self.checkpath = ['checks/']
self.more_options = ['-R']
returncode, stdout, _ = self._run_reframe()
num_checks_in_checkdir = re.search(
'Found (\d+) check', stdout, re.MULTILINE).group(1)
r'Found (\d+) check', stdout, re.MULTILINE).group(1)
self.assertEqual(num_checks_in_checkdir, num_checks_default)

self.more_options = []
returncode, stdout, stderr = self._run_reframe()
num_checks_in_checkdir = re.search(
'Found (\d+) check', stdout, re.MULTILINE).group(1)
r'Found (\d+) check', stdout, re.MULTILINE).group(1)
self.assertEqual('0', num_checks_in_checkdir)

def test_same_output_stage_dir(self):
Expand Down Expand Up @@ -317,3 +317,12 @@ def test_timestamp_option(self):
returncode, stdout, _ = self._run_reframe()
self.assertNotEqual(0, returncode)
self.assertIn(timefmt, stdout)

def test_list_check_with_empty_prgenvs(self):
self.checkpath = ['unittests/resources/checks/frontend_checks.py']
self.action = 'list'
self.environs = []
self.more_options = ['-n', 'NoPrgEnvCheck']
returncode, stdout, _ = self._run_reframe()
self.assertIn('Found 0 check(s)', stdout)
self.assertEqual(0, returncode)