Index: third_party/dom_distiller_js/protoc_plugins/json_values_converter_tests.py |
diff --git a/third_party/dom_distiller_js/protoc_plugins/json_values_converter_tests.py b/third_party/dom_distiller_js/protoc_plugins/json_values_converter_tests.py |
new file mode 100755 |
index 0000000000000000000000000000000000000000..5b5b56b8f56ead4c0282c652f97a53ab5226743f |
--- /dev/null |
+++ b/third_party/dom_distiller_js/protoc_plugins/json_values_converter_tests.py |
@@ -0,0 +1,46 @@ |
+#!/usr/bin/env python |
+# Copyright (c) 2016 The Chromium Authors. All rights reserved. |
+# Use of this source code is governed by a BSD-style license that can be |
+# found in the LICENSE file. |
+ |
+"""Tests for json_values_converter.py. |
+ |
+It tests json_values_converter.py. |
+""" |
+ |
+import argparse |
+import os |
+import sys |
+ |
+ |
+def CompareFiles(file1, file2): |
+ return file(file1, 'r').read() == file(file2, 'r').read() |
+ |
+def TouchStamp(stamp_path): |
+ dir_name = os.path.dirname(stamp_path) |
+ if not os.path.isdir(dir_name): |
+ os.makedirs() |
+ |
+ with open(stamp_path, 'a'): |
+ os.utime(stamp_path, None) |
+ |
+def main(argv): |
+ parser = argparse.ArgumentParser() |
+ parser.add_argument('--stamp', |
+ help='Path to touch on success.') |
+ parser.add_argument('files', nargs='+', |
+ help='Files to compare.') |
+ |
+ args = parser.parse_args() |
+ |
+ passed = True |
+ for i, j in zip(args.files[::2], args.files[1::2]): |
+ passed = passed and CompareFiles(i, j) |
+ |
+ if passed and args.stamp: |
+ TouchStamp(args.stamp) |
+ |
+ return not passed |
+ |
+if __name__ == '__main__': |
+ sys.exit(main(sys.argv)) |