aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/tests/bench_pictures_cfg_test.py
diff options
context:
space:
mode:
authorGravatar borenet@google.com <borenet@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-12-17 17:21:04 +0000
committerGravatar borenet@google.com <borenet@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-12-17 17:21:04 +0000
commit3b98bfd4023b0cdd853013a3d52a052551ecdbb8 (patch)
treeb7a7e46b3389cad035b44963b1cfc96b4446f521 /tools/tests/bench_pictures_cfg_test.py
parent5f8c8f448673c65c5434cf1e419319eccf34117b (diff)
Address comments for r6822: https://codereview.appspot.com/6946052/
Review URL: https://codereview.appspot.com/6943059 git-svn-id: http://skia.googlecode.com/svn/trunk@6847 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tools/tests/bench_pictures_cfg_test.py')
-rw-r--r--tools/tests/bench_pictures_cfg_test.py26
1 files changed, 18 insertions, 8 deletions
diff --git a/tools/tests/bench_pictures_cfg_test.py b/tools/tests/bench_pictures_cfg_test.py
index 1913e4208c..77ad553b28 100644
--- a/tools/tests/bench_pictures_cfg_test.py
+++ b/tools/tests/bench_pictures_cfg_test.py
@@ -12,25 +12,35 @@ import os
import sys
+def ThrowIfNotAString(obj):
+ """ Raise a TypeError if obj is not a string. """
+ if str(obj) != obj:
+ raise TypeError('%s is not a string!' % str(obj))
+
+
def Main(argv):
+ """ Verify that the bench_pictures.cfg file is sane.
+
+ - Exec the file to ensure that it uses correct Python syntax.
+ - Make sure that every element is a string, because the buildbot scripts will
+ fail to execute if this is not the case.
+
+ This test does not verify that the well-formed configs are actually valid.
+ """
vars = {'import_path': 'tools'}
execfile(os.path.join('tools', 'bench_pictures.cfg'), vars)
bench_pictures_cfg = vars['bench_pictures_cfg']
for config_name, config_list in bench_pictures_cfg.iteritems():
- if str(config_name) != config_name:
- raise TypeError('%s is not a string!' % str(config_name))
+ ThrowIfNotAString(config_name)
for config in config_list:
for key, value in config.iteritems():
- if str(key) != key:
- raise TypeError('%s is not a string!\n%s' % (str(key), config))
+ ThrowIfNotAString(key)
if type(value).__name__ == 'list':
for item in value:
- if str(item) != item:
- raise TypeError('%s is not a string!\n%s' % (str(item), config))
+ ThrowIfNotAString(item)
else:
- if str(value) != value:
- raise TypeError('%s is not a string!\n%s' % (str(value), config))
+ ThrowIfNotAString(value)
if __name__ == '__main__':
sys.exit(Main(sys.argv)) \ No newline at end of file