[appveyor] Fixed unicode issues on cram tests on windows
This commit is contained in:
parent
6dc256075f
commit
eef231a2ee
2 changed files with 41 additions and 0 deletions
38
.cmake/cram-win.patch
Normal file
38
.cmake/cram-win.patch
Normal file
|
@ -0,0 +1,38 @@
|
|||
diff --git a/cram.py b/cram.py
|
||||
index 20c4681..3b9f144 100755
|
||||
--- a/cram.py
|
||||
+++ b/cram.py
|
||||
@@ -168,14 +168,14 @@ def test(path, shell, indent=2):
|
||||
cmdline = '%s$ ' % indent
|
||||
conline = '%s> ' % indent
|
||||
|
||||
- f = open(path)
|
||||
+ f = open(path, 'r', encoding='utf-8')
|
||||
abspath = os.path.abspath(path)
|
||||
env = os.environ.copy()
|
||||
env['TESTDIR'] = os.path.dirname(abspath)
|
||||
env['TESTFILE'] = os.path.basename(abspath)
|
||||
p = subprocess.Popen([shell, '-'], bufsize=-1, stdin=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
|
||||
universal_newlines=True, env=env,
|
||||
preexec_fn=makeresetsigpipe(),
|
||||
close_fds=os.name == 'posix')
|
||||
salt = 'CRAM%s' % time.time()
|
||||
@@ -199,7 +199,7 @@ def test(path, shell, indent=2):
|
||||
after.setdefault(pos, []).append(line)
|
||||
stdin.append('echo "\n%s %s $?"\n' % (salt, i + 1))
|
||||
|
||||
- output = p.communicate(input=''.join(stdin))[0]
|
||||
+ output = p.communicate(input=''.join(stdin).encode('utf-8'))[0].decode('utf-8')
|
||||
if p.returncode == 80:
|
||||
return (refout, None, [])
|
||||
|
||||
@@ -336,7 +336,7 @@ def run(paths, tmpdir, shell, quiet=False, verbose=False, patchcmd=None,
|
||||
log('!', 'failed\n', verbose)
|
||||
if not quiet:
|
||||
log('\n', None, verbose)
|
||||
- errfile = open(errpath, 'w')
|
||||
+ errfile = open(errpath, 'w', encoding='utf-8')
|
||||
try:
|
||||
for line in postout:
|
||||
errfile.write(line)
|
|
@ -15,6 +15,7 @@ environment:
|
|||
PYTHON: "C:\\Python34"
|
||||
PYTHON_VERSION: "3.4.x"
|
||||
PYTHON_ARCH: "32"
|
||||
PYTHONIOENCODING: "utf-8" # consider cmd encoding to be unicode
|
||||
matrix:
|
||||
- COMPILER: mingw
|
||||
GENERATOR: "MSYS Makefiles"
|
||||
|
@ -44,6 +45,8 @@ install:
|
|||
# Install cram
|
||||
- "pip install cram"
|
||||
- python -m cram --version
|
||||
# Patch buggy cram
|
||||
- sh -c "patch C:/Python34/Lib/site-packages/cram.py .cmake/cram-win.patch"
|
||||
|
||||
- ps: $env:RELEASE_NAME = $env:APPVEYOR_REPO_BRANCH -replace "/", "-"
|
||||
# Hack to make git think it is on the tip of the repo branch
|
||||
|
|
Loading…
Add table
Reference in a new issue