Skip to content

Commit 794c068

Browse files
committed
fix tests that got broken by enabling use of depends_on (instead of load) statement in generated environment modules by default
1 parent f27a7fc commit 794c068

File tree

3 files changed

+39
-22
lines changed

3 files changed

+39
-22
lines changed

test/framework/easyblock.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,7 @@ def test_make_module_dep(self):
743743
" ('FFTW', '3.3.7'),",
744744
" ('OpenBLAS', '0.2.20', '', ('GCC', '6.4.0-2.28')),",
745745
']',
746+
'module_depends_on = False',
746747
])
747748
self.writeEC()
748749
eb = EasyBlock(EasyConfig(self.eb_file))
@@ -856,10 +857,10 @@ def test_make_module_dep_hmns(self):
856857
with self.mocked_stdout_stderr():
857858
mod_dep_txt = eb.make_module_dep()
858859
for mod in ['GCC/6.4.0-2.28', 'OpenMPI/2.1.2']:
859-
regex = re.compile('load.*%s' % mod)
860+
regex = re.compile('(load|depends[-_]on).*%s' % mod)
860861
self.assertFalse(regex.search(mod_dep_txt), "Pattern '%s' found in: %s" % (regex.pattern, mod_dep_txt))
861862

862-
regex = re.compile('load.*FFTW/3.3.7')
863+
regex = re.compile('(load|depends[-_]on).*FFTW/3.3.7')
863864
self.assertTrue(regex.search(mod_dep_txt), "Pattern '%s' found in: %s" % (regex.pattern, mod_dep_txt))
864865

865866
def test_make_module_dep_of_dep_hmns(self):
@@ -1344,27 +1345,27 @@ def test_make_module_step(self):
13441345

13451346
for (name, ver) in [('GCC', '6.4.0-2.28')]:
13461347
if get_module_syntax() == 'Tcl':
1347-
regex = re.compile(r'^\s*module load %s\s*$' % os.path.join(name, ver), re.M)
1348+
regex = re.compile(r'^\s*(module load|depends-on) %s\s*$' % os.path.join(name, ver), re.M)
13481349
elif get_module_syntax() == 'Lua':
1349-
regex = re.compile(r'^\s*load\("%s"\)$' % os.path.join(name, ver), re.M)
1350+
regex = re.compile(r'^\s*(load|depends_on)\("%s"\)$' % os.path.join(name, ver), re.M)
13501351
else:
13511352
self.fail("Unknown module syntax: %s" % get_module_syntax())
13521353
self.assertTrue(regex.search(txt), "Pattern %s found in %s" % (regex.pattern, txt))
13531354

13541355
for (name, ver) in [('test', '1.2.3')]:
13551356
if get_module_syntax() == 'Tcl':
1356-
regex = re.compile(r'^\s*module load %s/.%s\s*$' % (name, ver), re.M)
1357+
regex = re.compile(r'^\s*(module load|depends-on) %s/.%s\s*$' % (name, ver), re.M)
13571358
elif get_module_syntax() == 'Lua':
1358-
regex = re.compile(r'^\s*load\("%s/.%s"\)$' % (name, ver), re.M)
1359+
regex = re.compile(r'^\s*(load|depends_on)\("%s/.%s"\)$' % (name, ver), re.M)
13591360
else:
13601361
self.fail("Unknown module syntax: %s" % get_module_syntax())
13611362
self.assertTrue(regex.search(txt), "Pattern %s found in %s" % (regex.pattern, txt))
13621363

13631364
for (name, ver) in [('OpenMPI', '2.1.2-GCC-6.4.0-2.28')]:
13641365
if get_module_syntax() == 'Tcl':
1365-
regex = re.compile(r'^\s*module load %s/.?%s\s*$' % (name, ver), re.M)
1366+
regex = re.compile(r'^\s*(module load|depends-on) %s/.?%s\s*$' % (name, ver), re.M)
13661367
elif get_module_syntax() == 'Lua':
1367-
regex = re.compile(r'^\s*load\("%s/.?%s"\)$' % (name, ver), re.M)
1368+
regex = re.compile(r'^\s*(load|depends_on)\("%s/.?%s"\)$' % (name, ver), re.M)
13681369
else:
13691370
self.fail("Unknown module syntax: %s" % get_module_syntax())
13701371
self.assertFalse(regex.search(txt), "Pattern '%s' *not* found in %s" % (regex.pattern, txt))

test/framework/easyconfig.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4596,6 +4596,8 @@ def test_recursive_module_unload(self):
45964596
toy_ec = os.path.join(test_ecs_dir, 'f', 'foss', 'foss-2018a.eb')
45974597
test_ec = os.path.join(self.test_prefix, 'test.eb')
45984598
test_ec_txt = read_file(toy_ec)
4599+
# this test only makes sense if depends_on is not used
4600+
test_ec_txt += '\nmodule_depends_on = False'
45994601
write_file(test_ec, test_ec_txt)
46004602

46014603
test_module = os.path.join(self.test_installpath, 'modules', 'all', 'foss', '2018a')
@@ -4635,6 +4637,8 @@ def test_recursive_module_unload(self):
46354637
# recursive_module_unload easyconfig parameter is honored
46364638
test_ec_bis = os.path.join(self.test_prefix, 'test_bis.eb')
46374639
test_ec_bis_txt = read_file(toy_ec) + '\nrecursive_module_unload = True'
4640+
# this test only makes sense if depends_on is not used
4641+
test_ec_bis_txt += '\nmodule_depends_on = False'
46384642
write_file(test_ec_bis, test_ec_bis_txt)
46394643

46404644
ec_bis = EasyConfig(test_ec_bis)
@@ -4667,6 +4671,8 @@ def test_recursive_module_unload(self):
46674671
self.assertTrue(build_option('recursive_mod_unload'))
46684672
test_ec_bis = os.path.join(self.test_prefix, 'test_bis.eb')
46694673
test_ec_bis_txt = read_file(toy_ec) + '\nrecursive_module_unload = False'
4674+
# this test only makes sense if depends_on is not used
4675+
test_ec_bis_txt += '\nmodule_depends_on = False'
46704676
write_file(test_ec_bis, test_ec_bis_txt)
46714677
ec_bis = EasyConfig(test_ec_bis)
46724678
self.assertEqual(ec_bis['recursive_module_unload'], False)

test/framework/toy_build.py

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -861,9 +861,9 @@ def test_toy_hierarchical(self):
861861
# check that toolchain load is expanded to loads for toolchain dependencies,
862862
# except for the ones that extend $MODULEPATH to make the toy module available
863863
if get_module_syntax() == 'Tcl':
864-
load_regex_template = "load %s"
864+
load_regex_template = "(load|depends-on) %s"
865865
elif get_module_syntax() == 'Lua':
866-
load_regex_template = r'load\("%s/.*"\)'
866+
load_regex_template = r'(load|depends_on)\("%s/.*"\)'
867867
else:
868868
self.fail("Unknown module syntax: %s" % get_module_syntax())
869869

@@ -892,7 +892,7 @@ def test_toy_hierarchical(self):
892892

893893
# no dependencies or toolchain => no module load statements in module file
894894
modtxt = read_file(toy_module_path)
895-
self.assertFalse(re.search("module load", modtxt))
895+
self.assertFalse(re.search("(module load|depends-on)", modtxt))
896896
os.remove(toy_module_path)
897897
# test module path with GCC/6.4.0-2.28 build, pretend to be an MPI lib by setting moduleclass
898898
extra_args = [
@@ -952,7 +952,7 @@ def test_toy_hierarchical(self):
952952

953953
# no dependencies or toolchain => no module load statements in module file
954954
modtxt = read_file(toy_module_path)
955-
self.assertFalse(re.search("module load", modtxt))
955+
self.assertFalse(re.search("(module load|depends-on)", modtxt))
956956
os.remove(toy_module_path)
957957

958958
# test module path with system/system build, pretend to be a compiler by setting moduleclass
@@ -1727,8 +1727,10 @@ def test_module_only(self):
17271727

17281728
# make sure load statements for dependencies are included in additional module file generated with --module-only
17291729
modtxt = read_file(toy_mod)
1730-
self.assertTrue(re.search('load.*intel/2018a', modtxt), "load statement for intel/2018a found in module")
1731-
self.assertTrue(re.search('load.*GCC/6.4.0-2.28', modtxt), "load statement for GCC/6.4.0-2.28 found in module")
1730+
self.assertTrue(re.search('(load|depends[-_]on).*intel/2018a', modtxt),
1731+
"load statement for intel/2018a found in module: %s" % modtxt)
1732+
self.assertTrue(re.search('(load|depends[-_]on).*GCC/6.4.0-2.28', modtxt),
1733+
"load statement for GCC/6.4.0-2.28 found in module: %s" % modtxt)
17321734

17331735
os.remove(toy_mod)
17341736

@@ -1770,7 +1772,8 @@ def test_module_only(self):
17701772

17711773
# make sure load statements for dependencies are included
17721774
modtxt = read_file(toy_core_mod)
1773-
self.assertTrue(re.search('load.*intel/2018a', modtxt), "load statement for intel/2018a found in module")
1775+
self.assertTrue(re.search('(load|depends[-_]on).*intel/2018a', modtxt),
1776+
"load statement for intel/2018a found in module: %s" % modtxt)
17741777

17751778
# Test we can create a module even for an installation where we don't have write permissions
17761779
os.remove(toy_core_mod)
@@ -1788,7 +1791,8 @@ def test_module_only(self):
17881791

17891792
# make sure load statements for dependencies are included
17901793
modtxt = read_file(toy_core_mod)
1791-
self.assertTrue(re.search('load.*intel/2018a', modtxt), "load statement for intel/2018a found in module")
1794+
self.assertTrue(re.search('(load|depends[-_]).*intel/2018a', modtxt),
1795+
"load statement for intel/2018a found in module: %s" % modtxt)
17921796

17931797
os.remove(toy_core_mod)
17941798
os.remove(toy_mod)
@@ -1814,7 +1818,8 @@ def test_module_only(self):
18141818

18151819
# make sure load statements for dependencies are included
18161820
modtxt = read_file(toy_mod + '.lua')
1817-
self.assertTrue(re.search('load.*intel/2018a', modtxt), "load statement for intel/2018a found in module")
1821+
self.assertTrue(re.search('(load|depends[-_]).*intel/2018a', modtxt),
1822+
"load statement for intel/2018a found in module: %s" % modtxt)
18181823

18191824
def test_module_only_extensions(self):
18201825
"""
@@ -2350,7 +2355,8 @@ def test_toy_toy(self):
23502355

23512356
mod2_txt = read_file(mod2)
23522357

2353-
load1_regex = re.compile('load.*toy/0.0-one', re.M)
2358+
# load statement is (by default) either depends_on (Lua) or depends-on (Tcl)
2359+
load1_regex = re.compile('(load|depends[-_]on).*toy/0.0-one', re.M)
23542360
self.assertTrue(load1_regex.search(mod2_txt), "Pattern '%s' found in: %s" % (load1_regex.pattern, mod2_txt))
23552361

23562362
# Check the contents of the dumped env in the reprod dir to ensure it contains the dependency load
@@ -3183,14 +3189,18 @@ def test_toy_multi_deps(self):
31833189
# check whether (guarded) load statement for first version listed in multi_deps is there
31843190
if get_module_syntax() == 'Lua':
31853191
expected = '\n'.join([
3186-
'if not ( isloaded("GCC/4.6.3") ) and not ( isloaded("GCC/7.3.0-2.30") ) then',
3187-
' load("GCC/4.6.3")',
3192+
'if mode() == "unload" or isloaded("GCC/7.3.0-2.30") then',
3193+
' depends_on("GCC")',
3194+
'else',
3195+
' depends_on("GCC/4.6.3")',
31883196
'end',
31893197
])
31903198
else:
31913199
expected = '\n'.join([
3192-
'if { ![ is-loaded GCC/4.6.3 ] && ![ is-loaded GCC/7.3.0-2.30 ] } {',
3193-
' module load GCC/4.6.3',
3200+
'if { [ module-info mode remove ] || [ is-loaded GCC/7.3.0-2.30 ] } {',
3201+
' depends-on GCC',
3202+
'} else {',
3203+
' depends-on GCC/4.6.3',
31943204
'}',
31953205
])
31963206

0 commit comments

Comments
 (0)