~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_mergetools.py

  • Committer: Vincent Ladeuil
  • Date: 2017-01-30 14:30:10 UTC
  • mfrom: (6615.3.7 merges)
  • mto: This revision was merged to the branch mainline in revision 6621.
  • Revision ID: v.ladeuil+lp@free.fr-20170130143010-p31t1ranfeqbaeki
Merge  2.7 into trunk including fix for bug #1657238

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
19
18
import sys
20
19
import tempfile
21
20
 
23
22
    mergetools,
24
23
    tests
25
24
)
26
 
from bzrlib.tests.features import backslashdir_feature
27
25
 
28
26
 
29
27
class TestFilenameSubstitution(tests.TestCaseInTempDir):
39
37
             '-o',
40
38
             'test.txt'],
41
39
            args)
42
 
        
 
40
 
43
41
    def test_spaces(self):
44
42
        cmd_list = ['kdiff3', '{base}', '{this}', '{other}', '-o', '{result}']
45
43
        args, tmpfile = mergetools._subst_filename(cmd_list,
81
79
        self.assertTrue(mergetools.check_availability(sys.executable))
82
80
 
83
81
    def test_exe_on_path(self):
84
 
        if sys.platform == 'win32':
85
 
            exe = 'cmd.exe'
86
 
        else:
87
 
            exe = 'sh'
88
 
        self.assertTrue(mergetools.check_availability(exe))
 
82
        self.assertTrue(mergetools.check_availability('python'))
89
83
 
90
84
    def test_nonexistent(self):
91
85
        self.assertFalse(mergetools.check_availability('DOES NOT EXIST'))
111
105
            ('test.txt.THIS', 'this stuff'),
112
106
            ('test.txt.OTHER', 'other stuff'),
113
107
        ))
114
 
        
 
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
 
115
122
    def test_success(self):
116
123
        def dummy_invoker(exe, args, cleanup):
117
124
            self._exe = exe
122
129
        self.assertEqual(0, retcode)
123
130
        self.assertEqual('tool', self._exe)
124
131
        self.assertEqual(['test.txt'], self._args)
125
 
    
 
132
 
126
133
    def test_failure(self):
127
134
        def dummy_invoker(exe, args, cleanup):
128
135
            self._exe = exe
150
157
        self.assertEqual('tool', self._exe)
151
158
        self.assertPathDoesNotExist(self._args[0])
152
159
        self.assertFileEqual('temp stuff', 'test.txt')
153
 
    
 
160
 
154
161
    def test_failure_tempfile(self):
155
162
        def dummy_invoker(exe, args, cleanup):
156
163
            self._exe = exe