@@ -592,6 +592,24 @@ def _gnur_install_test(forwarded_args, pkgs, gnur_libinstall, gnur_install_tmp):
592592 log_step ('END' , 'install/test' , 'GnuR' )
593593
594594
595+ def get_contents (files ):
596+ def robust_readlines (file ):
597+ try :
598+ with open (file ) as f :
599+ return f .readlines ()
600+ except :
601+ return ["Could not read the contents of " + file ]
602+
603+ # normalize to a list
604+ list = [files ] if isinstance (files , str ) else files
605+ # print contents of all the files
606+ '\n ' .join ([format_contents (x , robust_readlines (x )) for x in list ])
607+
608+
609+ def format_contents (filename , contents ):
610+ return '\n ' + filename + "\n ########\n {0}########" .format ('\n ' .join (contents ))
611+
612+
595613def _set_test_status (fastr_test_info ):
596614 def _failed_outputs (outputs ):
597615 '''
@@ -619,13 +637,14 @@ def _failed_outputs(outputs):
619637 # What this likely means is that some native package is not
620638 # installed on the system so GNUR can't run the tests.
621639 # Ideally this never happens.
622- logging .info ("{0}: GnuR test had .fail outputs: {1}" .format (pkg , str ([s + '.fail' for s in gnur_failed_outputs ])))
640+ failed_outputs = [s + '.fail' for s in gnur_failed_outputs ]
641+ logging .info ("{0}: GnuR test had .fail outputs: {1}\n {2}" .format (pkg , str (failed_outputs ), get_contents (failed_outputs )))
623642
624643 fastr_failed_outputs = _failed_outputs (fastr_outputs )
625644 if fastr_failed_outputs :
626645 # In addition to the similar comment for GNU R, this can happen
627646 # if, say, the JVM crashes (possible with native code packages)
628- logging .info ("{0}: FastR test had .fail outputs: {1}" .format (pkg , str (fastr_failed_outputs )))
647+ logging .info ("{0}: FastR test had .fail outputs: {1}\n {2} " .format (pkg , str ( fastr_failed_outputs ), get_contents (fastr_failed_outputs )))
629648 fastr_test_status .set_status_code ("FAILED" )
630649
631650 # Now for each successful GNU R output we compare content (assuming FastR didn't fail)
@@ -665,6 +684,7 @@ def _failed_outputs(outputs):
665684
666685 # first, parse file and see if a known test framework has been used
667686 detected , ok , skipped , failed = handle_output_file (fastr_testfile_status .abspath , fastr_content )
687+ log_files = False
668688 if detected :
669689 # If a test framework is used, also parse the summary generated by GnuR to compare numbers.
670690 detected , gnur_ok , gnur_skipped , gnur_failed = handle_output_file (gnur_testfile_status .abspath ,
@@ -676,9 +696,11 @@ def _failed_outputs(outputs):
676696
677697 if not fastr_invalid_numbers and total_fastr != total_gnur :
678698 logging .info (
679- "Different number of tests executed. FastR = {} vs. GnuR = {}" .format (total_fastr , total_gnur ))
699+ "Different number of tests executed. FastR = {} vs. GnuR = {}\n " .format (total_fastr , total_gnur ))
700+ log_files = True
680701 elif fastr_invalid_numbers :
681702 logging .info ("FastR reported invalid numbers of executed tests." )
703+ log_files = True
682704
683705 if fastr_invalid_numbers or total_fastr > total_gnur :
684706 # If FastR's numbers are invalid or GnuR ran fewer tests than FastR, we cannot trust the FastR numbers
@@ -705,17 +727,24 @@ def _failed_outputs(outputs):
705727 fastr_test_status .set_status_code ("INDETERMINATE" )
706728 # we don't know how many tests are in there, so consider the whole file to be one big skipped test
707729 fastr_testfile_status .set_report (0 , 1 , 0 )
730+ log_files = True
708731 elif result != 0 :
709732 fastr_test_status .set_status_code ("FAILED" )
710733 fastr_testfile_status .status = "FAILED"
711734 fastr_testfile_status .set_report (n_tests_passed , 0 , n_tests_failed )
712735 logging .info ("{0}: FastR output mismatch: {1}" .format (pkg , gnur_test_output_relpath ))
713736 logging .info (" output mismatch file: {0}" .format (join (_pkg_testdir (RVM_FASTR , pkg ), gnur_test_output_relpath )))
714737 logging .info (" output mismatch file: {0}" .format (join (_pkg_testdir (RVM_GNUR , pkg ), gnur_test_output_relpath )))
738+ log_files = True
715739 else :
716740 fastr_testfile_status .status = "OK"
717741 fastr_testfile_status .set_report (n_tests_passed , 0 , n_tests_failed )
718742
743+ # print out the full output files if the test failed
744+ if log_files :
745+ logging .info (format_contents (gnur_testfile_status .abspath , gnur_content ) + format_contents (
746+ fastr_testfile_status .abspath , fastr_content ))
747+
719748 # we started out as UNKNOWN
720749 if not (fastr_test_status .status == "INDETERMINATE" or fastr_test_status .status == "FAILED" ):
721750 fastr_test_status .set_status_code ("OK" )
0 commit comments