~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

  • Committer: Alexander Belchenko
  • Date: 2006-12-19 08:26:36 UTC
  • mfrom: (2198 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2204.
  • Revision ID: bialix@ukr.net-20061219082636-xbb55np3wnamva8t
merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
585
585
        result.extractBenchmarkTime(self)
586
586
        timed_string = result._testTimeString()
587
587
        # without explicit benchmarking, we should get a simple time.
588
 
        self.assertContainsRe(timed_string, "^         [ 1-9][0-9]ms$")
 
588
        self.assertContainsRe(timed_string, "^ *[ 1-9][0-9]ms$")
589
589
        # if a benchmark time is given, we want a x of y style result.
590
590
        self.time(time.sleep, 0.001)
591
591
        result.extractBenchmarkTime(self)
592
592
        timed_string = result._testTimeString()
593
 
        self.assertContainsRe(timed_string, "^   [ 1-9][0-9]ms/   [ 1-9][0-9]ms$")
 
593
        self.assertContainsRe(timed_string, "^ *[ 1-9][0-9]ms/ *[ 1-9][0-9]ms$")
594
594
        # extracting the time from a non-bzrlib testcase sets to None
595
595
        result._recordTestStartTime()
596
596
        result.extractBenchmarkTime(
597
597
            unittest.FunctionTestCase(self.test_elapsed_time_with_benchmarking))
598
598
        timed_string = result._testTimeString()
599
 
        self.assertContainsRe(timed_string, "^         [ 1-9][0-9]ms$")
 
599
        self.assertContainsRe(timed_string, "^ *[ 1-9][0-9]ms$")
600
600
        # cheat. Yes, wash thy mouth out with soap.
601
601
        self._benchtime = None
602
602
 
999
999
        self.apply_redirected(out, err, None, bzrlib.tests.selftest, 
1000
1000
            test_suite_factory=factory)
1001
1001
        self.assertEqual([True], factory_called)
 
1002
 
 
1003
 
 
1004
class TestSelftestCleanOutput(TestCaseInTempDir):
 
1005
 
 
1006
    def test_clean_output(self):
 
1007
        # test functionality of clean_selftest_output()
 
1008
        from bzrlib.tests import clean_selftest_output
 
1009
 
 
1010
        dirs = ('test0000.tmp', 'test0001.tmp', 'bzrlib', 'tests')
 
1011
        files = ('bzr', 'setup.py', 'test9999.tmp')
 
1012
        for i in dirs:
 
1013
            os.mkdir(i)
 
1014
        for i in files:
 
1015
            f = file(i, 'wb')
 
1016
            f.write('content of ')
 
1017
            f.write(i)
 
1018
            f.close()
 
1019
 
 
1020
        root = os.getcwdu()
 
1021
        before = os.listdir(root)
 
1022
        before.sort()
 
1023
        self.assertEquals(['bzr','bzrlib','setup.py',
 
1024
                           'test0000.tmp','test0001.tmp',
 
1025
                           'test9999.tmp','tests'],
 
1026
                           before)
 
1027
        clean_selftest_output(root, quiet=True)
 
1028
        after = os.listdir(root)
 
1029
        after.sort()
 
1030
        self.assertEquals(['bzr','bzrlib','setup.py',
 
1031
                           'test9999.tmp','tests'],
 
1032
                           after)