~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_mergetools.py

  • Committer: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

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
 
        self.assertTrue(mergetools.check_availability(
85
 
            os.path.basename(sys.executable)))
 
82
        self.assertTrue(mergetools.check_availability('python'))
86
83
 
87
84
    def test_nonexistent(self):
88
85
        self.assertFalse(mergetools.check_availability('DOES NOT EXIST'))
108
105
            ('test.txt.THIS', 'this stuff'),
109
106
            ('test.txt.OTHER', 'other stuff'),
110
107
        ))
111
 
        
 
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
 
112
122
    def test_success(self):
113
123
        def dummy_invoker(exe, args, cleanup):
114
124
            self._exe = exe
119
129
        self.assertEqual(0, retcode)
120
130
        self.assertEqual('tool', self._exe)
121
131
        self.assertEqual(['test.txt'], self._args)
122
 
    
 
132
 
123
133
    def test_failure(self):
124
134
        def dummy_invoker(exe, args, cleanup):
125
135
            self._exe = exe
147
157
        self.assertEqual('tool', self._exe)
148
158
        self.assertPathDoesNotExist(self._args[0])
149
159
        self.assertFileEqual('temp stuff', 'test.txt')
150
 
    
 
160
 
151
161
    def test_failure_tempfile(self):
152
162
        def dummy_invoker(exe, args, cleanup):
153
163
            self._exe = exe