@@ -100,7 +100,7 @@ def check_reference_file(common_funcs, test_webpage, test_variables, debug):
100
100
common_funcs .add_entry (test_webpage , "#FF00FF" , "" , "Reference file does not exist" )
101
101
ret = 1
102
102
if debug :
103
- print (f"Return value after check_reference_file: { ret } " )
103
+ common_funcs . logger . info (f"Return value after check_reference_file: { ret } " )
104
104
return ret
105
105
106
106
def run_wcsim (variables , common_funcs , test_webpage , debug ):
@@ -121,13 +121,13 @@ def run_wcsim(variables, common_funcs, test_webpage, debug):
121
121
subprocess.CalledProcessError: If the subprocess call to run WCSim fails.
122
122
'''
123
123
try :
124
- wcsim_exit = subprocess . run (["/usr/bin/time" , "-p" , "--output=timetest" , f"{ common_funcs .ValidationPath } /{ variables ['ScriptName' ]} " , f"{ common_funcs .ValidationPath } /Generate/macReference/{ variables ['WCSimMacName' ]} " , f"{ variables ['FileTag' ]} .root" ], stdout = subprocess . PIPE , stderr = subprocess . STDOUT , check = True )
124
+ wcsim_exit = common_funcs . run_command (["/usr/bin/time" , "-p" , "--output=timetest" , f"{ common_funcs .ValidationPath } /{ variables ['ScriptName' ]} " , f"{ common_funcs .ValidationPath } /Generate/macReference/{ variables ['WCSimMacName' ]} " , f"{ variables ['FileTag' ]} .root" ])
125
125
126
126
# Write the command and its output to a log file
127
127
with open ('wcsim_run.out' , 'w' ) as logfile :
128
128
logfile .write (wcsim_exit .stdout .decode ())
129
129
130
- print (wcsim_exit .stdout .decode ())
130
+ common_funcs . logger . info (wcsim_exit .stdout .decode ())
131
131
132
132
# Parse the timing information
133
133
with open ("timetest" , "r" ) as timetest_file :
@@ -138,7 +138,7 @@ def run_wcsim(variables, common_funcs, test_webpage, debug):
138
138
139
139
common_funcs .add_entry (test_webpage , "#00FF00" , "" , time )
140
140
if debug :
141
- print (f"Return value after wcsim_exit: 0" )
141
+ common_funcs . logger . info (f"Return value after wcsim_exit: 0" )
142
142
return 0
143
143
144
144
except subprocess .CalledProcessError as e :
@@ -181,7 +181,7 @@ def compare_root_files(common_funcs, test_webpage, test_dir, variables, test_num
181
181
if not os .path .isdir (f"{ test_dir } /{ isubjob } " ):
182
182
os .mkdir (f"{ test_dir } /{ isubjob } " )
183
183
compare_exit_status = os .system (f"{ common_funcs .ValidationPath } /Compare/compareroot { common_funcs .ValidationPath } /Webpage/{ common_funcs .GIT_COMMIT } /{ test_num } /{ isubjob } { root_filename } { common_funcs .ValidationPath } /Compare/Reference/{ root_filename } " )
184
- print ('compare_exit_status' , compare_exit_status , type (compare_exit_status ))
184
+ common_funcs . logger . info ('compare_exit_status' , compare_exit_status , type (compare_exit_status ))
185
185
if compare_exit_status != 0 :
186
186
common_funcs .add_entry (test_webpage , "#FF0000" , link , f"Failed { pmttype } plot comparisons" )
187
187
ret = 1
@@ -190,13 +190,13 @@ def compare_root_files(common_funcs, test_webpage, test_dir, variables, test_num
190
190
else :
191
191
common_funcs .add_entry (test_webpage , "#000000" , "" , f"No { pmttype } in geometry" )
192
192
193
- print ('wcsim_has_output, ret after loop over diffing root files' , wcsim_has_output , ret )
193
+ common_funcs . logger . info ('wcsim_has_output, ret after loop over diffing root files' , wcsim_has_output , ret )
194
194
if wcsim_has_output == 0 :
195
195
ret = 1
196
196
except Exception as e :
197
197
raise Exception (f"Unxpected error occured when comparing the root files: { e } " )
198
198
if debug :
199
- print (f"Return value after compare_root_files: { ret } " )
199
+ common_funcs . logger . info (f"Return value after compare_root_files: { ret } " )
200
200
return ret
201
201
202
202
def compare_geofile (common_funcs , test_webpage , variables , test_num , debug ):
@@ -228,7 +228,7 @@ def compare_geofile(common_funcs, test_webpage, variables, test_num, debug):
228
228
except Exception as e :
229
229
raise Exception (f"Unexpected error occured when comparing the geometry files: { e } " )
230
230
if debug :
231
- print (f"Return value after compare_geofile: { ret } " )
231
+ common_funcs . logger . info (f"Return value after compare_geofile: { ret } " )
232
232
return ret
233
233
234
234
def compare_badfile (common_funcs , test_webpage , variables , test_num , debug ):
@@ -280,7 +280,7 @@ def compare_badfile(common_funcs, test_webpage, variables, test_num, debug):
280
280
except Exception as e :
281
281
raise Exception (f"Unexpected error when comparing bad files: { e } " )
282
282
if debug :
283
- print (f"Return value after compare_badfile: { ret } " )
283
+ common_funcs . logger . info (f"Return value after compare_badfile: { ret } " )
284
284
return ret
285
285
286
286
def check_impossible_geometry (common_funcs , test_webpage , variables , test_num , debug ):
@@ -322,9 +322,9 @@ def check_impossible_geometry(common_funcs, test_webpage, variables, test_num, d
322
322
323
323
if os .path .getsize (impossiblefilename ) > 0 :
324
324
common_funcs .add_entry (test_webpage , "#FF0000" , f"<a href='{ impossiblefilename } '>" , "Geometry warnings exist" )
325
- print ("Geometry warnings exist:" )
325
+ common_funcs . logger . info ("Geometry warnings exist:" )
326
326
with open (impossiblefilename , "r" ) as impossible_file :
327
- print (impossible_file .read ())
327
+ common_funcs . logger . info (impossible_file .read ())
328
328
os .system (f"mv { impossiblefilename } { common_funcs .ValidationPath } /Webpage/{ common_funcs .GIT_COMMIT } /{ test_num } /" )
329
329
ret = 1
330
330
else :
@@ -334,7 +334,7 @@ def check_impossible_geometry(common_funcs, test_webpage, variables, test_num, d
334
334
except Exception as e :
335
335
raise Exception (f"Unexpected error occurred when checking impossible geometry: { e } " )
336
336
if debug :
337
- print (f"Return value after check_impossible_geometry: { ret } " )
337
+ common_funcs . logger . info (f"Return value after check_impossible_geometry: { ret } " )
338
338
return ret
339
339
340
340
def main ():
@@ -348,12 +348,27 @@ def main():
348
348
logger = common_funcs .logger
349
349
test_dir = f"{ common_funcs .ValidationPath } /Webpage/{ common_funcs .GIT_COMMIT } /{ args .test_num } "
350
350
351
+ #Check if the test number is correct, kill if not.
352
+
353
+ with open (os .path .join (common_funcs .ValidationPath , 'tests.json' ), 'r' ) as json_file :
354
+ data = json .load (json_file )
355
+
356
+ values = data [f'Test{ args .test_num } ' ]
357
+ test_name = values ['name' ]
358
+ test_type = values ['test' ]
359
+ test_variables = {key : value for key , value in values .items () if key not in ['name' , 'test' ]}
360
+
361
+
362
+
363
+ common_funcs .logger .info (f"Running test { args .test_num } with name: { test_name } of type: { test_type } with variables: { test_variables } " )
364
+
365
+
351
366
# Checkout validation repository
352
367
common_funcs .checkout_validation_webpage_branch ()
353
368
354
369
# build the comparison script
355
370
try :
356
- subprocess . run ([ "make" ], stdout = subprocess . PIPE , stderr = subprocess . STDOUT , check = True )
371
+ common_funcs . run_command ( "make" )
357
372
except subprocess .CalledProcessError as e :
358
373
raise subprocess .CalledProcessError (f"Failed to build the comparison script. Return code: { e .returncode } .\n Output: { e .output .decode ()} " )
359
374
@@ -372,16 +387,6 @@ def main():
372
387
footer_content = create_test_webpage_footer (common_funcs .ValidationPath )
373
388
test_webpage = create_test_webpage (test_dir , header_content , GIT_COMMIT_MESSAGE , common_funcs .GIT_COMMIT , common_funcs .GIT_PULL_REQUEST_LINK )
374
389
375
- with open (os .path .join (common_funcs .ValidationPath , 'tests.json' ), 'r' ) as json_file :
376
- data = json .load (json_file )
377
-
378
- values = data [f'Test{ args .test_num } ' ]
379
- test_name = values ['name' ]
380
- test_type = values ['test' ]
381
- test_variables = {key : value for key , value in values .items () if key not in ['name' , 'test' ]}
382
-
383
- print (f"Running test { args .test_num } with name: { test_name } of type: { test_type } with variables: { test_variables } " )
384
-
385
390
with open (test_webpage , 'a' ) as webpage :
386
391
webpage .write (f"\n <h3>{ test_name } </h3>\n " )
387
392
@@ -411,12 +416,12 @@ def main():
411
416
# Add the footer and...
412
417
# Add color code at the bottom for the list of jobs page
413
418
if ret == 0 :
414
- print ("Finishing writing webpage file. Nothing failed!" )
419
+ common_funcs . logger . info ("Finishing writing webpage file. Nothing failed!" )
415
420
with open (test_webpage , "a" ) as webpage_file :
416
421
webpage_file .write (footer_content )
417
422
webpage_file .write ("#00FF00\n " )
418
423
else :
419
- print ("Finishing writing webpage file. Something failed!" )
424
+ common_funcs . logger . info ("Finishing writing webpage file. Something failed!" )
420
425
with open (test_webpage , "a" ) as webpage_file :
421
426
webpage_file .write (footer_content )
422
427
webpage_file .write ("#FF0000\n " )
@@ -427,13 +432,14 @@ def main():
427
432
sys .exit (- 1 )
428
433
429
434
except FileNotFoundError as e :
430
- logger .error (f"File not found error in RunTests: { e } " )
435
+ logger .error (f"File not found error in RunTests: { type ( e ). __name__ } : { e } " )
431
436
sys .exit (1 )
432
437
except subprocess .CalledProcessError as e :
438
+ #Maybe this needs changing?
433
439
logger .error (f"Error running subprocess in RunTests: Return code { e .returncode } , Output: { e .output .decode ()} " )
434
440
sys .exit (1 )
435
441
except Exception as e :
436
- logger .error (f"An unexpected error occurred in RunTests: { e } " )
442
+ logger .error (f"An unexpected error occurred in RunTests: { type ( e ). __name__ } : { e } " )
437
443
sys .exit (1 )
438
444
439
445
if __name__ == "__main__" :
0 commit comments