@@ -340,6 +340,39 @@ def HasRun(self, output):
340340 def Done (self ):
341341 pass
342342
343+ class DeoptsCheckProgressIndicator (SimpleProgressIndicator ):
344+
345+ def Starting (self ):
346+ pass
347+
348+ def AboutToRun (self , case ):
349+ pass
350+
351+ def HasRun (self , output ):
352+ # Print test name as (for example) "parallel/test-assert". Tests that are
353+ # scraped from the addons documentation are all named test.js, making it
354+ # hard to decipher what test is running when only the filename is printed.
355+ prefix = abspath (join (dirname (__file__ ), '../test' )) + os .sep
356+ command = output .command [- 1 ]
357+ if command .endswith ('.js' ): command = command [:- 3 ]
358+ if command .startswith (prefix ): command = command [len (prefix ):]
359+ command = command .replace ('\\ ' , '/' )
360+
361+ stdout = output .output .stdout .strip ()
362+ printed_file = False
363+ for line in stdout .splitlines ():
364+ if (line .startswith ("[aborted optimiz" ) or \
365+ line .startswith ("[disabled optimiz" )) and \
366+ ("because:" in line or "reason:" in line ):
367+ if not printed_file :
368+ printed_file = True
369+ print '==== %s ====' % command
370+ self .failed .append (output )
371+ print ' %s' % line
372+
373+ def Done (self ):
374+ pass
375+
343376
344377class CompactProgressIndicator (ProgressIndicator ):
345378
@@ -432,7 +465,8 @@ def ClearLine(self, last_line_length):
432465 'dots' : DotsProgressIndicator ,
433466 'color' : ColorProgressIndicator ,
434467 'tap' : TapProgressIndicator ,
435- 'mono' : MonochromeProgressIndicator
468+ 'mono' : MonochromeProgressIndicator ,
469+ 'deopts' : DeoptsCheckProgressIndicator
436470}
437471
438472
@@ -1367,6 +1401,8 @@ def BuildOptions():
13671401 help = "Expect test cases to fail" , default = False , action = "store_true" )
13681402 result .add_option ("--valgrind" , help = "Run tests through valgrind" ,
13691403 default = False , action = "store_true" )
1404+ result .add_option ("--check-deopts" , help = "Check tests for permanent deoptimizations" ,
1405+ default = False , action = "store_true" )
13701406 result .add_option ("--cat" , help = "Print the source of the tests" ,
13711407 default = False , action = "store_true" )
13721408 result .add_option ("--flaky-tests" ,
@@ -1569,6 +1605,14 @@ def Main():
15691605 run_valgrind = join (workspace , "tools" , "run-valgrind.py" )
15701606 options .special_command = "python -u " + run_valgrind + " @"
15711607
1608+ if options .check_deopts :
1609+ options .node_args .append ("--trace-opt" )
1610+ options .node_args .append ("--trace-file-names" )
1611+ # --always-opt is needed because many tests do not run long enough for the
1612+ # optimizer to kick in, so this flag will force it to run.
1613+ options .node_args .append ("--always-opt" )
1614+ options .progress = "deopts"
1615+
15721616 shell = abspath (options .shell )
15731617 buildspace = dirname (shell )
15741618
0 commit comments