<s> from __future__ import division <EOL> import subprocess <EOL> import os <EOL> BASE_DIR = os . path . join ( os . path . dirname ( __file__ ) , "<STR_LIT:..>" ) <EOL> TEST_DIR = os . path . join ( BASE_DIR , "<STR_LIT>" ) <EOL> EXTMODULE_DIR_PYSTON = os . path . abspath ( os . path . join ( BASE_DIR , "<STR_LIT>" ) ) <EOL> def main ( ) : <EOL> tests = os . listdir ( os . path . join ( TEST_DIR ) ) <EOL> ics_tests = [ os . path . join ( TEST_DIR , test ) for test in tests if <EOL> test . endswith ( "<STR_LIT>" ) and "<STR_LIT>" in test ] <EOL> results = [ ] <EOL> results . append ( [ '<STR_LIT:test>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> totalNumIcs = <NUM_LIT:0> <EOL> totalSizeIcs = <NUM_LIT:0> <EOL> asm_log = [ ] <EOL> for ics_test in ics_tests : <EOL> stats , assembly_logging = runTest ( ics_test ) <EOL> numIcs = stats [ '<STR_LIT>' ] <EOL> sizeIcs = stats [ '<STR_LIT>' ] <EOL> results . append ( [ ics_test , str ( numIcs ) , str ( sizeIcs ) , div ( sizeIcs , numIcs ) ] ) <EOL> totalNumIcs += numIcs <EOL> totalSizeIcs += sizeIcs <EOL> asm_log . append ( assembly_logging ) <EOL> print "<STR_LIT:\n>" . join ( asm_log ) <EOL> results . append ( [ '<STR_LIT>' , str ( totalNumIcs ) , str ( totalSizeIcs ) , div ( totalSizeIcs , totalNumIcs ) ] ) <EOL> printTable ( results ) <EOL> def div ( a , b ) : <EOL> if b == <NUM_LIT:0> : <EOL> return "<STR_LIT>" <EOL> else : <EOL> return '<STR_LIT>' % ( a / b ) <EOL> def runTest ( filename ) : <EOL> print '<STR_LIT>' , filename <EOL> pyston = os . path . join ( BASE_DIR , "<STR_LIT>" ) <EOL> env = dict ( os . environ ) <EOL> env [ "<STR_LIT>" ] = EXTMODULE_DIR_PYSTON <EOL> proc = subprocess . Popen ( [ pyston , "<STR_LIT>" , "<STR_LIT>" , filename ] , <EOL> stdout = subprocess . PIPE , <EOL> stderr = subprocess . PIPE , <EOL> stdin = subprocess . PIPE , <EOL> env = env ) <EOL> stdout , stderr = proc . communicate ( ) <EOL> if proc . wait ( ) != <NUM_LIT:0> : <EOL> raise Exception ( "<STR_LIT>" % filename ) <EOL> stderr , stats_str = stderr . split ( "<STR_LIT>" ) <EOL> stats_str , stderr_tail = stats_str . split ( "<STR_LIT>" ) <EOL> other_stats_str , counter_str = stats_str . split ( "<STR_LIT>" ) <EOL> stats = { } <EOL> for l in counter_str . strip ( ) . split ( '<STR_LIT:\n>' ) : <EOL> assert l . count ( '<STR_LIT::>' ) == <NUM_LIT:1> , l <EOL> k , v = l . split ( '<STR_LIT::>' ) <EOL> stats [ k . strip ( ) ] = int ( v ) <EOL> assembly_logging = stderr <EOL> return ( stats , assembly_logging ) <EOL> def printTable ( table ) : <EOL> widths = [ <NUM_LIT:3> + max ( len ( table [ i ] [ j ] ) for i in xrange ( len ( table ) ) ) for j in xrange ( len ( table [ <NUM_LIT:0> ] ) ) ] <EOL> for row in table : <EOL> for col , elem in enumerate ( row ) : <EOL> print elem , ( "<STR_LIT>" if col == len ( row ) - <NUM_LIT:1> else "<STR_LIT:U+0020>" * ( widths [ col ] - len ( elem ) ) ) , <EOL> print '<STR_LIT>' <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
