skia2/gm/rebaseline_server/compare_to_expectations_test.py
epoger 6132b436d8 rebaseline_server: cache results in long-running ImageDiffDB instance
Rather than rebuilding the ImageDiffDB from scratch every time we update expected/actual results, keep the same ImageDiffDB instance around and add image pairs to it.

This makes updating results within a long-running server.py *much* faster, and tests out an idea I'm ruminating in https://goto.google.com/LongRunningImageDiffDBServer : we could run an ImageDiffDB server that developers could connect to from their locally running rebaseline_server instances, for much faster launch times.

BUG=skia:2414
NOTRY=True
R=rmistry@google.com

Author: epoger@google.com

Review URL: https://codereview.chromium.org/379563005
2014-07-09 07:59:06 -07:00

59 lines
1.8 KiB
Python
Executable File

#!/usr/bin/python
"""
Copyright 2013 Google Inc.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
Test compare_to_expectations.py
TODO(epoger): Create a command to update the expected results (in
self._output_dir_expected) when appropriate. For now, you should:
1. examine the results in self._output_dir_actual and make sure they are ok
2. rm -rf self._output_dir_expected
3. mv self._output_dir_actual self._output_dir_expected
Although, if you're using an SVN checkout, this will blow away .svn directories
within self._output_dir_expected, which wouldn't be good...
"""
import os
# Imports from within Skia
import base_unittest
import compare_to_expectations
import imagediffdb
import results
import gm_json # must import results first, so that gm_json will be in sys.path
class CompareToExpectationsTest(base_unittest.TestCase):
def test_gm(self):
"""Process results of a GM run with the ExpectationComparisons object."""
image_diff_db = imagediffdb.ImageDiffDB(storage_root=self._temp_dir)
results_obj = compare_to_expectations.ExpectationComparisons(
image_diff_db=image_diff_db,
actuals_root=os.path.join(self._input_dir, 'gm-actuals'),
expected_root=os.path.join(self._input_dir, 'gm-expectations'),
diff_base_url='/static/generated-images')
results_obj.get_timestamp = mock_get_timestamp
gm_json.WriteToFile(
results_obj.get_packaged_results_of_type(
results.KEY__HEADER__RESULTS_ALL),
os.path.join(self._output_dir_actual, 'gm.json'))
def mock_get_timestamp():
"""Mock version of BaseComparisons.get_timestamp() for testing."""
return 12345678
def main():
base_unittest.main(CompareToExpectationsTest)
if __name__ == '__main__':
main()