@@ -84,26 +84,43 @@ def _unittest_config_participant(config):
8484
8585mx_unittest .add_config_participant (_unittest_config_participant )
8686
87- def _check_compiler_log (compiler_log_file , expectations , extra_check = None ):
87+ def _check_compiler_log (compiler_log_file , expectations , extra_check = None , extra_log_files = None ):
8888 """
89- Checks that `compiler_log_file` exists and that its contents match each regular expression in `expectations`.
89+ Checks that `compiler_log_file` exists and that its contents matches each regular expression in `expectations`.
9090 If all checks succeed, `compiler_log_file` is deleted.
9191 """
92+ def append_extra_logs ():
93+ suffix = ''
94+ if extra_log_files :
95+ for extra_log_file in extra_log_files :
96+ if exists (extra_log_file ):
97+ nl = os .linesep
98+ with open (extra_log_file ) as fp :
99+ lines = fp .readlines ()
100+ if len (lines ) > 50 :
101+ lines = lines [0 :25 ] + [f'...{ nl } ' , f'<omitted { len (lines ) - 50 } lines>{ nl } ' , f'...{ nl } ' ] + lines [- 50 :]
102+ if lines :
103+ suffix += f'{ nl } { extra_log_file } :\n ' + '' .join (lines )
104+ return suffix
105+
92106 in_exception_path = sys .exc_info () != (None , None , None )
93107 if not exists (compiler_log_file ):
94- mx .abort ('No output written to ' + compiler_log_file )
108+ mx .abort (f 'No output written to { compiler_log_file } { append_extra_logs () } ' )
95109 with open (compiler_log_file ) as fp :
96110 compiler_log = fp .read ()
97111 if not isinstance (expectations , list ) and not isinstance (expectations , tuple ):
98112 expectations = [expectations ]
99113 for pattern in expectations :
100114 if not re .search (pattern , compiler_log ):
101- mx .abort (f'Did not find expected pattern ("{ pattern } ") in compiler log:{ linesep } { compiler_log } ' )
115+ mx .abort (f'Did not find expected pattern ("{ pattern } ") in compiler log:{ linesep } { compiler_log } { append_extra_logs () } ' )
102116 if extra_check is not None :
103117 extra_check (compiler_log )
104118 if mx .get_opts ().verbose or in_exception_path :
105119 mx .log (compiler_log )
106120 remove (compiler_log_file )
121+ if extra_log_files :
122+ for extra_log_file in extra_log_files :
123+ remove (extra_log_file )
107124
108125def _test_libgraal_basic (extra_vm_arguments , libgraal_location ):
109126 """
@@ -314,6 +331,7 @@ def _test_libgraal_CompilationTimeout_Truffle(extra_vm_arguments):
314331 """
315332 graalvm_home = mx_sdk_vm_impl .graalvm_home ()
316333 compiler_log_file = abspath ('graal-compiler.log' )
334+ truffle_log_file = abspath ('truffle-compiler.log' )
317335 G = '-Dgraal.' #pylint: disable=invalid-name
318336 P = '-Dpolyglot.engine.' #pylint: disable=invalid-name
319337 for vm_can_exit in (False , True ):
@@ -330,7 +348,7 @@ def _test_libgraal_CompilationTimeout_Truffle(extra_vm_arguments):
330348 f'{ P } TraceCompilation=false' ,
331349 f'{ P } CompileImmediately=true' ,
332350 f'{ P } BackgroundCompilation=false' ,
333- f'-Dpolyglot.log.file={ compiler_log_file } ' ,
351+ f'-Dpolyglot.log.file={ truffle_log_file } ' ,
334352 '-Ddebug.graal.CompilationWatchDog=true' , # helps debug failure
335353 '-Dgraalvm.locatorDisabled=true' ,
336354 '-Dtruffle.attach.library=' + mx_subst .path_substitutions .substitute ('<path:TRUFFLE_LIBGRAAL_TRUFFLEATTACH>/bin/<lib:truffleattach>' ),
@@ -344,27 +362,9 @@ def _test_libgraal_CompilationTimeout_Truffle(extra_vm_arguments):
344362 exit_code = mx .run (cmd , nonZeroIsFatal = False , err = err )
345363 if err .data :
346364 mx .log (err .data )
347- if 'Could not find or load main class com.oracle.truffle.sl.launcher.SLMain' in err .data :
348- # Extra diagnostics to debug GR-43161
349-
350- # Can we find the class with javap?
351- cmd = [join (graalvm_home , 'bin' , 'javap' ), '-cp' , cp , 'com.oracle.truffle.sl.launcher.SLMain' ]
352- mx .log (' ' .join (cmd ))
353- mx .run (cmd , nonZeroIsFatal = False )
354-
355- # Maybe the class files are disappearing?
356- for p in ('com.oracle.truffle.sl' , 'com.oracle.truffle.sl.launcher' ):
357- classes_dir = mx .project (p ).output_dir ()
358- mx .log (f'Contents of { classes_dir } :' )
359- for root , dirnames , filenames in os .walk (classes_dir ):
360- for name in dirnames + filenames :
361- mx .log (' ' + join (root , name ))
362-
363- # Ignore this transient failure until it's clear what is causing it
364- return
365365
366366 expectations = ['detected long running compilation' ] + (['a stuck compilation' ] if vm_can_exit else [])
367- _check_compiler_log (compiler_log_file , expectations )
367+ _check_compiler_log (compiler_log_file , expectations , extra_log_files = [ truffle_log_file ] )
368368 if vm_can_exit :
369369 # org.graalvm.compiler.core.CompilationWatchDog.EventHandler.STUCK_COMPILATION_EXIT_CODE
370370 if exit_code != 84 :
0 commit comments