~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_selftest.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-07-05 01:04:27 UTC
  • mfrom: (2581.1.6 cleanup-runbzr)
  • Revision ID: pqm@pqm.ubuntu.com-20070705010427-0839hywgo4ioup2t
(mbp,vila) more run_bzr cleanups

Show diffs side-by-side

added added

removed removed

Lines of Context:
113
113
 
114
114
    def test_args(self):
115
115
        """Test that run_bzr passes args correctly to _run_bzr_core"""
116
 
        ## self.callDeprecated(
117
 
        ##         ['passing varargs to run_bzr was deprecated in version 0.18.'],
118
 
        ##         self.run_bzr,
119
 
        ##         'arg1', 'arg2', 'arg3', retcode=1)
120
 
        self.run_bzr('arg1', 'arg2', 'arg3', retcode=1)
 
116
        self.callDeprecated(
 
117
                ['passing varargs to run_bzr was deprecated in version 0.18.'],
 
118
                self.run_bzr,
 
119
                'arg1', 'arg2', 'arg3', retcode=1)
121
120
        self.assertEqual(['arg1', 'arg2', 'arg3'], self.argv)
122
121
 
123
122
    def test_encoding(self):
183
182
        old_root = TestCaseWithMemoryTransport.TEST_ROOT
184
183
        try:
185
184
            TestCaseWithMemoryTransport.TEST_ROOT = None
186
 
            out, err = self.run_bzr(['selftest', '--benchmark',
187
 
                'workingtree_implementations'])
 
185
            out, err = self.run_bzr('selftest --benchmark'
 
186
                                    ' workingtree_implementations')
188
187
        finally:
189
188
            TestCaseWithMemoryTransport.TEST_ROOT = old_root
190
189
        self.assertContainsRe(out, 'Ran 0 tests.*\n\nOK')
434
433
        """
435
434
        process = self.start_bzr_subprocess(['--versionn'])
436
435
        self.assertRaises(self.failureException, self.finish_bzr_subprocess,
437
 
                          process, retcode=0)
 
436
                          process)
438
437
        
439
438
    def test_start_and_stop_bzr_subprocess_send_signal(self):
440
439
        """finish_bzr_subprocess raises self.failureException if the retcode is
462
461
class TestRunBzrError(ExternalBase):
463
462
 
464
463
    def test_run_bzr_error(self):
 
464
        # retcode=0 is specially needed here because run_bzr_error expects
 
465
        # an error (oddly enough) but we want to test the case of not
 
466
        # actually getting one
465
467
        out, err = self.run_bzr_error(['^$'], ['rocks'], retcode=0)
466
468
        self.assertEqual(out, 'It sure does!\n')
467
 
 
468
 
        out, err = self.run_bzr_error(["bzr: ERROR: foobarbaz is not versioned"],
469
 
                                      ['file-id', 'foobarbaz'])
 
469
        # now test actually getting an error
 
470
        out, err = self.run_bzr_error(
 
471
                ["bzr: ERROR: foobarbaz is not versioned"],
 
472
                ['file-id', 'foobarbaz'])
470
473
 
471
474
 
472
475
class TestSelftestCleanOutput(TestCaseInTempDir):
491
494
                           'test9999.tmp','tests'],
492
495
                           before)
493
496
 
494
 
        out, err = self.run_bzr(['selftest','--clean-output'],
495
 
                                        working_dir=root)
 
497
        out, err = self.run_bzr('selftest --clean-output',
 
498
                                working_dir=root)
496
499
 
497
500
        self.assertEquals(['delete directory: test0000.tmp',
498
501
                          'delete directory: test0001.tmp'],
540
543
 
541
544
    def test_list_only(self):
542
545
        # check that bzr selftest --list-only works correctly
543
 
        out,err = self.run_bzr(['selftest', 'selftest',
544
 
            '--list-only'])
 
546
        out,err = self.run_bzr('selftest selftest --list-only')
545
547
        self.assertEndsWith(err, 'tests passed\n')
546
548
        (header,body,footer) = self._parse_test_list(out.splitlines())
547
549
        num_tests = len(body)
549
551
 
550
552
    def test_list_only_filtered(self):
551
553
        # check that a filtered --list-only works, both include and exclude
552
 
        out_all,err_all = self.run_bzr(['selftest', '--list-only'])
 
554
        out_all,err_all = self.run_bzr('selftest --list-only')
553
555
        tests_all = self._parse_test_list(out_all.splitlines())[1]
554
 
        out_incl,err_incl = self.run_bzr(['selftest', '--list-only',
555
 
          'selftest'])
 
556
        out_incl,err_incl = self.run_bzr('selftest --list-only selftest')
556
557
        tests_incl = self._parse_test_list(out_incl.splitlines())[1]
557
558
        self.assertSubset(tests_incl, tests_all)
558
559
        out_excl,err_excl = self.run_bzr(['selftest', '--list-only',
559
 
          '--exclude', 'selftest'])
 
560
                                          '--exclude', 'selftest'])
560
561
        tests_excl = self._parse_test_list(out_excl.splitlines())[1]
561
562
        self.assertSubset(tests_excl, tests_all)
562
563
        set_incl = set(tests_incl)
567
568
 
568
569
    def test_list_only_random(self):
569
570
        # check that --randomize works correctly
570
 
        out_all,err_all = self.run_bzr(['selftest', '--list-only',
571
 
            'selftest'])
 
571
        out_all,err_all = self.run_bzr('selftest --list-only selftest')
572
572
        tests_all = self._parse_test_list(out_all.splitlines())[1]
573
573
        # XXX: It looks like there are some orders for generating tests that
574
574
        # fail as of 20070504 - maybe because of import order dependencies.
575
575
        # So unfortunately this will rarely intermittently fail at the moment.
576
576
        # -- mbp 20070504
577
577
        out_rand,err_rand = self.run_bzr(['selftest', '--list-only',
578
 
            'selftest', '--randomize', 'now'])
 
578
                                          'selftest', '--randomize', 'now'])
579
579
        (header_rand,tests_rand,dummy) = self._parse_test_list(
580
580
            out_rand.splitlines(), 2)
581
581
        self.assertNotEqual(tests_all, tests_rand)
585
585
        match_obj = seed_re.search(header_rand[-1])
586
586
        seed = match_obj.group(1)
587
587
        out_rand2,err_rand2 = self.run_bzr(['selftest', '--list-only',
588
 
            'selftest', '--randomize', seed])
 
588
                                            'selftest', '--randomize', seed])
589
589
        (header_rand2,tests_rand2,dummy) = self._parse_test_list(
590
590
            out_rand2.splitlines(), 2)
591
591
        self.assertEqual(tests_rand, tests_rand2)