Skip to content

Commit 30763d4

Browse files
committed
add test for avail_easyconfig_constants function
1 parent ab4c334 commit 30763d4

File tree

1 file changed

+45
-2
lines changed

1 file changed

+45
-2
lines changed

test/framework/docs.py

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
from unittest import TextTestRunner
3333

3434
from easybuild.tools.config import module_classes
35-
from easybuild.tools.docs import avail_cfgfile_constants, avail_easyconfig_licenses, gen_easyblocks_overview_rst
36-
from easybuild.tools.docs import list_easyblocks, list_software, list_toolchains
35+
from easybuild.tools.docs import avail_cfgfile_constants, avail_easyconfig_constants, avail_easyconfig_licenses
36+
from easybuild.tools.docs import gen_easyblocks_overview_rst, list_easyblocks, list_software, list_toolchains
3737
from easybuild.tools.docs import md_title_and_table, rst_title_and_table
3838
from easybuild.tools.options import EasyBuildOptions
3939
from easybuild.tools.utilities import import_available_modules, mk_md_table, mk_rst_table
@@ -636,6 +636,49 @@ def test_avail_cfgfile_constants(self):
636636
regex = re.compile(pattern, re.M)
637637
self.assertTrue(regex.search(txt_rst), "Pattern '%s' should be found in: %s" % (regex.pattern, txt_rst))
638638

639+
def test_avail_easyconfig_constants(self):
640+
"""
641+
Test avail_easyconfig_constants to generate overview of constants that can be used in easyconfig files.
642+
"""
643+
txt_patterns = [
644+
r"^Constants that can be used in easyconfigs",
645+
r"^\s*ARCH: .* \(CPU architecture of current system \(aarch64, x86_64, ppc64le, ...\)\)",
646+
r"^\s*OS_PKG_OPENSSL_DEV: \('openssl-devel', 'libssl-dev', 'libopenssl-devel'\) "
647+
r"\(OS packages providing openSSL developement support\)",
648+
]
649+
650+
txt = avail_easyconfig_constants()
651+
for pattern in txt_patterns:
652+
regex = re.compile(pattern, re.M)
653+
self.assertTrue(regex.search(txt), "Pattern '%s' should be found in: %s" % (regex.pattern, txt))
654+
655+
txt = avail_easyconfig_constants(output_format='txt')
656+
for pattern in txt_patterns:
657+
regex = re.compile(pattern, re.M)
658+
self.assertTrue(regex.search(txt), "Pattern '%s' should be found in: %s" % (regex.pattern, txt))
659+
660+
md_patterns = [
661+
r"^## Constants that can be used in easyconfigs",
662+
r"^``ARCH``\s*\|``.*``\s*\|CPU architecture of current system \(aarch64, x86_64, ppc64le, ...\)$",
663+
r"^``OS_PKG_OPENSSL_DEV``\s*\|``\('openssl-devel', 'libssl-dev', 'libopenssl-devel'\)``\s*\|"
664+
r"OS packages providing openSSL developement support$",
665+
]
666+
txt_md = avail_easyconfig_constants(output_format='md')
667+
for pattern in md_patterns:
668+
regex = re.compile(pattern, re.M)
669+
self.assertTrue(regex.search(txt_md), "Pattern '%s' should be found in: %s" % (regex.pattern, txt_md))
670+
671+
rst_patterns = [
672+
r"^Constants that can be used in easyconfigs\n-{41}",
673+
r"^``ARCH``\s*``.*``\s*CPU architecture of current system \(aarch64, x86_64, ppc64le, ...\)$",
674+
r"^``OS_PKG_OPENSSL_DEV``\s*``\('openssl-devel', 'libssl-dev', 'libopenssl-devel'\)``\s*"
675+
r"OS packages providing openSSL developement support$",
676+
]
677+
txt_rst = avail_easyconfig_constants(output_format='rst')
678+
for pattern in rst_patterns:
679+
regex = re.compile(pattern, re.M)
680+
self.assertTrue(regex.search(txt_rst), "Pattern '%s' should be found in: %s" % (regex.pattern, txt_rst))
681+
639682
def test_mk_table(self):
640683
"""
641684
Tests for mk_*_table functions.

0 commit comments

Comments
 (0)