Skip to content

Commit 9fd885c

Browse files
committed
add test for defining %(cudaver)s template via toolchain
1 parent d7a2e6f commit 9fd885c

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

test/framework/easyconfig.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,6 +1050,51 @@ def test_templating(self):
10501050
ec = EasyConfig(test_ec)
10511051
self.assertEqual(ec['sanity_check_commands'], ['mpiexec -np 1 -- toy'])
10521052

1053+
def test_templating_cuda_toolchain(self):
1054+
"""Test templates via toolchain component, like setting %(cudaver)s with fosscuda toolchain."""
1055+
1056+
build_options = {'robot_path': [self.test_prefix]}
1057+
init_config(build_options=build_options)
1058+
1059+
# create fake easyconfig files, good enough to test with
1060+
cuda_ec = os.path.join(self.test_prefix, 'CUDA-10.1.243')
1061+
cuda_ec_txt = '\n'.join([
1062+
"easyblock = 'Toolchain'",
1063+
"name = 'CUDA'",
1064+
"version = '10.1.243'",
1065+
"homepage = 'https://example.com'",
1066+
"description = 'CUDA'",
1067+
"toolchain = SYSTEM",
1068+
])
1069+
write_file(cuda_ec, cuda_ec_txt)
1070+
1071+
fosscuda_ec = os.path.join(self.test_prefix, 'fosscuda-2021.02.eb')
1072+
fosscuda_ec_txt = '\n'.join([
1073+
"easyblock = 'Toolchain'",
1074+
"name = 'fosscuda'",
1075+
"version = '2021.02'",
1076+
"homepage = 'https://example.com'",
1077+
"description = 'fosscuda toolchain'",
1078+
"toolchain = SYSTEM",
1079+
"dependencies = [('CUDA', '10.1.243')]",
1080+
])
1081+
write_file(fosscuda_ec, fosscuda_ec_txt)
1082+
1083+
test_ec = os.path.join(self.test_prefix, 'test.eb')
1084+
test_ec_txt = '\n'.join([
1085+
"easyblock = 'Toolchain'",
1086+
"name = 'test'",
1087+
"version = '1.0'",
1088+
"homepage = 'https://example.com'",
1089+
"description = 'just a test'",
1090+
"toolchain = {'name': 'fosscuda', 'version': '2021.02'}",
1091+
])
1092+
write_file(test_ec, test_ec_txt)
1093+
ec = EasyConfig(test_ec)
1094+
self.assertEqual(ec.template_values['cudaver'], '10.1.243')
1095+
self.assertEqual(ec.template_values['cudamajver'], '10')
1096+
self.assertEqual(ec.template_values['cudashortver'], '10.1')
1097+
10531098
def test_java_wrapper_templating(self):
10541099
"""test templating when the Java wrapper is a dep"""
10551100
self.contents = '\n'.join([

0 commit comments

Comments
 (0)