tests: Windows compatibility fixes

- printenv.py, md5sum.py, simplemerge, test-archive, test-merge1,
  test-merge-symlinks: set standard streams to binary mode
- test-encode: replace "gunzip" by "gzip -d"
- test-hup: requires fifo
This commit is contained in:
Patrick Mezard 2008-10-12 19:11:59 +02:00
parent e82fd2d627
commit 0d0f719f13
8 changed files with 45 additions and 3 deletions

View File

@ -42,6 +42,9 @@ def showhelp():
sys.stdout.write(' %-*s %s\n' % (opts_len, first, second))
try:
for fp in (sys.stdin, sys.stdout, sys.stderr):
util.set_binary(fp)
opts = {}
try:
args = fancyopts.fancyopts(sys.argv[1:], options, opts)

View File

@ -6,13 +6,20 @@
# of the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2, which is
# GPL-compatible.
import sys
import sys, os
try:
from hashlib import md5
except ImportError:
from md5 import md5
try:
import msvcrt
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)
except ImportError:
pass
for filename in sys.argv[1:]:
try:
fp = open(filename, 'rb')

View File

@ -16,6 +16,14 @@
import os
import sys
try:
import msvcrt
msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)
except ImportError:
pass
exitcode = 0
out = sys.stdout

View File

@ -46,6 +46,13 @@ TIP=`hg id -v | cut -f1 -d' '`
QTIP=`hg id -q`
cat > getarchive.py <<EOF
import os, sys, urllib2
try:
# Set stdout to binary mode for win32 platforms
import msvcrt
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
except ImportError:
pass
node, archive = sys.argv[1:]
f = urllib2.urlopen('http://127.0.0.1:%s/?cmd=archive;node=%s;type=%s'
% (os.environ['HGPORT'], node, archive))

View File

@ -4,7 +4,7 @@ hg init
cat > .hg/hgrc <<EOF
[encode]
*.gz = gunzip
*.gz = gzip -d
[decode]
*.gz = gzip

View File

@ -1,5 +1,7 @@
#!/bin/sh
"$TESTDIR/hghave" fifo || exit 80
hg init
mkfifo p

View File

@ -2,7 +2,14 @@
cat > echo.py <<EOF
#!/usr/bin/env python
import os
import os, sys
try:
import msvcrt
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)
except ImportError:
pass
for k in ('HG_FILE', 'HG_MY_ISLINK', 'HG_OTHER_ISLINK', 'HG_BASE_ISLINK'):
print k, os.environ[k]
EOF

View File

@ -2,6 +2,14 @@
cat <<EOF > merge
import sys, os
try:
import msvcrt
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)
except ImportError:
pass
print "merging for", os.path.basename(sys.argv[1])
EOF
HGMERGE="python ../merge"; export HGMERGE