@@ -2027,19 +2027,35 @@ def makedirs_in_test(*paths):
20272027
20282028 def test_find_eb_script (self ):
20292029 """Test find_eb_script function."""
2030+
2031+ # make sure $EB_SCRIPT_PATH is not set already (used as fallback mechanism in find_eb_script)
2032+ if 'EB_SCRIPT_PATH' in os .environ :
2033+ del os .environ ['EB_SCRIPT_PATH' ]
2034+
20302035 self .assertTrue (os .path .exists (ft .find_eb_script ('rpath_args.py' )))
20312036 self .assertTrue (os .path .exists (ft .find_eb_script ('rpath_wrapper_template.sh.in' )))
20322037 self .assertErrorRegex (EasyBuildError , "Script 'no_such_script' not found" , ft .find_eb_script , 'no_such_script' )
20332038
20342039 # put test script in place relative to location of 'eb'
2035- ft .write_file (os .path .join (self .test_prefix , 'bin' , 'eb' ), '#!/bin/bash\n echo "fake eb"' )
2036- ft .adjust_permissions (os .path .join (self .test_prefix , 'bin' , 'eb' ), stat .S_IXUSR )
2037- os .environ ['PATH' ] = '%s:%s' % (os .path .join (self .test_prefix , 'bin' ), os .getenv ('PATH' , '' ))
2040+ fake_eb = os .path .join (self .test_prefix , 'bin' , 'eb' )
2041+ ft .write_file (fake_eb , '#!/bin/bash\n echo "fake eb"' )
2042+ ft .adjust_permissions (fake_eb , stat .S_IXUSR )
2043+ os .environ ['PATH' ] = '%s:%s' % (os .path .dirname (fake_eb ), os .getenv ('PATH' , '' ))
20382044
2039- justatest = os .path .join (self .test_prefix , 'easybuild' , 'scripts' , 'justatest .sh' )
2045+ justatest = os .path .join (self .test_prefix , 'easybuild' , 'scripts' , 'thisisjustatestscript .sh' )
20402046 ft .write_file (justatest , '#!/bin/bash' )
20412047
2042- self .assertTrue (os .path .samefile (ft .find_eb_script ('justatest.sh' ), justatest ))
2048+ self .assertTrue (os .path .samefile (ft .find_eb_script ('thisisjustatestscript.sh' ), justatest ))
2049+
2050+ # $EB_SCRIPT_PATH can also be used (overrules 'eb' found via $PATH)
2051+ ft .remove_file (fake_eb )
2052+ os .environ ['EB_SCRIPT_PATH' ] = os .path .join (self .test_prefix , 'easybuild' , 'scripts' )
2053+ self .assertTrue (os .path .samefile (ft .find_eb_script ('thisisjustatestscript.sh' ), justatest ))
2054+
2055+ # if script can't be found via either $EB_SCRIPT_PATH or location of 'eb', we get a clean error
2056+ del os .environ ['EB_SCRIPT_PATH' ]
2057+ error_pattern = "Script 'thisisjustatestscript.sh' not found at expected location"
2058+ self .assertErrorRegex (EasyBuildError , error_pattern , ft .find_eb_script , 'thisisjustatestscript.sh' )
20432059
20442060 def test_move_file (self ):
20452061 """Test move_file function"""
0 commit comments