blob: 612be99837ed75fa284d1fb6bc154a8d1f072bf5 [file] [log] [blame]
commit-bot@chromium.org31d0b3d2014-03-31 15:17:52 +00001#!/usr/bin/python
2
3"""
4Copyright 2014 Google Inc.
5
6Use of this source code is governed by a BSD-style license that can be
7found in the LICENSE file.
8
9Test compare_configs.py
10
11TODO(epoger): Create a command to update the expected results (in
12self._output_dir_expected) when appropriate. For now, you should:
epoger66ed8dc2014-07-17 12:54:16 -0700131. examine the results in self.output_dir_actual and make sure they are ok
commit-bot@chromium.org31d0b3d2014-03-31 15:17:52 +0000142. rm -rf self._output_dir_expected
epoger66ed8dc2014-07-17 12:54:16 -0700153. mv self.output_dir_actual self._output_dir_expected
commit-bot@chromium.org31d0b3d2014-03-31 15:17:52 +000016Although, if you're using an SVN checkout, this will blow away .svn directories
17within self._output_dir_expected, which wouldn't be good...
18
19"""
20
epoger66ed8dc2014-07-17 12:54:16 -070021# System-level imports
commit-bot@chromium.org31d0b3d2014-03-31 15:17:52 +000022import os
epoger66ed8dc2014-07-17 12:54:16 -070023
24# Must fix up PYTHONPATH before importing from within Skia
stephana3b5c86c2014-08-18 13:37:59 -070025import rs_fixpypath # pylint: disable=W0611
commit-bot@chromium.org31d0b3d2014-03-31 15:17:52 +000026
27# Imports from within Skia
28import base_unittest
29import compare_configs
epoger66ed8dc2014-07-17 12:54:16 -070030import gm_json
commit-bot@chromium.org31d0b3d2014-03-31 15:17:52 +000031import results
commit-bot@chromium.org31d0b3d2014-03-31 15:17:52 +000032
33
34class CompareConfigsTest(base_unittest.TestCase):
35
36 def test_gm(self):
37 """Process results of a GM run with the ConfigComparisons object."""
38 results_obj = compare_configs.ConfigComparisons(
39 configs=('8888', 'gpu'),
epoger66ed8dc2014-07-17 12:54:16 -070040 actuals_root=os.path.join(self.input_dir, 'gm-actuals'),
41 generated_images_root=self.temp_dir,
commit-bot@chromium.org31d0b3d2014-03-31 15:17:52 +000042 diff_base_url='/static/generated-images')
43 results_obj.get_timestamp = mock_get_timestamp
44 gm_json.WriteToFile(
45 results_obj.get_packaged_results_of_type(
46 results.KEY__HEADER__RESULTS_ALL),
epoger66ed8dc2014-07-17 12:54:16 -070047 os.path.join(self.output_dir_actual, 'gm.json'))
commit-bot@chromium.org31d0b3d2014-03-31 15:17:52 +000048
49
50def mock_get_timestamp():
51 """Mock version of BaseComparisons.get_timestamp() for testing."""
52 return 12345678
53
54
55def main():
56 base_unittest.main(CompareConfigsTest)
57
58
59if __name__ == '__main__':
60 main()