/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/script.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-12-18 10:09:49 UTC
  • mfrom: (4871.5.4 admin-guide-submit)
  • Revision ID: pqm@pqm.ubuntu.com-20091218100949-2c1ityvnbqjtdf3g
(nmb) Add backup section to admin-guide

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2009 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
24
24
import glob
25
25
import os
26
26
import shlex
27
 
import textwrap
28
27
from cStringIO import StringIO
29
28
 
30
29
from bzrlib import (
74
73
    cmd_line = 1
75
74
    lineno = 0
76
75
    input, output, error = None, None, None
77
 
    text = textwrap.dedent(text)
78
76
    for line in text.split('\n'):
79
77
        lineno += 1
80
78
        # Keep a copy for error reporting
404
402
            retcode = 0
405
403
        return retcode, None, err
406
404
 
407
 
    def do_mv(self, test_case, input, args):
408
 
        err = None
409
 
        def error(msg, src, dst):
410
 
            return "mv: cannot move %s to %s: %s\n" % (src, dst, msg)
411
 
 
412
 
        if not args or len(args) != 2:
413
 
            raise SyntaxError("Usage: mv path1 path2")
414
 
        src, dst = args
415
 
        try:
416
 
            real_dst = dst
417
 
            if os.path.isdir(dst):
418
 
                real_dst = os.path.join(dst, os.path.basename(src))
419
 
            os.rename(src, real_dst)
420
 
        except OSError, e:
421
 
            if e.errno == errno.ENOENT:
422
 
                err = error('No such file or directory', src, dst)
423
 
            else:
424
 
                raise
425
 
        if err:
426
 
            retcode = 1
427
 
        else:
428
 
            retcode = 0
429
 
        return retcode, None, err
430
 
 
431
 
 
432
405
 
433
406
class TestCaseWithMemoryTransportAndScript(tests.TestCaseWithMemoryTransport):
434
407
    """Helper class to experiment shell-like test and memory fs.
477
450
    def run_command(self, cmd, input, output, error):
478
451
        return self.script_runner.run_command(self, cmd, input, output, error)
479
452
 
480
 
 
481
 
def run_script(test_case, script_string):
482
 
    """Run the given script within a testcase"""
483
 
    return ScriptRunner().run_script(test_case, script_string)