test.py
changeset 5279 1aec8ea805d2
parent 5275 d4008f2981ba
child 5295 c1bd4ffb5e47
equal deleted inserted replaced
5278:ef65dbb51385 5279:1aec8ea805d2
   652     # through the list of test suites and dispatch a job to run each one.
   652     # through the list of test suites and dispatch a job to run each one.
   653     # 
   653     # 
   654     # Dispatching will run with unlimited speed and the worker threads will 
   654     # Dispatching will run with unlimited speed and the worker threads will 
   655     # execute as fast as possible from the queue.
   655     # execute as fast as possible from the queue.
   656     #
   656     #
       
   657     total_tests = 0
   657     for test in suite_list:
   658     for test in suite_list:
   658         if len(test):
   659         if len(test):
   659             job = Job()
   660             job = Job()
   660             job.set_is_example(False)
   661             job.set_is_example(False)
   661             job.set_display_name(test)
   662             job.set_display_name(test)
   667             if options.verbose:
   668             if options.verbose:
   668                 print "Queue %s" % test
   669                 print "Queue %s" % test
   669 
   670 
   670             input_queue.put(job)
   671             input_queue.put(job)
   671             jobs = jobs + 1
   672             jobs = jobs + 1
       
   673             total_tests = total_tests + 1
   672     
   674     
   673     #
   675     #
   674     # We've taken care of the discovered or specified test suites.  Now we
   676     # We've taken care of the discovered or specified test suites.  Now we
   675     # have to deal with examples run as smoke tests.  We have a list of all of
   677     # have to deal with examples run as smoke tests.  We have a list of all of
   676     # the example programs it makes sense to try and run.  Each example will
   678     # the example programs it makes sense to try and run.  Each example will
   726                     if options.verbose:
   728                     if options.verbose:
   727                         print "Queue %s" % test
   729                         print "Queue %s" % test
   728 
   730 
   729                     input_queue.put(job)
   731                     input_queue.put(job)
   730                     jobs = jobs + 1
   732                     jobs = jobs + 1
       
   733                     total_tests = total_tests + 1
       
   734 
   731     elif len(options.example):
   735     elif len(options.example):
   732         #
   736         #
   733         # If you tell me to run an example, I will try and run the example
   737         # If you tell me to run an example, I will try and run the example
   734         # irrespective of any condition.
   738         # irrespective of any condition.
   735         #
   739         #
   744         if options.verbose:
   748         if options.verbose:
   745             print "Queue %s" % test
   749             print "Queue %s" % test
   746 
   750 
   747         input_queue.put(job)
   751         input_queue.put(job)
   748         jobs = jobs + 1
   752         jobs = jobs + 1
       
   753         total_tests = total_tests + 1
   749 
   754 
   750     #
   755     #
   751     # Tell the worker threads to pack up and go home for the day.  Each one
   756     # Tell the worker threads to pack up and go home for the day.  Each one
   752     # will exit when they see their is_break task.
   757     # will exit when they see their is_break task.
   753     #
   758     #
   764     # they stop doing real work and will just start throwing jobs back at us
   769     # they stop doing real work and will just start throwing jobs back at us
   765     # with is_break set to True.  In this case, there are no real results so we 
   770     # with is_break set to True.  In this case, there are no real results so we 
   766     # ignore them.  If there are real results, we always print PASS or FAIL to
   771     # ignore them.  If there are real results, we always print PASS or FAIL to
   767     # standard out as a quick indication of what happened.
   772     # standard out as a quick indication of what happened.
   768     #
   773     #
       
   774     passed_tests = 0
       
   775     failed_tests = 0
       
   776     crashed_tests = 0
   769     for i in range(jobs):
   777     for i in range(jobs):
   770         job = output_queue.get()
   778         job = output_queue.get()
   771         if job.is_break:
   779         if job.is_break:
   772             continue
   780             continue
   773 
   781 
   776         else:
   784         else:
   777             kind = "TestSuite"
   785             kind = "TestSuite"
   778 
   786 
   779         if job.returncode == 0:
   787         if job.returncode == 0:
   780             status = "PASS"
   788             status = "PASS"
       
   789             passed_tests = passed_tests + 1
       
   790         elif job.returncode == 1:
       
   791             failed_tests = failed_tests + 1
       
   792             status = "FAIL"
   781         else:
   793         else:
   782             status = "FAIL"
   794             crashed_tests = crashed_tests + 1
       
   795             status = "CRASH"
   783 
   796 
   784         print "%s: %s %s" % (status, kind, job.display_name)
   797         print "%s: %s %s" % (status, kind, job.display_name)
   785 
   798 
   786         if job.is_example == True:
   799         if job.is_example == True:
   787             #
   800             #
   859     f = open(xml_results_file, 'a')
   872     f = open(xml_results_file, 'a')
   860     f.write('</TestResults>\n')
   873     f.write('</TestResults>\n')
   861     f.close()
   874     f.close()
   862 
   875 
   863     #
   876     #
       
   877     # Print a quick summary of events
       
   878     #
       
   879     print "%d of %d tests passed (%d passed, %d failed, %d crashed)" % (passed_tests, total_tests, passed_tests, 
       
   880                                                                         failed_tests, crashed_tests)
       
   881     #
   864     # The last things to do are to translate the XML results file to "human
   882     # The last things to do are to translate the XML results file to "human
   865     # readable form" if the user asked for it (or make an XML file somewhere)
   883     # readable form" if the user asked for it (or make an XML file somewhere)
   866     #
   884     #
   867     if len(options.html):
   885     if len(options.html):
   868         translate_to_html(xml_results_file, options.html)
   886         translate_to_html(xml_results_file, options.html)