# HG changeset patch # User Gregory Szorc # Date 1427578102 25200 # Node ID 8d6fd0b8f622b92bd9e6e5926e2a2d7caf42f07c # Parent 27092bb7029386717ca7670822a03530244a1161 run-tests: separate newline normalization from replacements Upcoming patches will change how the replacements system works to make it more flexible. To prepare for this, eliminate the one-off use of replacements to perform newline normalization on Windows. diff -r 27092bb70293 -r 8d6fd0b8f622 tests/run-tests.py --- a/tests/run-tests.py Sat Mar 28 14:12:57 2015 -0700 +++ b/tests/run-tests.py Sat Mar 28 14:28:22 2015 -0700 @@ -722,7 +722,7 @@ # Failed is denoted by AssertionError (by default at least). raise AssertionError(msg) - def _runcommand(self, cmd, replacements, env): + def _runcommand(self, cmd, replacements, env, normalizenewlines=False): """Run command in a sub-process, capturing the output (stdout and stderr). @@ -765,6 +765,10 @@ for s, r in replacements: output = re.sub(s, r, output) + + if normalizenewlines: + output = output.replace('\r\n', '\n') + return ret, output.splitlines(True) class PythonTest(Test): @@ -778,9 +782,9 @@ py3kswitch = self._py3kwarnings and ' -3' or '' cmd = '%s%s "%s"' % (PYTHON, py3kswitch, self.path) vlog("# Running", cmd) - if os.name == 'nt': - replacements.append((r'\r\n', '\n')) - result = self._runcommand(cmd, replacements, env) + normalizenewlines = os.name == 'nt' + result = self._runcommand(cmd, replacements, env, + normalizenewlines=normalizenewlines) if self._aborted: raise KeyboardInterrupt()