epoger@google.com | f9d134d | 2013-09-27 15:02:44 +0000 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
epoger@google.com | 9fb6c8a | 2013-10-09 18:05:58 +0000 | [diff] [blame] | 3 | """ |
epoger@google.com | f9d134d | 2013-09-27 15:02:44 +0000 | [diff] [blame] | 4 | Copyright 2013 Google Inc. |
| 5 | |
| 6 | Use of this source code is governed by a BSD-style license that can be |
| 7 | found in the LICENSE file. |
epoger@google.com | f9d134d | 2013-09-27 15:02:44 +0000 | [diff] [blame] | 8 | |
epoger@google.com | f9d134d | 2013-09-27 15:02:44 +0000 | [diff] [blame] | 9 | Repackage expected/actual GM results as needed by our HTML rebaseline viewer. |
epoger@google.com | 9fb6c8a | 2013-10-09 18:05:58 +0000 | [diff] [blame] | 10 | """ |
epoger@google.com | f9d134d | 2013-09-27 15:02:44 +0000 | [diff] [blame] | 11 | |
| 12 | # System-level imports |
epoger@google.com | f9d134d | 2013-09-27 15:02:44 +0000 | [diff] [blame] | 13 | import os |
| 14 | import re |
| 15 | import sys |
| 16 | |
| 17 | # Imports from within Skia |
| 18 | # |
| 19 | # We need to add the 'gm' directory, so that we can import gm_json.py within |
| 20 | # that directory. That script allows us to parse the actual-results.json file |
| 21 | # written out by the GM tool. |
| 22 | # Make sure that the 'gm' dir is in the PYTHONPATH, but add it at the *end* |
| 23 | # so any dirs that are already in the PYTHONPATH will be preferred. |
commit-bot@chromium.org | 7b06c8e | 2013-12-23 22:47:15 +0000 | [diff] [blame] | 24 | PARENT_DIRECTORY = os.path.dirname(os.path.realpath(__file__)) |
| 25 | GM_DIRECTORY = os.path.dirname(PARENT_DIRECTORY) |
epoger@google.com | f9d134d | 2013-09-27 15:02:44 +0000 | [diff] [blame] | 26 | if GM_DIRECTORY not in sys.path: |
| 27 | sys.path.append(GM_DIRECTORY) |
| 28 | import gm_json |
commit-bot@chromium.org | 16f4180 | 2014-02-26 19:05:20 +0000 | [diff] [blame] | 29 | |
| 30 | # Keys used to link an image to a particular GM test. |
| 31 | # NOTE: Keep these in sync with static/constants.js |
commit-bot@chromium.org | d1c85d2 | 2014-03-17 14:22:02 +0000 | [diff] [blame] | 32 | REBASELINE_SERVER_SCHEMA_VERSION_NUMBER = 2 |
commit-bot@chromium.org | 16f4180 | 2014-02-26 19:05:20 +0000 | [diff] [blame] | 33 | KEY__EXPECTATIONS__BUGS = gm_json.JSONKEY_EXPECTEDRESULTS_BUGS |
| 34 | KEY__EXPECTATIONS__IGNOREFAILURE = gm_json.JSONKEY_EXPECTEDRESULTS_IGNOREFAILURE |
| 35 | KEY__EXPECTATIONS__REVIEWED = gm_json.JSONKEY_EXPECTEDRESULTS_REVIEWED |
| 36 | KEY__EXTRACOLUMN__BUILDER = 'builder' |
| 37 | KEY__EXTRACOLUMN__CONFIG = 'config' |
| 38 | KEY__EXTRACOLUMN__RESULT_TYPE = 'resultType' |
| 39 | KEY__EXTRACOLUMN__TEST = 'test' |
commit-bot@chromium.org | 7498d95 | 2014-03-13 14:56:29 +0000 | [diff] [blame] | 40 | KEY__HEADER = 'header' |
| 41 | KEY__HEADER__DATAHASH = 'dataHash' |
| 42 | KEY__HEADER__IS_EDITABLE = 'isEditable' |
| 43 | KEY__HEADER__IS_EXPORTED = 'isExported' |
| 44 | KEY__HEADER__IS_STILL_LOADING = 'resultsStillLoading' |
commit-bot@chromium.org | 16f4180 | 2014-02-26 19:05:20 +0000 | [diff] [blame] | 45 | KEY__HEADER__RESULTS_ALL = 'all' |
| 46 | KEY__HEADER__RESULTS_FAILURES = 'failures' |
commit-bot@chromium.org | ea770f1 | 2014-03-13 16:33:36 +0000 | [diff] [blame] | 47 | KEY__HEADER__SCHEMA_VERSION = 'schemaVersion' |
commit-bot@chromium.org | 7498d95 | 2014-03-13 14:56:29 +0000 | [diff] [blame] | 48 | KEY__HEADER__TIME_NEXT_UPDATE_AVAILABLE = 'timeNextUpdateAvailable' |
| 49 | KEY__HEADER__TIME_UPDATED = 'timeUpdated' |
| 50 | KEY__HEADER__TYPE = 'type' |
commit-bot@chromium.org | 16f4180 | 2014-02-26 19:05:20 +0000 | [diff] [blame] | 51 | KEY__NEW_IMAGE_URL = 'newImageUrl' |
| 52 | KEY__RESULT_TYPE__FAILED = gm_json.JSONKEY_ACTUALRESULTS_FAILED |
| 53 | KEY__RESULT_TYPE__FAILUREIGNORED = gm_json.JSONKEY_ACTUALRESULTS_FAILUREIGNORED |
| 54 | KEY__RESULT_TYPE__NOCOMPARISON = gm_json.JSONKEY_ACTUALRESULTS_NOCOMPARISON |
| 55 | KEY__RESULT_TYPE__SUCCEEDED = gm_json.JSONKEY_ACTUALRESULTS_SUCCEEDED |
| 56 | |
epoger@google.com | f9d134d | 2013-09-27 15:02:44 +0000 | [diff] [blame] | 57 | IMAGE_FILENAME_RE = re.compile(gm_json.IMAGE_FILENAME_PATTERN) |
epoger@google.com | eb83259 | 2013-10-23 15:07:26 +0000 | [diff] [blame] | 58 | IMAGE_FILENAME_FORMATTER = '%s_%s.png' # pass in (testname, config) |