|
51 | 51 | from easybuild.tools.build_log import EasyBuildError |
52 | 52 | from easybuild.tools.config import get_module_syntax, get_repositorypath |
53 | 53 | from easybuild.tools.environment import modify_env |
54 | | -from easybuild.tools.filetools import adjust_permissions, change_dir, copy_file, mkdir |
| 54 | +from easybuild.tools.filetools import adjust_permissions, change_dir, copy_file, mkdir, move_file |
55 | 55 | from easybuild.tools.filetools import read_file, remove_dir, remove_file, which, write_file |
56 | 56 | from easybuild.tools.module_generator import ModuleGeneratorTcl |
57 | 57 | from easybuild.tools.modules import Lmod |
@@ -1682,6 +1682,58 @@ def test_module_only(self): |
1682 | 1682 | modtxt = read_file(toy_mod + '.lua') |
1683 | 1683 | self.assertTrue(re.search('load.*intel/2018a', modtxt), "load statement for intel/2018a found in module") |
1684 | 1684 |
|
| 1685 | + def test_module_only_extensions(self): |
| 1686 | + """ |
| 1687 | + Test use of --module-only with extensions involved. |
| 1688 | + Sanity check should catch problems with extensions, |
| 1689 | + extensions can be skipped using --skip-exts. |
| 1690 | + """ |
| 1691 | + topdir = os.path.abspath(os.path.dirname(__file__)) |
| 1692 | + toy_ec = os.path.join(topdir, 'easyconfigs', 'test_ecs', 't', 'toy', 'toy-0.0.eb') |
| 1693 | + |
| 1694 | + toy_mod = os.path.join(self.test_installpath, 'modules', 'all', 'toy', '0.0') |
| 1695 | + if get_module_syntax() == 'Lua': |
| 1696 | + toy_mod += '.lua' |
| 1697 | + |
| 1698 | + test_ec = os.path.join(self.test_prefix, 'test.ec') |
| 1699 | + test_ec_txt = read_file(toy_ec) |
| 1700 | + test_ec_txt += '\n' + '\n'.join([ |
| 1701 | + "sanity_check_commands = ['barbar', 'toy']", |
| 1702 | + "sanity_check_paths = {'files': ['bin/barbar', 'bin/toy'], 'dirs': ['bin']}", |
| 1703 | + "exts_list = [", |
| 1704 | + " ('barbar', '0.0', {", |
| 1705 | + " 'start_dir': 'src',", |
| 1706 | + " 'exts_filter': ('ls -l lib/lib%(ext_name)s.a', ''),", |
| 1707 | + " })", |
| 1708 | + "]", |
| 1709 | + ]) |
| 1710 | + write_file(test_ec, test_ec_txt) |
| 1711 | + |
| 1712 | + # clean up $MODULEPATH to only modules in test prefix dir are found |
| 1713 | + self.reset_modulepath([os.path.join(self.test_installpath, 'modules', 'all')]) |
| 1714 | + self.assertEqual(self.modtool.available('toy'), []) |
| 1715 | + |
| 1716 | + # install toy/0.0 |
| 1717 | + self.eb_main([test_ec], do_build=True, raise_error=True) |
| 1718 | + |
| 1719 | + # remove module file so we can try --module-only |
| 1720 | + remove_file(toy_mod) |
| 1721 | + |
| 1722 | + # rename file required for barbar extension, so we can check whether sanity check catches it |
| 1723 | + libbarbar = os.path.join(self.test_installpath, 'software', 'toy', '0.0', 'lib', 'libbarbar.a') |
| 1724 | + move_file(libbarbar, libbarbar + '.foobar') |
| 1725 | + |
| 1726 | + # check whether sanity check fails now when using --module-only |
| 1727 | + error_pattern = 'Sanity check failed: command "ls -l lib/libbarbar.a" failed' |
| 1728 | + for extra_args in (['--module-only'], ['--module-only', '--rebuild']): |
| 1729 | + self.assertErrorRegex(EasyBuildError, error_pattern, self.eb_main, [test_ec] + extra_args, |
| 1730 | + do_build=True, raise_error=True) |
| 1731 | + self.assertFalse(os.path.exists(toy_mod)) |
| 1732 | + |
| 1733 | + # we can force module generation via --force (which skips sanity check entirely) |
| 1734 | + self.eb_main([test_ec, '--module-only', '--force'], do_build=True, raise_error=True) |
| 1735 | + self.assertTrue(os.path.exists(toy_mod)) |
| 1736 | + |
1685 | 1737 | def test_backup_modules(self): |
1686 | 1738 | """Test use of backing up of modules with --module-only.""" |
1687 | 1739 |
|
|
0 commit comments