Skip to content

Commit

Permalink
Add test for presence of python without -s
Browse files Browse the repository at this point in the history
  • Loading branch information
Flamefire committed Sep 12, 2024
1 parent 4d19ad5 commit 238f3de
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/easyconfigs/easyconfigs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1181,6 +1181,19 @@ def test_pr_python_packages(self):
sanity_pip_check = ec.get('sanity_pip_check') or exts_default_options.get('sanity_pip_check')
if not sanity_pip_check and not any(re.match(regex, ec_fn) for regex in whitelist_pip_check):
failing_checks.append("sanity_pip_check should be enabled in %s" % ec_fn)
else:
# Make sure the user packages in $HOME/.local/lib/python*/ are ignored when running python commands
# For the EasyBlocks above this is handled automatically by setting $PYTHONNOUSERSITE
# Detect any code or module invocation (-m or -c), `python cc` and `python <filepath>`
python_re = re.compile(r'\bpython (-c|-m|cc|[^ ]*\w+.py) ')
# Detect if `-s` is present, potentially after other switches
ignore_user_switch_re = re.compile(r'\bpython (-\w+ )*-s ')
# Check the raw lines as the issue could be anywhere, not only in `sanity_check_commands`,
# e.g. `runtest`, `installopts`, `configopts`, ...
for line in read_file(ec.path).splitlines():
if python_re.search(line) and not ignore_user_switch_re.search(line):
failing_checks.append("Python invocation in '%s' should use the '-s' parameter in %s"
% (line, ec_fn))

if failing_checks:
self.fail('\n'.join(failing_checks))
Expand Down

0 comments on commit 238f3de

Please sign in to comment.