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
--- a/contrib/simplemerge Sun Oct 12 19:11:56 2008 +0200
+++ b/contrib/simplemerge Sun Oct 12 19:11:59 2008 +0200
@@ -42,6 +42,9 @@
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)
--- a/tests/md5sum.py Sun Oct 12 19:11:56 2008 +0200
+++ b/tests/md5sum.py Sun Oct 12 19:11:59 2008 +0200
@@ -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')
--- a/tests/printenv.py Sun Oct 12 19:11:56 2008 +0200
+++ b/tests/printenv.py Sun Oct 12 19:11:59 2008 +0200
@@ -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
--- a/tests/test-archive Sun Oct 12 19:11:56 2008 +0200
+++ b/tests/test-archive Sun Oct 12 19:11:59 2008 +0200
@@ -46,6 +46,13 @@
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))
--- a/tests/test-encode Sun Oct 12 19:11:56 2008 +0200
+++ b/tests/test-encode Sun Oct 12 19:11:59 2008 +0200
@@ -4,7 +4,7 @@
cat > .hg/hgrc <<EOF
[encode]
-*.gz = gunzip
+*.gz = gzip -d
[decode]
*.gz = gzip
--- a/tests/test-hup Sun Oct 12 19:11:56 2008 +0200
+++ b/tests/test-hup Sun Oct 12 19:11:59 2008 +0200
@@ -1,5 +1,7 @@
#!/bin/sh
+"$TESTDIR/hghave" fifo || exit 80
+
hg init
mkfifo p
--- a/tests/test-merge-symlinks Sun Oct 12 19:11:56 2008 +0200
+++ b/tests/test-merge-symlinks Sun Oct 12 19:11:59 2008 +0200
@@ -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
--- a/tests/test-merge1 Sun Oct 12 19:11:56 2008 +0200
+++ b/tests/test-merge1 Sun Oct 12 19:11:59 2008 +0200
@@ -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