@@ -609,6 +609,100 @@ def test_make_module_req(self):
609
609
eb .close_log ()
610
610
os .remove (eb .logfile )
611
611
612
+ def test_module_search_path_headers (self ):
613
+ """Test functionality of module-search-path-headers option"""
614
+ sp_headers_mode = {
615
+ "none" : [],
616
+ "cpath" : ["CPATH" ],
617
+ "include_paths" : ["C_INCLUDE_PATH" , "CPLUS_INCLUDE_PATH" , "OBJC_INCLUDE_PATH" ],
618
+ }
619
+
620
+ self .contents = '\n ' .join ([
621
+ 'easyblock = "ConfigureMake"' ,
622
+ 'name = "pi"' ,
623
+ 'version = "3.14"' ,
624
+ 'homepage = "http://example.com"' ,
625
+ 'description = "test easyconfig"' ,
626
+ 'toolchain = SYSTEM' ,
627
+ ])
628
+ self .writeEC ()
629
+
630
+ for build_opt , sp_headers in sp_headers_mode .items ():
631
+ init_config (build_options = {"module_search_path_headers" : build_opt , "silent" : True })
632
+ eb = EasyBlock (EasyConfig (self .eb_file ))
633
+ eb .installdir = config .install_path ()
634
+ try :
635
+ os .makedirs (os .path .join (eb .installdir , 'include' ))
636
+ write_file (os .path .join (eb .installdir , 'include' , 'header.h' ), 'dummy header file' )
637
+ except FileExistsError :
638
+ pass
639
+
640
+ with eb .module_generator .start_module_creation ():
641
+ guess = eb .make_module_req ()
642
+
643
+ if not sp_headers :
644
+ # none option adds nothing to module file
645
+ if get_module_syntax () == 'Tcl' :
646
+ tcl_ref_pattern = r"^prepend-path\s+CPATH\s+\$root/include$"
647
+ self .assertFalse (re .search (tcl_ref_pattern , guess , re .M ))
648
+ elif get_module_syntax () == 'Lua' :
649
+ lua_ref_pattern = r'^prepend_path\("CPATH", pathJoin\(root, "include"\)\)$'
650
+ self .assertFalse (re .search (lua_ref_pattern , guess , re .M ))
651
+ else :
652
+ for env_var in sp_headers :
653
+ if get_module_syntax () == 'Tcl' :
654
+ tcl_ref_pattern = rf"^prepend-path\s+{ env_var } \s+\$root/include$"
655
+ self .assertTrue (re .search (tcl_ref_pattern , guess , re .M ))
656
+ elif get_module_syntax () == 'Lua' :
657
+ lua_ref_pattern = rf'^prepend_path\("{ env_var } ", pathJoin\(root, "include"\)\)$'
658
+ self .assertTrue (re .search (lua_ref_pattern , guess , re .M ))
659
+
660
+ # test with easyconfig parameter
661
+ for ec_param , sp_headers in sp_headers_mode .items ():
662
+ self .contents += f'\n module_search_path_headers = "{ ec_param } "'
663
+ self .writeEC ()
664
+ eb = EasyBlock (EasyConfig (self .eb_file ))
665
+ eb .installdir = config .install_path ()
666
+ try :
667
+ os .makedirs (os .path .join (eb .installdir , 'include' ))
668
+ write_file (os .path .join (eb .installdir , 'include' , 'header.h' ), 'dummy header file' )
669
+ except FileExistsError :
670
+ pass
671
+
672
+ for build_opt in sp_headers_mode :
673
+ init_config (build_options = {"module_search_path_headers" : build_opt , "silent" : True })
674
+ with eb .module_generator .start_module_creation ():
675
+ guess = eb .make_module_req ()
676
+ if not sp_headers :
677
+ # none option adds nothing to module file
678
+ if get_module_syntax () == 'Tcl' :
679
+ tcl_ref_pattern = r"^prepend-path\s+CPATH\s+\$root/include$"
680
+ self .assertFalse (re .search (tcl_ref_pattern , guess , re .M ))
681
+ elif get_module_syntax () == 'Lua' :
682
+ lua_ref_pattern = r'^prepend_path\("CPATH", pathJoin\(root, "include"\)\)$'
683
+ self .assertFalse (re .search (lua_ref_pattern , guess , re .M ))
684
+ else :
685
+ for env_var in sp_headers :
686
+ if get_module_syntax () == 'Tcl' :
687
+ tcl_ref_pattern = rf"^prepend-path\s+{ env_var } \s+\$root/include$"
688
+ self .assertTrue (re .search (tcl_ref_pattern , guess , re .M ))
689
+ elif get_module_syntax () == 'Lua' :
690
+ lua_ref_pattern = rf'^prepend_path\("{ env_var } ", pathJoin\(root, "include"\)\)$'
691
+ self .assertTrue (re .search (lua_ref_pattern , guess , re .M ))
692
+
693
+ # test wrong easyconfig parameter
694
+ self .contents += '\n module_search_path_headers = "WRONG_OPT"'
695
+ self .writeEC ()
696
+ ec = EasyConfig (self .eb_file )
697
+
698
+ error_pattern = "Unknown value selected for option module-search-path-headers"
699
+ with eb .module_generator .start_module_creation ():
700
+ self .assertErrorRegex (EasyBuildError , error_pattern , EasyBlock , ec )
701
+
702
+ # cleanup
703
+ eb .close_log ()
704
+ os .remove (eb .logfile )
705
+
612
706
def test_make_module_extra (self ):
613
707
"""Test for make_module_extra."""
614
708
init_config (build_options = {'silent' : True })
0 commit comments