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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 #!/usr/bin/python
2
3 # Copyright 2016 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
6 """Test that the set of gen-* files is the same as the generated files."""
7
8 import fnmatch
9 import os
10 import sys
11 import generate
12
13 UPDATE_TIP = ('To update the generated tests, run:\n'
14 '$ python third_party/WebKit/LayoutTests/bluetooth/generate.py')
15
16
17 def main():
18 generated_files = set()
19 # Tests data in gen-* files is the same as the data generated.
20 for generated_test in generate.GetGeneratedTests():
21 generated_files.add(generated_test.path)
22 try:
23 with open(generated_test.path) as f:
24 data = f.read().decode('utf-8')
25 if data != generated_test.data:
26 print generated_test.path + ' does not match template.'
27 print UPDATE_TIP
28 return -1
29 except IOError, e:
30 if e.errno == 2:
31 print 'Missing generated test:\n{}\nFor template:\n{}'.format(
32 generated_test.path, generated_test.template)
33 print UPDATE_TIP
34 return -1
35
36 # Tests that there are no obsolete generated files.
37 previous_generated_files = set()
38 current_path = os.path.dirname(os.path.realpath(__file__))
39 for root, _, filenames in os.walk(current_path):
40 for filename in fnmatch.filter(filenames, 'gen-*.html'):
41 previous_generated_files.add(os.path.join(root, filename))
42
43 if previous_generated_files != generated_files:
44 print 'There are extra generated tests. Please remove them.'
45 for test_path in previous_generated_files - generated_files:
46 print test_path
47 return -1
48
49
50 if __name__ == '__main__':
51 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698