Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1386)

Unified Diff: third_party/WebKit/LayoutTests/bluetooth/generate_test.py

Issue 2423853002: bluetooth: Add script to generate tests based on templates (Closed)
Patch Set: Remove replace loop Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/bluetooth/generate_test.py
diff --git a/third_party/WebKit/LayoutTests/bluetooth/generate_test.py b/third_party/WebKit/LayoutTests/bluetooth/generate_test.py
new file mode 100755
index 0000000000000000000000000000000000000000..e500ff6e5959dc7db0b3c55d2df185be168540c0
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/bluetooth/generate_test.py
@@ -0,0 +1,51 @@
+#!/usr/bin/python
+
+# Copyright 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.
+"""Test that the set of gen-* files is the same as the generated files."""
+
+import fnmatch
+import os
+import sys
+import generate
+
+UPDATE_TIP = ('To update the generated tests, run:\n'
+ '$ python third_party/WebKit/LayoutTests/bluetooth/generate.py')
+
+
+def main():
+ generated_files = set()
+ # Tests data in gen-* files is the same as the data generated.
+ for generated_test in generate.GetGeneratedTests():
+ generated_files.add(generated_test.path)
+ try:
+ with open(generated_test.path) as f:
+ data = f.read().decode('utf-8')
+ if data != generated_test.data:
+ print generated_test.path + ' does not match template.'
+ print UPDATE_TIP
+ return -1
+ except IOError, e:
+ if e.errno == 2:
+ print 'Missing generated test:\n{}\nFor template:\n{}'.format(
+ generated_test.path, generated_test.template)
+ print UPDATE_TIP
+ return -1
+
+ # Tests that there are no obsolete generated files.
+ previous_generated_files = set()
+ current_path = os.path.dirname(os.path.realpath(__file__))
+ for root, _, filenames in os.walk(current_path):
+ for filename in fnmatch.filter(filenames, 'gen-*.html'):
+ previous_generated_files.add(os.path.join(root, filename))
+
+ if previous_generated_files != generated_files:
+ print 'There are extra generated tests. Please remove them.'
+ for test_path in previous_generated_files - generated_files:
+ print test_path
+ return -1
+
+
+if __name__ == '__main__':
+ sys.exit(main())

Powered by Google App Engine
This is Rietveld 408576698