From 30762ceda9db949550de6785b36dbe0d89c6d9d2 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Thu, 9 Apr 2015 13:37:02 -0700 Subject: Merge to XFA: testing utility combo patch This pulls in the following CLs from master: Review URL: https://codereview.chromium.org/1072613003 Review URL: https://codereview.chromium.org/1058463004 Review URL: https://codereview.chromium.org/1057983003 Review URL: https://codereview.chromium.org/1036073002 Review URL: https://codereview.chromium.org/1031203003 Review URL: https://codereview.chromium.org/1029193002 Review URL: https://codereview.chromium.org/1016613004 Review URL: https://codereview.chromium.org/1026903002 TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1062163003 --- testing/tools/text_diff.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 testing/tools/text_diff.py (limited to 'testing/tools/text_diff.py') diff --git a/testing/tools/text_diff.py b/testing/tools/text_diff.py new file mode 100755 index 0000000000..3a5bd7bf6a --- /dev/null +++ b/testing/tools/text_diff.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python +# Copyright 2015 The PDFium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import difflib +import sys + +def main(argv): + if len(argv) != 3: + print '%s: invalid arguments' % argv[0] + return 2 + filename1 = argv[1] + filename2 = argv[2] + try: + with open(filename1, "r") as f1: + str1 = f1.readlines(); + with open(filename2, "r") as f2: + str2 = f2.readlines(); + diffs = difflib.unified_diff( + str1, str2, fromfile=filename1, tofile=filename2) + except Exception as e: + print "something went astray: %s" % e + return 1 + status_code = 0 + for diff in diffs: + sys.stdout.write(diff) + status_code = 1 + return status_code + +if __name__ == '__main__': + sys.exit(main(sys.argv)) -- cgit v1.2.3