OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """Verify perf_expectations.json can be loaded using simplejson. | 7 """Verify perf_expectations.json can be loaded using simplejson. |
8 | 8 |
9 perf_expectations.json is a JSON-formatted file. This script verifies | 9 perf_expectations.json is a JSON-formatted file. This script verifies |
10 that simplejson can load it correctly. It should catch most common | 10 that simplejson can load it correctly. It should catch most common |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
144 # regular expression. | 144 # regular expression. |
145 if not re.match(r"^([\w\.-]+)/([\w\.-]+)/([\w\.-]+)/([\w\.-]+)$", key): | 145 if not re.match(r"^([\w\.-]+)/([\w\.-]+)/([\w\.-]+)/([\w\.-]+)$", key): |
146 bad_keys.append(key) | 146 bad_keys.append(key) |
147 if len(bad_keys) > 0: | 147 if len(bad_keys) > 0: |
148 msg = "perf expectations keys in bad format, expected a/b/c/d" | 148 msg = "perf expectations keys in bad format, expected a/b/c/d" |
149 raise Exception("%s: %s" % (msg, bad_keys)) | 149 raise Exception("%s: %s" % (msg, bad_keys)) |
150 | 150 |
151 def testNoUpdatesNeeded(self): | 151 def testNoUpdatesNeeded(self): |
152 p = subprocess.Popen([MAKE_EXPECTATIONS, '-s'], stdout=subprocess.PIPE) | 152 p = subprocess.Popen([MAKE_EXPECTATIONS, '-s'], stdout=subprocess.PIPE) |
153 p.wait(); | 153 p.wait(); |
154 self.assertEqual(p.returncode, 0, msg='Expectations has pending updates!') | 154 self.assertEqual(p.returncode, 0, |
155 msg='Update expectations first! (run make_expectations.py)') | |
Nico
2012/01/17 20:33:27
nit: I prefer diagnostic messages without exclamat
cmp
2012/01/17 20:35:46
Done.
| |
155 | 156 |
156 def testConfigFile(self): | 157 def testConfigFile(self): |
157 # Test that the config file can be parsed as JSON. | 158 # Test that the config file can be parsed as JSON. |
158 config = LoadJsonFile(CONFIG_JSON) | 159 config = LoadJsonFile(CONFIG_JSON) |
159 # Require the following keys. | 160 # Require the following keys. |
160 if 'base_url' not in config: | 161 if 'base_url' not in config: |
161 raise Exception('base_url not specified in config file') | 162 raise Exception('base_url not specified in config file') |
162 if 'perf_file' not in config: | 163 if 'perf_file' not in config: |
163 raise Exception('perf_file not specified in config file') | 164 raise Exception('perf_file not specified in config file') |
164 | 165 |
165 | 166 |
166 if __name__ == '__main__': | 167 if __name__ == '__main__': |
167 unittest.main() | 168 unittest.main() |
OLD | NEW |