sys.stdout.write(auto + '\n')
answer = sys.stdin.readline().strip().lower()
-def run(paths, quiet=False, verbose=False, interactive=False,
- basetmp=None, keeptmp=False, answer=None):
+ p = subprocess.Popen([cmd, '-p0'], bufsize=-1, stdin=subprocess.PIPE,
+ universal_newlines=True, close_fds=os.name == 'posix')
+ return p.returncode == 0
+def run(paths, quiet=False, verbose=False, basetmp=None, keeptmp=False,
+ patchcmd=None, answer=None):
- If quiet is True, diffs aren't printed.
- If verbose is True, filenames and status information are printed.
+ If quiet is True, diffs aren't printed. If verbose is True,
+ filenames and status information are printed.
If basetmp is set, each test is run in a random temporary
- directory inside basetmp.
+ directory inside basetmp. If keeptmp is also True, temporary
+ directories are preserved after use.
- If basetmp is set and keeptmp is True, temporary directories are
- If interactive is True, a prompt is written to stdout asking if
+ If patchcmd is set, a prompt is written to stdout asking if
changed output should be merged back into the original test. The
- answer is read from stdin.
+ answer is read from stdin. If 'y', the test is patched using patch
+ based on the changed output.
- if prompt('Accept this change?', 'yN', answer) == 'y':
- shutil.copy(errpath, abspath)
+ prompt('Accept this change?', 'yN', answer) == 'y'):
+ if patch(patchcmd, diff):
+ log(None, '%s: merged output\n' % path, verbose)
- log(None, '%s: merged output\n' % path, verbose)
+ log('%s: merge failed\n' % path)
log('# Ran %s tests, %s skipped, %s failed.\n'
% (len(seen), skipped, failed))
+ """Return the patch to cmd or None if not found"""
+ for p in os.environ['PATH'].split(os.pathsep):
+ path = os.path.join(p, cmd)
+ if os.path.exists(path) and os.access(path, os.X_OK):
+ patchcmd = which('patch')
+ sys.stderr.write('patch(1) required for -i\n')
- run(paths, opts.quiet, opts.verbose, opts.interactive, basetmp,
- opts.keep_tmpdir, answer)
+ run(paths, opts.quiet, opts.verbose, basetmp, opts.keep_tmpdir,