summaryrefslogtreecommitdiff
path: root/platform/android/scripts/run-render-test.py
blob: 940ae7a3dfd23e6b7c3b98d53699e339cafdcde0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/python

import os
import shutil

catPath = os.getcwd() + "/platform/android/build/render-test/"
failCounter = 0
testCounter = 0
for cat in os.listdir(catPath):
    testPath = catPath + cat + "/"
    for test in os.listdir(testPath):
        inputPath = os.getcwd() + "/mapbox-gl-js/test/integration/render-tests/" + cat + "/" + test
        outputPath = testPath + test

        expected = outputPath + "/expected.png"
        actual = outputPath + "/actual.png"
        output = outputPath + "/output.png"

        shutil.copyfile(inputPath + "/expected.png", expected)
        shutil.copyfile(inputPath + "/style.json", outputPath + "/style.json")
        pixelmatchCommand = "node_modules/pixelmatch/bin/pixelmatch " + actual + " " + expected + " " + output + " 0.1"

        print "Pixel match " + cat + " " + test

        with os.popen(pixelmatchCommand) as f:
            for line_terminated in f:
                line = line_terminated.rstrip('\n')
                pair = line.split(": ")
                if pair[0] == "error":
                    testCounter += 1
                    currentError = pair[1]
                    if currentError != "0%":
                       failCounter += 1
                    # below deletes successful results
                    #    print cat + " " + test + " " + currentError
                    # else:
                        # try:
                        #     if os.path.isdir(outputPath):
                        #         shutil.rmtree(outputPath)
                        # except OSError, e:
                        #     print ("Error: %s - %s." % (e.filename, e.strerror))
print
print  str(failCounter) + "/" + str(testCounter)