~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-05-18 08:53:27 UTC
  • mfrom: (1713.1.4 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20060518085327-89822346d9321aba
Merge benchmark selftests(Robert Collins, Martin Pool), bzr add chattiness(Robert Collins), and bzr push revision count reporting improvements(Robert Collins).

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
from bzrlib.branch import Branch
44
44
import bzrlib.bzrdir as bzrdir
45
45
from bzrlib.errors import BzrCommandError
46
 
from bzrlib.osutils import has_symlinks, pathjoin, rmtree
 
46
from bzrlib.osutils import (
 
47
    has_symlinks,
 
48
    pathjoin,
 
49
    rmtree,
 
50
    terminal_width,
 
51
    )
47
52
from bzrlib.tests.HTTPTestUtil import TestCaseWithWebserver
48
53
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
49
54
from bzrlib.tests.blackbox import ExternalBase
499
504
        self.runbzr('pull ../a --remember')
500
505
        self.runbzr('pull')
501
506
        
502
 
    def test_add_reports(self):
503
 
        """add command prints the names of added files."""
504
 
        self.runbzr('init')
505
 
        self.build_tree(['top.txt', 'dir/', 'dir/sub.txt', 'CVS'])
506
 
        out = self.run_bzr_captured(['add'], retcode=0)[0]
507
 
        # the ordering is not defined at the moment
508
 
        results = sorted(out.rstrip('\n').split('\n'))
509
 
        self.assertEquals(['If you wish to add some of these files, please'\
510
 
                           ' add them by name.',
511
 
                           'added dir',
512
 
                           'added dir/sub.txt',
513
 
                           'added top.txt',
514
 
                           'ignored 1 file(s) matching "CVS"'],
515
 
                          results)
516
 
        out = self.run_bzr_captured(['add', '-v'], retcode=0)[0]
517
 
        results = sorted(out.rstrip('\n').split('\n'))
518
 
        self.assertEquals(['If you wish to add some of these files, please'\
519
 
                           ' add them by name.',
520
 
                           'ignored CVS matching "CVS"'],
521
 
                          results)
522
 
 
523
 
    def test_add_quiet_is(self):
524
 
        """add -q does not print the names of added files."""
525
 
        self.runbzr('init')
526
 
        self.build_tree(['top.txt', 'dir/', 'dir/sub.txt'])
527
 
        out = self.run_bzr_captured(['add', '-q'], retcode=0)[0]
528
 
        # the ordering is not defined at the moment
529
 
        results = sorted(out.rstrip('\n').split('\n'))
530
 
        self.assertEquals([''], results)
531
 
 
532
 
    def test_add_in_unversioned(self):
533
 
        """Try to add a file in an unversioned directory.
534
 
 
535
 
        "bzr add" should add the parent(s) as necessary.
536
 
        """
537
 
        self.runbzr('init')
538
 
        self.build_tree(['inertiatic/', 'inertiatic/esp'])
539
 
        self.assertEquals(self.capture('unknowns'), 'inertiatic\n')
540
 
        self.run_bzr('add', 'inertiatic/esp')
541
 
        self.assertEquals(self.capture('unknowns'), '')
542
 
 
543
 
        # Multiple unversioned parents
544
 
        self.build_tree(['veil/', 'veil/cerpin/', 'veil/cerpin/taxt'])
545
 
        self.assertEquals(self.capture('unknowns'), 'veil\n')
546
 
        self.run_bzr('add', 'veil/cerpin/taxt')
547
 
        self.assertEquals(self.capture('unknowns'), '')
548
 
 
549
 
        # Check whacky paths work
550
 
        self.build_tree(['cicatriz/', 'cicatriz/esp'])
551
 
        self.assertEquals(self.capture('unknowns'), 'cicatriz\n')
552
 
        self.run_bzr('add', 'inertiatic/../cicatriz/esp')
553
 
        self.assertEquals(self.capture('unknowns'), '')
554
 
 
555
 
    def test_add_in_versioned(self):
556
 
        """Try to add a file in a versioned directory.
557
 
 
558
 
        "bzr add" should do this happily.
559
 
        """
560
 
        self.runbzr('init')
561
 
        self.build_tree(['inertiatic/', 'inertiatic/esp'])
562
 
        self.assertEquals(self.capture('unknowns'), 'inertiatic\n')
563
 
        self.run_bzr('add', '--no-recurse', 'inertiatic')
564
 
        self.assertEquals(self.capture('unknowns'), 'inertiatic/esp\n')
565
 
        self.run_bzr('add', 'inertiatic/esp')
566
 
        self.assertEquals(self.capture('unknowns'), '')
567
 
 
568
 
    def test_subdir_add(self):
569
 
        """Add in subdirectory should add only things from there down"""
570
 
        from bzrlib.workingtree import WorkingTree
571
 
        
572
 
        eq = self.assertEqual
573
 
        ass = self.assert_
574
 
        chdir = os.chdir
575
 
        
576
 
        t = self.make_branch_and_tree('.')
577
 
        b = t.branch
578
 
        self.build_tree(['src/', 'README'])
579
 
        
580
 
        eq(sorted(t.unknowns()),
581
 
           ['README', 'src'])
582
 
        
583
 
        self.run_bzr('add', 'src')
584
 
        
585
 
        self.build_tree(['src/foo.c'])
586
 
        
587
 
        chdir('src')
588
 
        self.run_bzr('add')
589
 
        
590
 
        self.assertEquals(self.capture('unknowns'), 'README\n')
591
 
        eq(len(t.read_working_inventory()), 3)
592
 
                
593
 
        chdir('..')
594
 
        self.run_bzr('add')
595
 
        self.assertEquals(self.capture('unknowns'), '')
596
 
        self.run_bzr('check')
597
 
 
598
507
    def test_unknown_command(self):
599
508
        """Handling of unknown command."""
600
509
        out, err = self.run_bzr_captured(['fluffy-badger'],
952
861
        self.assert_('revision-id' in capture('log --show-ids -m commit'))
953
862
 
954
863
        log_out = capture('log --line')
 
864
        # determine the widest line we want
 
865
        max_width = terminal_width() - 1
955
866
        for line in log_out.splitlines():
956
 
            self.assert_(len(line) <= 79, len(line))
 
867
            self.assert_(len(line) <= max_width, len(line))
957
868
        self.assert_("this is my new commit and" in log_out)
958
869
 
959
 
 
960
870
        progress("file with spaces in name")
961
871
        mkdir('sub directory')
962
872
        file('sub directory/file with spaces ', 'wt').write('see how this works\n')