~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_mergetools.py

  • Committer: Martin Packman
  • Date: 2012-02-01 13:24:42 UTC
  • mto: (6437.23.4 2.5)
  • mto: This revision was merged to the branch mainline in revision 6462.
  • Revision ID: martin.packman@canonical.com-20120201132442-ela7jc4mxv4b058o
Treat path for .bzr.log as unicode

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
import os
 
18
import re
18
19
import sys
19
20
import tempfile
20
21
 
22
23
    mergetools,
23
24
    tests
24
25
)
 
26
from bzrlib.tests.features import backslashdir_feature
25
27
 
26
28
 
27
29
class TestFilenameSubstitution(tests.TestCaseInTempDir):
37
39
             '-o',
38
40
             'test.txt'],
39
41
            args)
40
 
 
 
42
        
41
43
    def test_spaces(self):
42
44
        cmd_list = ['kdiff3', '{base}', '{this}', '{other}', '-o', '{result}']
43
45
        args, tmpfile = mergetools._subst_filename(cmd_list,
79
81
        self.assertTrue(mergetools.check_availability(sys.executable))
80
82
 
81
83
    def test_exe_on_path(self):
82
 
        self.assertTrue(mergetools.check_availability('python'))
 
84
        if sys.platform == 'win32':
 
85
            exe = 'cmd.exe'
 
86
        else:
 
87
            exe = 'sh'
 
88
        self.assertTrue(mergetools.check_availability(exe))
83
89
 
84
90
    def test_nonexistent(self):
85
91
        self.assertFalse(mergetools.check_availability('DOES NOT EXIST'))
105
111
            ('test.txt.THIS', 'this stuff'),
106
112
            ('test.txt.OTHER', 'other stuff'),
107
113
        ))
108
 
 
109
 
    def test_invoke_expands_exe_path(self):
110
 
        self.overrideEnv('PATH', os.path.dirname(sys.executable))
111
 
        def dummy_invoker(exe, args, cleanup):
112
 
            self._exe = exe
113
 
            self._args = args
114
 
            cleanup(0)
115
 
            return 0
116
 
        command = '%s {result}' % os.path.basename(sys.executable)
117
 
        retcode = mergetools.invoke(command, 'test.txt', dummy_invoker)
118
 
        self.assertEqual(0, retcode)
119
 
        self.assertEqual(sys.executable, self._exe)
120
 
        self.assertEqual(['test.txt'], self._args)
121
 
 
 
114
        
122
115
    def test_success(self):
123
116
        def dummy_invoker(exe, args, cleanup):
124
117
            self._exe = exe
129
122
        self.assertEqual(0, retcode)
130
123
        self.assertEqual('tool', self._exe)
131
124
        self.assertEqual(['test.txt'], self._args)
132
 
 
 
125
    
133
126
    def test_failure(self):
134
127
        def dummy_invoker(exe, args, cleanup):
135
128
            self._exe = exe
157
150
        self.assertEqual('tool', self._exe)
158
151
        self.assertPathDoesNotExist(self._args[0])
159
152
        self.assertFileEqual('temp stuff', 'test.txt')
160
 
 
 
153
    
161
154
    def test_failure_tempfile(self):
162
155
        def dummy_invoker(exe, args, cleanup):
163
156
            self._exe = exe