Allow ini plugin to load file using other encoding than utf8.

- New option for ini plugins: encoding
  - Add a new option encoding to _get_file_contents
  - Use replace option in test/runner/lib/util.py when calling decode on stdout/err
    output when diff have non-utf8 sequences
This commit is contained in:
Yannig Perré 2017-07-21 09:11:22 +02:00 committed by Toshio Kuratomi
parent 806da6e7c7
commit 6a57ad34c0
9 changed files with 78 additions and 35 deletions

View file

@ -24,7 +24,7 @@ class Git(object):
:rtype: list[str]
"""
cmd = ['diff'] + args
return self.run_git_split(cmd, '\n')
return self.run_git_split(cmd, '\n', str_errors='replace')
def get_diff_names(self, args):
"""
@ -76,22 +76,24 @@ class Git(object):
except SubprocessError:
return False
def run_git_split(self, cmd, separator=None):
def run_git_split(self, cmd, separator=None, str_errors='strict'):
"""
:type cmd: list[str]
:param separator: str | None
:type str_errors: 'strict' | 'replace'
:rtype: list[str]
"""
output = self.run_git(cmd).strip(separator)
output = self.run_git(cmd, str_errors=str_errors).strip(separator)
if not output:
return []
return output.split(separator)
def run_git(self, cmd):
def run_git(self, cmd, str_errors='strict'):
"""
:type cmd: list[str]
:type str_errors: 'strict' | 'replace'
:rtype: str
"""
return run_command(self.args, [self.git] + cmd, capture=True, always=True)[0]
return run_command(self.args, [self.git] + cmd, capture=True, always=True, str_errors=str_errors)[0]