From 0d0f719f13cd61105f036c3172750c7173cf3713 Mon Sep 17 00:00:00 2001 From: Patrick Mezard Date: Sun, 12 Oct 2008 19:11:59 +0200 Subject: [PATCH] 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 --- contrib/simplemerge | 3 +++ tests/md5sum.py | 9 ++++++++- tests/printenv.py | 8 ++++++++ tests/test-archive | 7 +++++++ tests/test-encode | 2 +- tests/test-hup | 2 ++ tests/test-merge-symlinks | 9 ++++++++- tests/test-merge1 | 8 ++++++++ 8 files changed, 45 insertions(+), 3 deletions(-) diff --git a/contrib/simplemerge b/contrib/simplemerge index 05b9865ef2..0d49d2c0b6 100755 --- a/contrib/simplemerge +++ b/contrib/simplemerge @@ -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) diff --git a/tests/md5sum.py b/tests/md5sum.py index ec81d2587d..aa3fb620a1 100755 --- a/tests/md5sum.py +++ b/tests/md5sum.py @@ -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') diff --git a/tests/printenv.py b/tests/printenv.py index da825f1f0a..453a1593f0 100644 --- a/tests/printenv.py +++ b/tests/printenv.py @@ -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 diff --git a/tests/test-archive b/tests/test-archive index d63d82a936..6363e0c7e1 100755 --- a/tests/test-archive +++ b/tests/test-archive @@ -46,6 +46,13 @@ TIP=`hg id -v | cut -f1 -d' '` QTIP=`hg id -q` cat > getarchive.py < .hg/hgrc < echo.py < 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