From 55187c7f59789f4803280134314b5c6aadfd9dfd Mon Sep 17 00:00:00 2001 From: Snaipe Date: Sat, 16 Jan 2016 21:18:40 +0100 Subject: [PATCH] Patched buggy cram on OS X --- .cmake/cram-osx.patch | 41 +++++++++++++++++++++++++++++++++++++++++ .travis.yml | 7 ++++++- 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 .cmake/cram-osx.patch diff --git a/.cmake/cram-osx.patch b/.cmake/cram-osx.patch new file mode 100644 index 0000000..fb77c16 --- /dev/null +++ b/.cmake/cram-osx.patch @@ -0,0 +1,41 @@ +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, ++ universal_newlines=False, env=env, + preexec_fn=makeresetsigpipe(), + close_fds=os.name == 'posix') + salt = 'CRAM%s' % time.time() +@@ -199,7 +199,9 @@ 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] ++ print(f.encoding) ++ print(sys.stdout.encoding) ++ output = p.communicate(input=''.join(stdin).encode('utf-8'))[0].decode('utf-8') + if p.returncode == 80: + return (refout, None, []) + +@@ -336,7 +338,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) diff --git a/.travis.yml b/.travis.yml index 4f2e205..d93039a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -108,7 +108,12 @@ before_install: curl -L https://bootstrap.pypa.io/get-pip.py | python3.5 - --user fi - pip3 install --user cram + pip3 install --user cram==0.6 + + # Patch buggy cram on OSX + if [ "$TRAVIS_OS_NAME" = "osx" ]; then + patch "$(python3 -m site --user-base)/lib/python/site-packages/cram.py" .cmake/cram-osx.patch + fi cram --version fi