Skip to content

Commit

Permalink
hook up visual tests to the 'make test' target
Browse files Browse the repository at this point in the history
  • Loading branch information
Dane Springmeyer committed Mar 23, 2012
1 parent 2ff8c33 commit e570ea3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions Makefile
Expand Up @@ -19,6 +19,7 @@ uninstall:

test:
@python tests/run_tests.py -q
@python tests/visual_tests/test.py

pep8:
# https://gist.github.com/1903033
Expand Down
8 changes: 6 additions & 2 deletions tests/visual_tests/compare.py
Expand Up @@ -42,13 +42,17 @@ def compare(fn1, fn2):

def summary():
global errors
print "-"*80
print "Summary:"
if len(errors) != 0:
print "-"*80
print "Summary:"
for error in errors:
if (error[1] is None):
print "Could not verify %s: No reference image found!" % error[0]
else:
print "%s failed: %d different pixels" % error
print "-"*80
sys.exit(1)
else:
print 'No errors detected!'
print "-"*80
sys.exit(0)
1 change: 1 addition & 0 deletions tests/visual_tests/test.py
Expand Up @@ -19,6 +19,7 @@
(499, 100), (500, 100), (501, 100), (502, 100), (505, 100), (510, 100)]

dirname = os.path.dirname(__file__)

files = [
{'name': "list", 'sizes': sizes_many_in_big_range},
{'name': "simple", 'sizes': sizes_many_in_big_range},
Expand Down
10 changes: 6 additions & 4 deletions tests/visual_tests/test_python.py
Expand Up @@ -4,6 +4,8 @@
import os.path
from compare import compare, summary

dirname = os.path.dirname(__file__)

class MyText(mapnik.FormattingNode):
def __init__(self):
mapnik.FormattingNode.__init__(self)
Expand Down Expand Up @@ -69,7 +71,7 @@ def add_expressions(self, output):


layer = mapnik.Layer('Layer')
layer.datasource = mapnik.Shapefile(file="data/points.shp")
layer.datasource = mapnik.Shapefile(file=os.path.join(dirname,"data/points.shp"))
layer.styles.append('Style')
m.layers.append(layer)

Expand Down Expand Up @@ -97,9 +99,9 @@ def add_expressions(self, output):

for format_tree in format_trees:
text.placements.defaults.format_tree = format_tree[1]
mapnik.render_to_file(m, os.path.join("images", 'python-%s.png' % format_tree[0]), 'png')
compare(os.path.join("images", 'python-%s.png' % format_tree[0]),
os.path.join("images", 'python-%s-reference.png' % format_tree[0])
mapnik.render_to_file(m, os.path.join(dirname,"images", 'python-%s.png' % format_tree[0]), 'png')
compare(os.path.join(dirname,"images", 'python-%s.png' % format_tree[0]),
os.path.join(dirname,"images", 'python-%s-reference.png' % format_tree[0])
)

summary()

0 comments on commit e570ea3

Please sign in to comment.