2020NO_JSON_REPORT_MESSAGE = ("Cannot locate JSON report [%s] for tests - "
2121 "required to build planemo report and summarize "
2222 "tests." )
23+ REPORT_NOT_CHANGED = ("Galaxy failed to update test report [%s] for tests - "
24+ "required to build planemo report and summarize "
25+ "tests." )
2326NO_TESTS_MESSAGE = "No tests were executed - see Galaxy output for details."
2427ALL_TESTS_PASSED_MESSAGE = "All %d test(s) executed passed."
2528PROBLEM_COUNT_MESSAGE = ("There were problems with %d test(s) - out of %d "
@@ -43,7 +46,9 @@ def run_in_config(ctx, config, run=run_galaxy_command, **kwds):
4346 job_output_files = os .path .join (config_directory , "jobfiles" )
4447
4548 xunit_report_file = _xunit_state (kwds , config )
49+ xunit_report_file_tracker = _FileChangeTracker (xunit_report_file )
4650 structured_report_file = _structured_report_file (kwds , config )
51+ structured_report_file_tracker = _FileChangeTracker (structured_report_file )
4752
4853 info ("Testing using galaxy_root %s" , config .galaxy_root )
4954 # TODO: Allow running dockerized Galaxy here instead.
@@ -85,15 +90,7 @@ def run_in_config(ctx, config, run=run_galaxy_command, **kwds):
8590 update_cp_args = (job_output_files , config .test_data_dir )
8691 shell ('cp -r "%s"/* "%s"' % update_cp_args )
8792
88- if not os .path .exists (xunit_report_file ):
89- message = NO_XUNIT_REPORT_MESSAGE % xunit_report_file
90- error (message )
91- raise Exception (message )
92-
93- if not os .path .exists (structured_report_file ):
94- message = NO_JSON_REPORT_MESSAGE % structured_report_file
95- error (message )
96- raise Exception (message )
93+ _check_test_outputs (xunit_report_file_tracker , structured_report_file_tracker )
9794
9895 test_results = test_structures .GalaxyTestResults (
9996 structured_report_file ,
@@ -248,6 +245,31 @@ def _print_command_line(structured_data, test_id):
248245 click .echo ("| command: %s" % command )
249246
250247
248+ def _check_test_outputs (
249+ xunit_report_file_tracker ,
250+ structured_report_file_tracker
251+ ):
252+ if not os .path .exists (xunit_report_file_tracker .path ):
253+ message = NO_XUNIT_REPORT_MESSAGE % xunit_report_file_tracker .path
254+ error (message )
255+ raise Exception (message )
256+
257+ if not os .path .exists (structured_report_file_tracker .path ):
258+ message = NO_JSON_REPORT_MESSAGE % structured_report_file_tracker .path
259+ error (message )
260+ raise Exception (message )
261+
262+ if not xunit_report_file_tracker .changed ():
263+ message = REPORT_NOT_CHANGED % xunit_report_file_tracker .path
264+ error (message )
265+ raise Exception (message )
266+
267+ if not structured_report_file_tracker .changed ():
268+ message = REPORT_NOT_CHANGED % structured_report_file_tracker .path
269+ error (message )
270+ raise Exception (message )
271+
272+
251273def _xunit_state (kwds , config ):
252274 # This has been supported in Galaxy for well over a year, just going to assume
253275 # it from here on out.
@@ -278,6 +300,24 @@ def _structured_report_file(kwds, config):
278300 return structured_report_file
279301
280302
303+ class _FileChangeTracker (object ):
304+
305+ def __init__ (self , path ):
306+ modification_time = None
307+ if os .path .exists (path ):
308+ modification_time = os .path .getmtime (path )
309+
310+ self .path = path
311+ self .modification_time = modification_time
312+
313+ def changed (self ):
314+ if self .modification_time :
315+ new_modification_time = os .path .getmtime (self .path )
316+ return self .modification_time != new_modification_time
317+ else :
318+ return os .path .exists (self .path )
319+
320+
281321__all__ = [
282322 "run_in_config" ,
283323 "handle_reports" ,
0 commit comments