Skip to content

Commit

Permalink
Adapt test_toy_group_check now Tcl modulefile may support group check
Browse files Browse the repository at this point in the history
  • Loading branch information
xdelaruelle committed Dec 28, 2023
1 parent 6e674b2 commit 58c5afa
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions test/framework/toy_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
from easybuild.tools.filetools import adjust_permissions, change_dir, copy_file, mkdir, move_file
from easybuild.tools.filetools import read_file, remove_dir, remove_file, which, write_file
from easybuild.tools.module_generator import ModuleGeneratorTcl
from easybuild.tools.modules import Lmod
from easybuild.tools.modules import Lmod, EnvironmentModules
from easybuild.tools.py2vs3 import reload, string_type
from easybuild.tools.run import run_cmd
from easybuild.tools.utilities import nub
Expand Down Expand Up @@ -749,9 +749,29 @@ def test_toy_group_check(self):
self.mock_stdout(False)

if get_module_syntax() == 'Tcl':
pattern = "Can't generate robust check in TCL modules for users belonging to group %s." % group_name
regex = re.compile(pattern, re.M)
self.assertTrue(regex.search(outtxt), "Pattern '%s' found in: %s" % (regex.pattern, outtxt))
module_version = LooseVersion(self.modtool.version)
if isinstance(self.modtool, EnvironmentModules) and module_version >= LooseVersion('4.6.0'):
toy_mod = os.path.join(self.test_installpath, 'modules', 'all', 'toy', '0.0')
toy_mod_txt = read_file(toy_mod)

if isinstance(group, tuple):
group_name = group[0]
error_msg_pattern = "Hey, you're not in the '%s' group!" % group_name
else:
group_name = group
error_msg_pattern = "You are not part of '%s' group of users" % group_name

pattern = '\n'.join([
r'^if \{ \!\[ module-info usergroups %s \] \} \{' % group_name,
r' error "%s[^"]*"' % error_msg_pattern,
r'\}$',
])
regex = re.compile(pattern, re.M)
self.assertTrue(regex.search(outtxt), "Pattern '%s' found in: %s" % (regex.pattern, toy_mod_txt))
else:
pattern = "Can't generate robust check in Tcl modules for users belonging to group %s." % group_name
regex = re.compile(pattern, re.M)
self.assertTrue(regex.search(outtxt), "Pattern '%s' found in: %s" % (regex.pattern, outtxt))

elif get_module_syntax() == 'Lua':
lmod_version = os.getenv('LMOD_VERSION', 'NOT_FOUND')
Expand Down

0 comments on commit 58c5afa

Please sign in to comment.