~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

  • Committer: Carl Friedrich Bolz
  • Date: 2006-07-05 12:27:59 UTC
  • mto: This revision was merged to the branch mainline in revision 1928.
  • Revision ID: cfbolz@gmx.de-20060705122759-0a3481a4647b16dc
(lifeless, cfbolz): Add recording of benchmark results to the benchmark history
file ".perf_history".

Show diffs side-by-side

added added

removed removed

Lines of Context:
477
477
                                        bench_history=output
478
478
                                        )
479
479
        output_string = output.getvalue()
480
 
        self.assertContainsRe(output_string, "--date [0-9.]+")
481
 
 
 
480
        self.assertContainsRe(output_string, "--date [0-9.]+\n")
 
481
 
 
482
    def test_benchhistory_records_test_times(self):
 
483
        result_stream = StringIO()
 
484
        result = bzrlib.tests._MyResult(
 
485
            self._log_file,
 
486
            descriptions=0,
 
487
            verbosity=1,
 
488
            bench_history=result_stream
 
489
            )
 
490
 
 
491
        # we want profile a call and check that its test duration is recorded
 
492
        # make a new test instance that when run will generate a benchmark
 
493
        example_test_case = TestTestResult("_time_hello_world_encoding")
 
494
        # execute the test, which should succeed and record times
 
495
        example_test_case.run(result)
 
496
        lines = result_stream.getvalue().splitlines()
 
497
        self.assertEqual(2, len(lines))
 
498
        self.assertContainsRe(lines[1],
 
499
            " *[0-9]+ms bzrlib.tests.test_selftest.TestTestResult"
 
500
            "._time_hello_world_encoding")
 
501
 
482
502
    def _time_hello_world_encoding(self):
483
503
        """Profile two sleep calls
484
504
        
579
599
        runner = TextTestRunner(stream=self._log_file, bench_history=output)
580
600
        result = self.run_test_runner(runner, test)
581
601
        output_string = output.getvalue()
582
 
        self.assertContainsRe(output_string, "--date [0-9.]+")
 
602
        self.assertContainsRe(output_string, "--date [0-9.]+\n")
583
603
 
584
604
 
585
605
class TestTestCase(TestCase):