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.'],
119
## 'arg1', 'arg2', 'arg3', retcode=1)
120
self.run_bzr('arg1', 'arg2', 'arg3', retcode=1)
117
['passing varargs to run_bzr was deprecated in version 0.18.'],
119
'arg1', 'arg2', 'arg3', retcode=1)
121
120
self.assertEqual(['arg1', 'arg2', 'arg3'], self.argv)
123
122
def test_encoding(self):
183
182
old_root = TestCaseWithMemoryTransport.TEST_ROOT
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')
189
188
TestCaseWithMemoryTransport.TEST_ROOT = old_root
190
189
self.assertContainsRe(out, 'Ran 0 tests.*\n\nOK')
435
434
process = self.start_bzr_subprocess(['--versionn'])
436
435
self.assertRaises(self.failureException, self.finish_bzr_subprocess,
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):
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')
468
out, err = self.run_bzr_error(["bzr: ERROR: foobarbaz is not versioned"],
469
['file-id', 'foobarbaz'])
472
class TestSelftestCleanOutput(TestCaseInTempDir):
474
def test_clean_output(self):
475
# check that 'bzr selftest --clean-output' works correct
476
dirs = ('test0000.tmp', 'test0001.tmp', 'bzrlib', 'tests')
477
files = ('bzr', 'setup.py', 'test9999.tmp')
482
f.write('content of ')
487
before = os.listdir(root)
489
self.assertEquals(['bzr','bzrlib','setup.py',
490
'test0000.tmp','test0001.tmp',
491
'test9999.tmp','tests'],
494
out, err = self.run_bzr(['selftest','--clean-output'],
497
self.assertEquals(['delete directory: test0000.tmp',
498
'delete directory: test0001.tmp'],
499
sorted(out.splitlines()))
500
self.assertEquals('', err)
502
after = os.listdir(root)
504
self.assertEquals(['bzr','bzrlib','setup.py',
505
'test9999.tmp','tests'],
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'])
509
475
class TestSelftestListOnly(TestCase):
541
507
def test_list_only(self):
542
508
# check that bzr selftest --list-only works correctly
543
out,err = self.run_bzr(['selftest', 'selftest',
509
out,err = self.run_bzr('selftest selftest --list-only')
545
510
self.assertEndsWith(err, 'tests passed\n')
546
511
(header,body,footer) = self._parse_test_list(out.splitlines())
547
512
num_tests = len(body)
550
515
def test_list_only_filtered(self):
551
516
# check that a filtered --list-only works, both include and exclude
552
out_all,err_all = self.run_bzr(['selftest', '--list-only'])
517
out_all,err_all = self.run_bzr('selftest --list-only')
553
518
tests_all = self._parse_test_list(out_all.splitlines())[1]
554
out_incl,err_incl = self.run_bzr(['selftest', '--list-only',
519
out_incl,err_incl = self.run_bzr('selftest --list-only selftest')
556
520
tests_incl = self._parse_test_list(out_incl.splitlines())[1]
557
521
self.assertSubset(tests_incl, tests_all)
558
522
out_excl,err_excl = self.run_bzr(['selftest', '--list-only',
559
'--exclude', 'selftest'])
523
'--exclude', 'selftest'])
560
524
tests_excl = self._parse_test_list(out_excl.splitlines())[1]
561
525
self.assertSubset(tests_excl, tests_all)
562
526
set_incl = set(tests_incl)
568
532
def test_list_only_random(self):
569
533
# check that --randomize works correctly
570
out_all,err_all = self.run_bzr(['selftest', '--list-only',
534
out_all,err_all = self.run_bzr('selftest --list-only selftest')
572
535
tests_all = self._parse_test_list(out_all.splitlines())[1]
573
536
# XXX: It looks like there are some orders for generating tests that
574
537
# fail as of 20070504 - maybe because of import order dependencies.
575
538
# So unfortunately this will rarely intermittently fail at the moment.
576
539
# -- mbp 20070504
577
540
out_rand,err_rand = self.run_bzr(['selftest', '--list-only',
578
'selftest', '--randomize', 'now'])
541
'selftest', '--randomize', 'now'])
579
542
(header_rand,tests_rand,dummy) = self._parse_test_list(
580
543
out_rand.splitlines(), 2)
581
544
self.assertNotEqual(tests_all, tests_rand)
585
548
match_obj = seed_re.search(header_rand[-1])
586
549
seed = match_obj.group(1)
587
550
out_rand2,err_rand2 = self.run_bzr(['selftest', '--list-only',
588
'selftest', '--randomize', seed])
551
'selftest', '--randomize', seed])
589
552
(header_rand2,tests_rand2,dummy) = self._parse_test_list(
590
553
out_rand2.splitlines(), 2)
591
554
self.assertEqual(tests_rand, tests_rand2)