~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/blackbox.py

  • Committer: Robert Collins
  • Date: 2005-11-13 18:57:26 UTC
  • mfrom: (1185.31.9)
  • Revision ID: robertc@robertcollins.net-20051113185726-39ede10d746eee6d
Merge Johns current integration work.

Show diffs side-by-side

added added

removed removed

Lines of Context:
576
576
                  'subdir/b\n'
577
577
                  , '--versioned')
578
578
 
 
579
    def test_pull_verbose(self):
 
580
        """Pull changes from one branch to another and watch the output."""
 
581
 
 
582
        os.mkdir('a')
 
583
        os.chdir('a')
 
584
 
 
585
        bzr = self.runbzr
 
586
        self.example_branch()
 
587
 
 
588
        os.chdir('..')
 
589
        bzr('branch a b')
 
590
        os.chdir('b')
 
591
        open('b', 'wb').write('else\n')
 
592
        bzr('add b')
 
593
        bzr(['commit', '-m', 'added b'])
 
594
 
 
595
        os.chdir('../a')
 
596
        out = bzr('pull --verbose ../b', backtick=True)
 
597
        self.failIfEqual(out.find('Added Revisions:'), -1)
 
598
        self.failIfEqual(out.find('message:\n  added b'), -1)
 
599
        self.failIfEqual(out.find('added:\n  b'), -1)
 
600
 
 
601
        # Check that --overwrite --verbose prints out the removed entries
 
602
        bzr('commit -m foo --unchanged')
 
603
        os.chdir('../b')
 
604
        bzr('commit -m baz --unchanged')
 
605
        bzr('pull ../a', retcode=1)
 
606
        out = bzr('pull --overwrite --verbose ../a', backtick=1)
 
607
 
 
608
        remove_loc = out.find('Removed Revisions:')
 
609
        self.failIfEqual(remove_loc, -1)
 
610
        added_loc = out.find('Added Revisions:')
 
611
        self.failIfEqual(added_loc, -1)
 
612
 
 
613
        removed_message = out.find('message:\n  baz')
 
614
        self.failIfEqual(removed_message, -1)
 
615
        self.failUnless(remove_loc < removed_message < added_loc)
 
616
 
 
617
        added_message = out.find('message:\n  foo')
 
618
        self.failIfEqual(added_message, -1)
 
619
        self.failUnless(added_loc < added_message)
 
620
        
579
621
    def test_locations(self):
580
622
        """Using and remembering different locations"""
581
623
        os.mkdir('a')
758
800
        # nothing missing
759
801
        self.runbzr('missing ../missing/new-branch')
760
802
 
 
803
    def test_external_command(self):
 
804
        """test that external commands can be run by setting the path"""
 
805
        cmd_name = 'test-command'
 
806
        output = 'Hello from test-command'
 
807
        if sys.platform == 'win32':
 
808
            cmd_name += '.bat'
 
809
            output += '\r\n'
 
810
        else:
 
811
            output += '\n'
 
812
 
 
813
        oldpath = os.environ.get('BZRPATH', None)
 
814
 
 
815
        bzr = self.capture
 
816
 
 
817
        try:
 
818
            if os.environ.has_key('BZRPATH'):
 
819
                del os.environ['BZRPATH']
 
820
 
 
821
            f = file(cmd_name, 'wb')
 
822
            if sys.platform == 'win32':
 
823
                f.write('@echo off\n')
 
824
            else:
 
825
                f.write('#!/bin/sh\n')
 
826
            f.write('echo Hello from test-command')
 
827
            f.close()
 
828
            os.chmod(cmd_name, 0755)
 
829
 
 
830
            # It should not find the command in the local 
 
831
            # directory by default, since it is not in my path
 
832
            bzr(cmd_name, retcode=1)
 
833
 
 
834
            # Now put it into my path
 
835
            os.environ['BZRPATH'] = '.'
 
836
 
 
837
            bzr(cmd_name)
 
838
            # The test suite does not capture stdout for external commands
 
839
            # this is because you have to have a real file object
 
840
            # to pass to Popen(stdout=FOO), and StringIO is not one of those.
 
841
            # (just replacing sys.stdout does not change a spawned objects stdout)
 
842
            #self.assertEquals(bzr(cmd_name), output)
 
843
 
 
844
            # Make sure empty path elements are ignored
 
845
            os.environ['BZRPATH'] = os.pathsep
 
846
 
 
847
            bzr(cmd_name, retcode=1)
 
848
 
 
849
        finally:
 
850
            if oldpath:
 
851
                os.environ['BZRPATH'] = oldpath
 
852
 
761
853
 
762
854
def listdir_sorted(dir):
763
855
    L = os.listdir(dir)