@@ -57,6 +57,9 @@ def setUp(self):
5757 'def pre_build_and_install_loop_hook(ecs):' ,
5858 ' print("About to start looping for %d easyconfigs!" % len(ecs))' ,
5959 '' ,
60+ 'def pre_easyblock_hook(self):' ,
61+ ' print(f"Starting installation of {self.name} {self.version}")' ,
62+ '' ,
6063 'def foo():' ,
6164 ' print("running foo helper method")' ,
6265 '' ,
@@ -78,6 +81,9 @@ def setUp(self):
7881 ' if cmd == "make install":' ,
7982 ' return "sudo " + cmd' ,
8083 '' ,
84+ 'def post_easyblock_hook(self):' ,
85+ ' print(f"Done with installation of {self.name} {self.version}")' ,
86+ '' ,
8187 'def fail_hook(err):' ,
8288 ' print("EasyBuild FAIL: %s" % err)' ,
8389 '' ,
@@ -101,13 +107,15 @@ def test_load_hooks(self):
101107
102108 hooks = load_hooks (self .test_hooks_pymod )
103109
104- self .assertEqual (len (hooks ), 9 )
110+ self .assertEqual (len (hooks ), 11 )
105111 expected = [
106112 'crash_hook' ,
107113 'fail_hook' ,
108114 'parse_hook' ,
109115 'post_configure_hook' ,
116+ 'post_easyblock_hook' ,
110117 'pre_build_and_install_loop_hook' ,
118+ 'pre_easyblock_hook' ,
111119 'pre_install_hook' ,
112120 'pre_run_shell_cmd_hook' ,
113121 'pre_single_extension_hook' ,
@@ -197,12 +205,18 @@ def test_run_hook(self):
197205
198206 init_config (build_options = {'debug' : True })
199207
208+ class FakeEasyBlock ():
209+ def __init__ (self , * args , ** kwargs ):
210+ self .name = 'fake'
211+ self .version = '1.2.3'
212+
200213 def run_hooks ():
201214 self .mock_stdout (True )
202215 self .mock_stderr (True )
203216 run_hook ('start' , hooks )
204217 run_hook ('parse' , hooks , args = ['<EasyConfig instance>' ], msg = "Running parse hook for example.eb..." )
205218 run_hook ('build_and_install_loop' , hooks , args = [['ec1' , 'ec2' ]], pre_step_hook = True )
219+ run_hook ('easyblock' , hooks , args = [FakeEasyBlock ()], pre_step_hook = True )
206220 run_hook ('configure' , hooks , pre_step_hook = True , args = [None ])
207221 run_hook ('run_shell_cmd' , hooks , pre_step_hook = True , args = ["configure.sh" ], kwargs = {'interactive' : True })
208222 run_hook ('configure' , hooks , post_step_hook = True , args = [None ])
@@ -220,6 +234,7 @@ def run_hooks():
220234 run_hook ('extensions' , hooks , post_step_hook = True , args = [None ])
221235 run_hook ('fail' , hooks , args = [EasyBuildError ('oops' )])
222236 run_hook ('crash' , hooks , args = [RuntimeError ('boom!' )])
237+ run_hook ('easyblock' , hooks , args = [FakeEasyBlock ()], post_step_hook = True )
223238 stdout = self .get_stdout ()
224239 stderr = self .get_stderr ()
225240 self .mock_stdout (False )
@@ -236,6 +251,8 @@ def run_hooks():
236251 "Parse hook with argument <EasyConfig instance>" ,
237252 "== Running pre-build_and_install_loop hook..." ,
238253 "About to start looping for 2 easyconfigs!" ,
254+ "== Running pre-easyblock hook..." ,
255+ "Starting installation of fake 1.2.3" ,
239256 "== Running pre-run_shell_cmd hook..." ,
240257 "this is run before running interactive command 'configure.sh'" ,
241258 "== Running post-configure hook..." ,
@@ -257,6 +274,8 @@ def run_hooks():
257274 "EasyBuild FAIL: 'oops'" ,
258275 "== Running crash hook..." ,
259276 "EasyBuild CRASHED, oh no! => boom!" ,
277+ "== Running post-easyblock hook..." ,
278+ "Done with installation of fake 1.2.3" ,
260279 ]
261280 expected_stdout = '\n ' .join (expected_stdout_lines )
262281
0 commit comments