~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_win32utils.py

(gz) Allow use of Python arguments preceding bzr script in Windows command
 lines (Jason Spashett)

Show diffs side-by-side

added added

removed removed

Lines of Context:
276
276
 
277
277
class Test_CommandLineToArgv(tests.TestCaseInTempDir):
278
278
 
279
 
    def assertCommandLine(self, expected, line, single_quotes_allowed=False):
 
279
    def assertCommandLine(self, expected, line, argv=None,
 
280
            single_quotes_allowed=False):
280
281
        # Strictly speaking we should respect parameter order versus glob
281
282
        # expansions, but it's not really worth the effort here
282
 
        argv = win32utils._command_line_to_argv(line,
 
283
        if argv is None:
 
284
            argv = [line]
 
285
        argv = win32utils._command_line_to_argv(line, argv,
283
286
                single_quotes_allowed=single_quotes_allowed)
284
287
        self.assertEqual(expected, sorted(argv))
285
288
 
313
316
 
314
317
    def test_single_quote_support(self):
315
318
        self.assertCommandLine(["add", "let's-do-it.txt"],
316
 
            "add let's-do-it.txt")
317
 
        self.assertCommandLine(["add", "lets do it.txt"],
318
 
            "add 'lets do it.txt'", single_quotes_allowed=True)
 
319
            "add let's-do-it.txt",
 
320
            ["add", "let's-do-it.txt"])
 
321
        self.expectFailure("Using single quotes breaks trimming from argv",
 
322
            self.assertCommandLine, ["add", "lets do it.txt"],
 
323
            "add 'lets do it.txt'", ["add", "'lets", "do", "it.txt'"],
 
324
            single_quotes_allowed=True)
319
325
 
320
326
    def test_case_insensitive_globs(self):
321
327
        self.requireFeature(tests.CaseInsCasePresFilenameFeature)
326
332
        self.requireFeature(backslashdir_feature)
327
333
        self.build_tree(['a/', 'a/b.c', 'a/c.c', 'a/c.h'])
328
334
        self.assertCommandLine([u'a/b.c'], 'a\\b*')
 
335
 
 
336
    def test_with_pdb(self):
 
337
        """Check stripping Python arguments before bzr script per lp:587868"""
 
338
        self.assertCommandLine([u"rocks"], "-m pdb rocks", ["rocks"])
 
339
        self.build_tree(['d/', 'd/f1', 'd/f2'])
 
340
        self.assertCommandLine([u"rm", u"x*"], "-m pdb rm x*", ["rm", u"x*"])
 
341
        self.assertCommandLine([u"add", u"d/f1", u"d/f2"], "-m pdb add d/*",
 
342
            ["add", u"d/*"])