@@ -341,6 +341,39 @@ def HasRun(self, output):
341341 def Done (self ):
342342 pass
343343
344+ class DeoptsCheckProgressIndicator (SimpleProgressIndicator ):
345+
346+ def Starting (self ):
347+ pass
348+
349+ def AboutToRun (self , case ):
350+ pass
351+
352+ def HasRun (self , output ):
353+ # Print test name as (for example) "parallel/test-assert". Tests that are
354+ # scraped from the addons documentation are all named test.js, making it
355+ # hard to decipher what test is running when only the filename is printed.
356+ prefix = abspath (join (dirname (__file__ ), '../test' )) + os .sep
357+ command = output .command [- 1 ]
358+ if command .endswith ('.js' ): command = command [:- 3 ]
359+ if command .startswith (prefix ): command = command [len (prefix ):]
360+ command = command .replace ('\\ ' , '/' )
361+
362+ stdout = output .output .stdout .strip ()
363+ printed_file = False
364+ for line in stdout .splitlines ():
365+ if (line .startswith ("[aborted optimiz" ) or \
366+ line .startswith ("[disabled optimiz" )) and \
367+ ("because:" in line or "reason:" in line ):
368+ if not printed_file :
369+ printed_file = True
370+ print '==== %s ====' % command
371+ self .failed .append (output )
372+ print ' %s' % line
373+
374+ def Done (self ):
375+ pass
376+
344377
345378class CompactProgressIndicator (ProgressIndicator ):
346379
@@ -433,7 +466,8 @@ def ClearLine(self, last_line_length):
433466 'dots' : DotsProgressIndicator ,
434467 'color' : ColorProgressIndicator ,
435468 'tap' : TapProgressIndicator ,
436- 'mono' : MonochromeProgressIndicator
469+ 'mono' : MonochromeProgressIndicator ,
470+ 'deopts' : DeoptsCheckProgressIndicator
437471}
438472
439473
@@ -1383,6 +1417,8 @@ def BuildOptions():
13831417 help = "Expect test cases to fail" , default = False , action = "store_true" )
13841418 result .add_option ("--valgrind" , help = "Run tests through valgrind" ,
13851419 default = False , action = "store_true" )
1420+ result .add_option ("--check-deopts" , help = "Check tests for permanent deoptimizations" ,
1421+ default = False , action = "store_true" )
13861422 result .add_option ("--cat" , help = "Print the source of the tests" ,
13871423 default = False , action = "store_true" )
13881424 result .add_option ("--flaky-tests" ,
@@ -1586,6 +1622,14 @@ def Main():
15861622 run_valgrind = join (workspace , "tools" , "run-valgrind.py" )
15871623 options .special_command = "python -u " + run_valgrind + " @"
15881624
1625+ if options .check_deopts :
1626+ options .node_args .append ("--trace-opt" )
1627+ options .node_args .append ("--trace-file-names" )
1628+ # --always-opt is needed because many tests do not run long enough for the
1629+ # optimizer to kick in, so this flag will force it to run.
1630+ options .node_args .append ("--always-opt" )
1631+ options .progress = "deopts"
1632+
15891633 shell = abspath (options .shell )
15901634 buildspace = dirname (shell )
15911635
0 commit comments