@@ -2593,6 +2593,99 @@ def test_toy_build_enhanced_sanity_check(self):
2593
2593
2594
2594
del sys .modules ['easybuild.easyblocks.toy' ]
2595
2595
2596
+ def test_toy_build_enhanced_sanity_check_templated_multi_dep (self ):
2597
+ """Test enhancing of sanity check by easyblocks with templates and in the presence of multi_deps."""
2598
+
2599
+ # if toy easyblock was imported, get rid of corresponding entry in sys.modules,
2600
+ # to avoid that it messes up the use of --include-easyblocks=toy.py below...
2601
+ if 'easybuild.easyblocks.toy' in sys .modules :
2602
+ del sys .modules ['easybuild.easyblocks.toy' ]
2603
+
2604
+ test_dir = os .path .join (os .path .abspath (os .path .dirname (__file__ )))
2605
+ toy_ec = os .path .join (test_dir , 'easyconfigs' , 'test_ecs' , 't' , 'toy' , 'toy-0.0.eb' )
2606
+ toy_ec_txt = read_file (toy_ec )
2607
+
2608
+ test_ec = os .path .join (self .test_prefix , 'test.eb' )
2609
+
2610
+ # get rid of custom sanity check paths in test easyconfig
2611
+ regex = re .compile (r'^sanity_check_paths\s*=\s*{[^}]+}' , re .M )
2612
+ test_ec_txt = regex .sub ('' , toy_ec_txt )
2613
+ self .assertNotIn ('sanity_check_' , test_ec_txt )
2614
+
2615
+ test_ec_txt += "\n multi_deps = {'Python': ['3.7.2', '2.7.15']}"
2616
+ write_file (test_ec , test_ec_txt )
2617
+
2618
+ # create custom easyblock for toy that has a custom sanity_check_step
2619
+ toy_easyblock = os .path .join (test_dir , 'sandbox' , 'easybuild' , 'easyblocks' , 't' , 'toy.py' )
2620
+
2621
+ toy_easyblock_txt = read_file (toy_easyblock )
2622
+
2623
+ toy_custom_sanity_check_step = textwrap .dedent ("""
2624
+ # Add to class to indent
2625
+ def sanity_check_step(self):
2626
+ paths = {
2627
+ 'files': ['bin/python%(pyshortver)s'],
2628
+ 'dirs': ['lib/py-%(pyshortver)s'],
2629
+ }
2630
+ cmds = ['python%(pyshortver)s']
2631
+ return super(EB_toy, self).sanity_check_step(custom_paths=paths, custom_commands=cmds)
2632
+ """ )
2633
+ test_toy_easyblock = os .path .join (self .test_prefix , 'toy.py' )
2634
+ write_file (test_toy_easyblock , toy_easyblock_txt + toy_custom_sanity_check_step )
2635
+
2636
+ eb_args = [
2637
+ '--extended-dry-run' ,
2638
+ '--include-easyblocks=%s' % test_toy_easyblock ,
2639
+ ]
2640
+
2641
+ # by default, sanity check commands & paths specified by easyblock are used
2642
+ with self .mocked_stdout_stderr ():
2643
+ self .test_toy_build (ec_file = test_ec , extra_args = eb_args , verify = False , testing = False , raise_error = True )
2644
+ stdout = self .get_stdout ()
2645
+ # Cut output to start of the toy-ec, after the Python installations
2646
+ stdout = stdout [stdout .index (test_ec ):]
2647
+
2648
+ pattern_template = textwrap .dedent (r"""
2649
+ Sanity check paths - file.*
2650
+ \s*\* bin/python{pyshortver}
2651
+ Sanity check paths - \(non-empty\) directory.*
2652
+ \s*\* lib/py-{pyshortver}
2653
+ Sanity check commands
2654
+ \s*\* python{pyshortver}
2655
+ """ )
2656
+ for pyshortver in ('2.7' , '3.7' ):
2657
+ regex = re .compile (pattern_template .format (pyshortver = pyshortver ), re .M )
2658
+ self .assertTrue (regex .search (stdout ), "Pattern '%s' should be found in: %s" % (regex .pattern , stdout ))
2659
+
2660
+ # Enhance sanity check by extra paths to check for, the ones from the easyblock should be kept
2661
+ test_ec_txt += textwrap .dedent ("""
2662
+ enhance_sanity_check = True
2663
+ sanity_check_paths = {
2664
+ 'files': ['bin/pip%(pyshortver)s'],
2665
+ 'dirs': ['bin'],
2666
+ }
2667
+ """ )
2668
+ write_file (test_ec , test_ec_txt )
2669
+ with self .mocked_stdout_stderr ():
2670
+ self .test_toy_build (ec_file = test_ec , extra_args = eb_args , verify = False , testing = False , raise_error = True )
2671
+ stdout = self .get_stdout ()
2672
+ # Cut output to start of the toy-ec, after the Python installations
2673
+ stdout = stdout [stdout .index (test_ec ):]
2674
+
2675
+ pattern_template = textwrap .dedent (r"""
2676
+ Sanity check paths - file.*
2677
+ \s*\* bin/pip{pyshortver}
2678
+ \s*\* bin/python{pyshortver}
2679
+ Sanity check paths - \(non-empty\) directory.*
2680
+ \s*\* bin
2681
+ \s*\* lib/py-{pyshortver}
2682
+ Sanity check commands
2683
+ \s*\* python{pyshortver}
2684
+ """ )
2685
+ for pyshortver in ('2.7' , '3.7' ):
2686
+ regex = re .compile (pattern_template .format (pyshortver = pyshortver ), re .M )
2687
+ self .assertTrue (regex .search (stdout ), "Pattern '%s' should be found in: %s" % (regex .pattern , stdout ))
2688
+
2596
2689
def test_toy_dumped_easyconfig (self ):
2597
2690
""" Test dumping of file in eb_filerepo in both .eb and .yeb format """
2598
2691
filename = 'toy-0.0'
0 commit comments