summaryrefslogtreecommitdiff
path: root/testing/tools/text_diff.py
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-03-26 16:29:05 -0700
committerTom Sepez <tsepez@chromium.org>2015-03-26 16:29:05 -0700
commit84e50d58496622af351cd27da51479059736923d (patch)
tree1358a04b895e9692b4a3a2d65522b15ffcf6ca64 /testing/tools/text_diff.py
parent30506b41ea88cf6743c314743ce477e8186a3945 (diff)
downloadpdfium-84e50d58496622af351cd27da51479059736923d.tar.xz
Replace linux-specific code in test scripts.
Now that there's a win bot, this needs to be more careful. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1036073002
Diffstat (limited to 'testing/tools/text_diff.py')
-rwxr-xr-xtesting/tools/text_diff.py32
1 files changed, 32 insertions, 0 deletions
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))