@@ -566,15 +566,16 @@ def test_extensions_templates(self):
566566 # bogus, but useful to check whether this get resolved
567567 'exts_default_options = {"source_urls": [PYPI_SOURCE]}' ,
568568 'exts_list = [' ,
569- ' ("toy", "0.0", {' ,
569+ ' ("toy", "0.0.1 ", {' ,
570570 # %(name)s and %(version_major_minor)s should be resolved using name/version of extension (not parent)
571571 # %(pymajver)s should get resolved because Python is listed as a (runtime) dep
572572 # %(versionsuffix)s should get resolved with value of parent
573573 ' "source_tmpl": "%(name)s-%(version_major_minor)s-py%(pymajver)s%(versionsuffix)s.tar.gz",' ,
574- ' "patches": ["%(name)s-%(version )s_fix-silly-typo-in-printf-statement.patch"],' ,
574+ ' "patches": ["%(name)s-%(version_major_minor )s_fix-silly-typo-in-printf-statement.patch"],' ,
575575 # use hacky prebuildopts that is picked up by 'EB_Toy' easyblock, to check whether templates are resolved
576- ' "prebuildopts": "gcc -O2 %(name)s.c -o toy-%(version)s &&' +
577- ' mv toy-%(version)s toy # echo installdir is %(installdir)s #",' ,
576+ ' "prebuildopts": "gcc -O2 %(name)s.c -o toy-%(version_minor_patch)s &&' +
577+ ' mv toy-%(version_minor_patch)s toy # echo installdir is %(installdir)s #",' ,
578+ ' "postbuildopts": "echo postbuild step for %(name)s-%(version)s",' ,
578579 ' }),' ,
579580 ']' ,
580581 ])
@@ -597,16 +598,15 @@ def test_extensions_templates(self):
597598 # check whether template values were resolved correctly in Extension instances that were created/used
598599 toy_ext = eb .ext_instances [0 ]
599600 self .assertEqual (os .path .basename (toy_ext .src ), 'toy-0.0-py3-test.tar.gz' )
600- patches = []
601- for patch in toy_ext .patches :
602- patches .append (patch ['path' ])
601+ patches = [patch ['path' ] for patch in toy_ext .patches ]
603602 self .assertEqual (patches , [os .path .join (self .test_prefix , toy_patch_fn )])
604603 # define actual installation dir
605604 pi_installdir = os .path .join (self .test_installpath , 'software' , 'pi' , '3.14-test' )
606- expected_prebuildopts = 'gcc -O2 toy.c -o toy-0.0 && mv toy-0.0 toy # echo installdir is %s #' % pi_installdir
605+ expected_prebuildopts = 'gcc -O2 toy.c -o toy-0.1 && mv toy-0.1 toy # echo installdir is %s #' % pi_installdir
607606 expected = {
608607 'patches' : ['toy-0.0_fix-silly-typo-in-printf-statement.patch' ],
609608 'prebuildopts' : expected_prebuildopts ,
609+ 'postbuildopts' : "echo postbuild step for toy-0.0.1" ,
610610 'source_tmpl' : 'toy-0.0-py3-test.tar.gz' ,
611611 'source_urls' : ['https://pypi.python.org/packages/source/t/toy' ],
612612 }
@@ -3723,7 +3723,7 @@ def test_template_constant_dict(self):
37233723 # also check result of template_constant_dict when dict representing extension is passed
37243724 ext_dict = {
37253725 'name' : 'foo' ,
3726- 'version' : '1.2.3' ,
3726+ 'version' : '1.2.3.42 ' ,
37273727 'options' : {
37283728 'source_urls' : ['https://example.com' ],
37293729 'source_tmpl' : '%(name)s-%(version)s.tar.gz' ,
@@ -3744,13 +3744,27 @@ def test_template_constant_dict(self):
37443744 'rpath_enabled' : rpath ,
37453745 'software_commit' : '' ,
37463746 'sysroot' : '' ,
3747- 'version' : '1.2.3' ,
3747+ 'version' : '1.2.3.42 ' ,
37483748 'version_major' : '1' ,
37493749 'version_major_minor' : '1.2' ,
3750- 'version_minor' : '2'
3750+ 'version_major_minor_patch' : '1.2.3' ,
3751+ 'version_minor' : '2' ,
3752+ 'version_minor_patch' : '2.3' ,
3753+ 'version_patch' : '3' ,
37513754 }
37523755 self .assertEqual (res , expected )
37533756
3757+ # No patch version makes the templates undefined
3758+ ext_dict ['version' ] = '1.2'
3759+ res = template_constant_dict (ext_dict )
3760+ res .pop ('arch' )
3761+
3762+ del expected ['version_major_minor_patch' ]
3763+ del expected ['version_minor_patch' ]
3764+ del expected ['version_patch' ]
3765+ expected ['version' ] = '1.2'
3766+ self .assertEqual (res , expected )
3767+
37543768 def test_parse_deps_templates (self ):
37553769 """Test whether handling of templates defined by dependencies is done correctly."""
37563770 test_ecs = os .path .join (os .path .dirname (os .path .abspath (__file__ )), 'easyconfigs' , 'test_ecs' )
0 commit comments