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

Side by Side Diff: Tools/Scripts/webkitpy/w3c/test_parser.py

Issue 15901008: Modify w3c import script to be able to run over a whole repo. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add more FIXME comments for error handling Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « Tools/Scripts/webkitpy/w3c/test_importer.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 # Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 3 # Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
4 # 4 #
5 # Redistribution and use in source and binary forms, with or without 5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions 6 # modification, are permitted provided that the following conditions
7 # are met: 7 # are met:
8 # 8 #
9 # 1. Redistributions of source code must retain the above 9 # 1. Redistributions of source code must retain the above
10 # copyright notice, this list of conditions and the following 10 # copyright notice, this list of conditions and the following
(...skipping 28 matching lines...) Expand all
39 self.options = options 39 self.options = options
40 self.filename = filename 40 self.filename = filename
41 self.host = Host() 41 self.host = Host()
42 self.filesystem = self.host.filesystem 42 self.filesystem = self.host.filesystem
43 43
44 self.test_doc = None 44 self.test_doc = None
45 self.ref_doc = None 45 self.ref_doc = None
46 self.load_file(filename) 46 self.load_file(filename)
47 47
48 def load_file(self, filename): 48 def load_file(self, filename):
49 if self.filesystem.exists(filename): 49 if self.filesystem.isfile(filename):
50 self.test_doc = Parser(self.filesystem.read_binary_file(filename)) 50 try:
51 self.test_doc = Parser(self.filesystem.read_binary_file(filename ))
52 except:
53 # FIXME: Figure out what to do if we can't parse the file.
54 print "Error: failed to parse %s" % filename
55 self.test_doc is None
51 else: 56 else:
57 if self.filesystem.isdir(filename):
58 # FIXME: Figure out what is triggering this and what to do about it.
59 print "Error: trying to load %s, which is a directory" % filenam e
52 self.test_doc = None 60 self.test_doc = None
53 self.ref_doc = None 61 self.ref_doc = None
54 62
55 def analyze_test(self, test_contents=None, ref_contents=None): 63 def analyze_test(self, test_contents=None, ref_contents=None):
56 """ Analyzes a file to determine if it's a test, what type of test, and what reference or support files it requires. Returns all of the test info """ 64 """ Analyzes a file to determine if it's a test, what type of test, and what reference or support files it requires. Returns all of the test info """
57 65
58 test_info = None 66 test_info = None
59 67
60 if test_contents is None and self.test_doc is None: 68 if test_contents is None and self.test_doc is None:
61 return test_info 69 return test_info
62 70
63 if test_contents is not None: 71 if test_contents is not None:
64 self.test_doc = Parser(test_contents) 72 self.test_doc = Parser(test_contents)
65 73
66 if ref_contents is not None: 74 if ref_contents is not None:
67 self.ref_doc = Parser(ref_contents) 75 self.ref_doc = Parser(ref_contents)
68 76
69 # First check if it's a reftest 77 # First check if it's a reftest
70 78
71 matches = self.reference_links_of_type('match') + self.reference_links_o f_type('mismatch') 79 matches = self.reference_links_of_type('match') + self.reference_links_o f_type('mismatch')
72 if matches: 80 if matches:
73 if len(matches) > 1: 81 if len(matches) > 1:
74 print 'Warning: Webkit does not support multiple references. Imp orting the first ref defined in ' + self.filesystem.basename(self.filename) 82 print 'Warning: Webkit does not support multiple references. Imp orting the first ref defined in ' + self.filesystem.basename(self.filename)
75 83
76 ref_file = self.filesystem.join(self.filesystem.dirname(self.filenam e), matches[0]['href']) 84 try:
85 ref_file = self.filesystem.join(self.filesystem.dirname(self.fil ename), matches[0]['href'])
86 except KeyError as e:
87 # FIXME: Figure out what to do w/ invalid test files.
88 print "Error: %s is has a reference link but is missing the 'hre f'" % (self.filesystem)
ojan 2013/05/28 23:45:54 s/is has/has/
89 return None
90
77 if self.ref_doc is None: 91 if self.ref_doc is None:
78 self.ref_doc = self.load_file(ref_file) 92 self.ref_doc = self.load_file(ref_file)
79 93
80 test_info = {'test': self.filename, 'reference': ref_file} 94 test_info = {'test': self.filename, 'reference': ref_file}
81 95
82 # If the ref file path is relative, we need to check it for 96 # If the ref file path is relative, we need to check it for
83 # relative paths also because when it lands in WebKit, it will be 97 # relative paths also because when it lands in WebKit, it will be
84 # moved down into the test dir. 98 # moved down into the test dir.
85 # 99 #
86 # Note: The test files themselves are not checked for support files 100 # Note: The test files themselves are not checked for support files
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 147
134 src_paths = [src_tag['src'] for src_tag in elements_with_src_attributes] 148 src_paths = [src_tag['src'] for src_tag in elements_with_src_attributes]
135 href_paths = [href_tag['href'] for href_tag in elements_with_href_attrib utes] 149 href_paths = [href_tag['href'] for href_tag in elements_with_href_attrib utes]
136 150
137 paths = src_paths + href_paths + urls 151 paths = src_paths + href_paths + urls
138 for path in paths: 152 for path in paths:
139 if not(path.startswith('http:')) and not(path.startswith('mailto:')) : 153 if not(path.startswith('http:')) and not(path.startswith('mailto:')) :
140 support_files.append(path) 154 support_files.append(path)
141 155
142 return support_files 156 return support_files
OLDNEW
« no previous file with comments | « Tools/Scripts/webkitpy/w3c/test_importer.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698