@@ -5783,23 +5783,25 @@ def test_sanity_check_only(self):
57835783 "exts_list = [" ,
57845784 " ('barbar', '0.0', {" ,
57855785 " 'start_dir': 'src'," ,
5786+ " 'exts_filter': ('ls -l lib/lib%(ext_name)s.a', '')," ,
57865787 " })" ,
57875788 "]" ,
57885789 ])
57895790 write_file (test_ec , test_ec_txt )
57905791
57915792 # sanity check fails if software was not installed yet
57925793 outtxt , error_thrown = self .eb_main ([test_ec , '--sanity-check-only' ], do_build = True , return_error = True )
5793- self .assertTrue ("Sanity check failed: no file found at \\ 'bin/barbar\\ '" in str (error_thrown ))
5794- self .assertTrue ("no file found at \\ 'bin/toy\\ '" in str (error_thrown ))
5794+ self .assertTrue ("Sanity check failed" in str (error_thrown ))
57955795
57965796 # actually install, then try --sanity-check-only again;
57975797 # need to use --force to install toy because module already exists (but installation doesn't)
57985798 self .eb_main ([test_ec , '--force' ], do_build = True , raise_error = True )
57995799
5800+ args = [test_ec , '--sanity-check-only' ]
5801+
58005802 self .mock_stdout (True )
58015803 self .mock_stderr (True )
5802- self .eb_main ([ test_ec , '--sanity-check-only' , '--trace' ], do_build = True , raise_error = True , testing = False )
5804+ self .eb_main (args + [ '--trace' ], do_build = True , raise_error = True , testing = False )
58035805 stdout = self .get_stdout ().strip ()
58045806 stderr = self .get_stderr ().strip ()
58055807 self .mock_stdout (False )
@@ -5830,14 +5832,30 @@ def test_sanity_check_only(self):
58305832 self .assertTrue ("== sanity checking..." in stdout )
58315833 self .assertTrue ("COMPLETED: Installation ended successfully" in stdout )
58325834 msgs = [
5833- "file 'bin/barbar' found: OK" ,
5834- "file 'bin/toy' found: OK" ,
5835- "(non-empty) directory 'bin' found: OK" ,
5836- "loading modules: toy/0.0..." ,
5837- "result for command 'toy': OK" ,
5835+ " >> file 'bin/barbar' found: OK" ,
5836+ " >> file 'bin/toy' found: OK" ,
5837+ " >> (non-empty) directory 'bin' found: OK" ,
5838+ " >> loading modules: toy/0.0..." ,
5839+ " >> result for command 'toy': OK" ,
5840+ "ls -l lib/libbarbar.a" , # sanity check for extension barbar (via exts_filter)
58385841 ]
58395842 for msg in msgs :
5840- self .assertTrue (" >> %s" % msg in stdout , "' >> %s' found in: %s" % (msg , stdout ))
5843+ self .assertTrue (msg in stdout , "'%s' found in: %s" % (msg , stdout ))
5844+
5845+ # check if sanity check for extension fails if a file provided by that extension,
5846+ # which is checked by the sanity check for that extension, is removed
5847+ libbarbar = os .path .join (self .test_installpath , 'software' , 'toy' , '0.0' , 'lib' , 'libbarbar.a' )
5848+ remove_file (libbarbar )
5849+
5850+ outtxt , error_thrown = self .eb_main (args + ['--debug' ], do_build = True , return_error = True )
5851+ error_msg = str (error_thrown )
5852+ error_patterns = [
5853+ r"Sanity check failed" ,
5854+ r'command "ls -l lib/libbarbar\.a" failed' ,
5855+ ]
5856+ for error_pattern in error_patterns :
5857+ regex = re .compile (error_pattern )
5858+ self .assertTrue (regex .search (error_msg ), "Pattern '%s' should be found in: %s" % (regex .pattern , error_msg ))
58415859
58425860 def test_fake_vsc_include (self ):
58435861 """Test whether fake 'vsc' namespace is triggered for modules included via --include-*."""
0 commit comments