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

Side by Side Diff: bower_components/web-animations-js/test/update-testcases.py

Issue 786953007: npm_modules: Fork bower_components into Polymer 0.4.0 and 0.5.0 versions (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: Created 5 years, 11 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 import cStringIO as StringIO
4 from fnmatch import fnmatch
5 import difflib
6 import os
7 import sys
8
9
10 def get_name(filename):
11 return os.path.splitext(filename)[0]
12
13
14 def list_dir(dir_path, filter_func):
15 return sorted(filter(filter_func, os.listdir(dir_path)), key=get_name)
16
17
18 def main():
19 test_dir = os.path.dirname(os.path.realpath(__file__))
20 testcase_dir = os.path.join(test_dir, 'testcases')
21 testcase_file = os.path.join(test_dir, 'testcases.js')
22
23 def is_testcase_file(filename):
24 return (
25 fnmatch(filename, "*.html") and
26 not fnmatch(filename, "manual-test*") and
27 not fnmatch(filename, "disabled-*"))
28
29 new_testcases = StringIO.StringIO()
30 new_testcases.write("""\
31 // This file is automatically generated by test/update-testcases.py.
32 // Disable tests by adding them to test/disabled-testcases
33 """)
34 new_testcases.write('var tests = [\n \'')
35 new_testcases.write(
36 '\',\n \''.join(list_dir(testcase_dir, is_testcase_file)))
37 new_testcases.write('\',\n];\n')
38 new_testcases.seek(0)
39 new_testcases_lines = new_testcases.readlines()
40
41 current_testcases_lines = file(testcase_file).readlines()
42
43 lines = list(difflib.unified_diff(
44 current_testcases_lines, new_testcases_lines,
45 fromfile=testcase_file, tofile=testcase_file))
46
47 if len(lines) == 0:
48 sys.stdout.write('Nothing to do\n')
49 sys.exit(0)
50
51 if not "--dry-run" in sys.argv:
52 file(testcase_file, "w").write("".join(new_testcases_lines))
53 sys.stdout.write(
54 'Updating %s with the following diff.\n' % testcase_file)
55
56 for line in lines:
57 sys.stdout.write(line)
58
59 sys.exit(1)
60
61
62 if __name__ == '__main__':
63 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698