tests/test-fix.t
branchstable
changeset 47036 ea563187ee7c
parent 46838 d083c12032c6
child 47142 bea4717415c0
equal deleted inserted replaced
47035:9e3979a25bfe 47036:ea563187ee7c
     5   $ cat > $UPPERCASEPY <<EOF
     5   $ cat > $UPPERCASEPY <<EOF
     6   > import sys
     6   > import sys
     7   > from mercurial.utils.procutil import setbinary
     7   > from mercurial.utils.procutil import setbinary
     8   > setbinary(sys.stdin)
     8   > setbinary(sys.stdin)
     9   > setbinary(sys.stdout)
     9   > setbinary(sys.stdout)
       
    10   > stdin = getattr(sys.stdin, 'buffer', sys.stdin)
       
    11   > stdout = getattr(sys.stdout, 'buffer', sys.stdout)
    10   > lines = set()
    12   > lines = set()
    11   > for arg in sys.argv[1:]:
    13   > for arg in sys.argv[1:]:
    12   >   if arg == 'all':
    14   >   if arg == 'all':
    13   >     sys.stdout.write(sys.stdin.read().upper())
    15   >     stdout.write(stdin.read().upper())
    14   >     sys.exit(0)
    16   >     sys.exit(0)
    15   >   else:
    17   >   else:
    16   >     first, last = arg.split('-')
    18   >     first, last = arg.split('-')
    17   >     lines.update(range(int(first), int(last) + 1))
    19   >     lines.update(range(int(first), int(last) + 1))
    18   > for i, line in enumerate(sys.stdin.readlines()):
    20   > for i, line in enumerate(stdin.readlines()):
    19   >   if i + 1 in lines:
    21   >   if i + 1 in lines:
    20   >     sys.stdout.write(line.upper())
    22   >     stdout.write(line.upper())
    21   >   else:
    23   >   else:
    22   >     sys.stdout.write(line)
    24   >     stdout.write(line)
    23   > EOF
    25   > EOF
    24   $ TESTLINES="foo\nbar\nbaz\nqux\n"
    26   $ TESTLINES="foo\nbar\nbaz\nqux\n"
    25   $ printf $TESTLINES | "$PYTHON" $UPPERCASEPY
    27   $ printf $TESTLINES | "$PYTHON" $UPPERCASEPY
    26   foo
    28   foo
    27   bar
    29   bar