diff --git a/easybuild/framework/easyconfig/constants.py b/easybuild/framework/easyconfig/constants.py index f684985b21..24141c393b 100644 --- a/easybuild/framework/easyconfig/constants.py +++ b/easybuild/framework/easyconfig/constants.py @@ -82,3 +82,7 @@ def _get_arch_constant(): 'OS_PKG_PAM_DEV': (('pam-devel', 'libpam0g-dev'), "OS packages providing Pluggable Authentication Module (PAM) developement support"), } + +# Add EasyConfig constants to export list +globals().update({name: value for name, (value, _) in EASYCONFIG_CONSTANTS.items()}) +__all__ = ['EXTERNAL_MODULE_MARKER', 'EASYCONFIG_CONSTANTS'] + list(EASYCONFIG_CONSTANTS.keys()) diff --git a/test/framework/easyconfig.py b/test/framework/easyconfig.py index a747db80aa..2e94263cd8 100644 --- a/test/framework/easyconfig.py +++ b/test/framework/easyconfig.py @@ -74,7 +74,8 @@ from easybuild.tools.py2vs3 import OrderedDict, reload from easybuild.tools.robot import resolve_dependencies from easybuild.tools.systemtools import AARCH64, KNOWN_ARCH_CONSTANTS, POWER, X86_64 -from easybuild.tools.systemtools import get_cpu_architecture, get_shared_lib_ext +from easybuild.tools.systemtools import get_cpu_architecture, get_shared_lib_ext, get_os_name, get_os_version + from easybuild.tools.toolchain.utilities import search_toolchain from easybuild.tools.utilities import quote_str, quote_py_str from test.framework.utilities import find_full_path @@ -1278,6 +1279,20 @@ def test_constant_doc(self): ] self.assertEqual(len(doc.split('\n')), sum([len(temps)] + [len(x) for x in temps])) + def test_constant_import(self): + """Test importing EC constants works""" + from easybuild.framework.easyconfig.constants import SYSTEM, OS_NAME, OS_VERSION + self.assertEqual(SYSTEM, {'name': 'system', 'version': 'system'}) + self.assertEqual(OS_NAME, get_os_name()) + self.assertEqual(OS_VERSION, get_os_version()) + + def test_constant_import_values(self): + """Test that importing an EC constant works as-if using EASYCONFIG_CONSTANTS""" + constants = __import__('easybuild.framework.easyconfig.constants', fromlist=[None]) + for name, (value, _doc) in easyconfig.constants.EASYCONFIG_CONSTANTS.items(): + self.assertTrue(hasattr(constants, name), 'Missing ' + name) + self.assertEqual(getattr(constants, name), value) + def test_build_options(self): """Test configure/build/install options, both strings and lists.""" orig_contents = '\n'.join([