results_test.py revision ea770f155e72f88e66a4d9c652552517d46a8605
1#!/usr/bin/python
2
3"""
4Copyright 2013 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 results.py
10
11TODO(epoger): Create a command to update the expected results (in
12self._output_dir_expected) when appropriate.  For now, you should:
131. examine the results in self._output_dir_actual and make sure they are ok
142. rm -rf self._output_dir_expected
153. mv self._output_dir_actual self._output_dir_expected
16Although, 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
21import os
22import sys
23
24# Imports from within Skia
25import base_unittest
26import results
27import gm_json  # must import results first, so that gm_json will be in sys.path
28
29
30class ResultsTest(base_unittest.TestCase):
31
32  def test_gm(self):
33    """Process results of a GM run with the Results object."""
34    results_obj = results.Results(
35        actuals_root=os.path.join(self._input_dir, 'gm-actuals'),
36        expected_root=os.path.join(self._input_dir, 'gm-expectations'),
37        generated_images_root=self._temp_dir)
38    results_obj.get_timestamp = mock_get_timestamp
39    gm_json.WriteToFile(
40        results_obj.get_packaged_results_of_type(
41            results.KEY__HEADER__RESULTS_ALL),
42        os.path.join(self._output_dir_actual, 'gm.json'))
43
44
45def mock_get_timestamp():
46  """Mock version of Results.get_timestamp() for testing."""
47  return 12345678
48
49
50def main():
51  base_unittest.main(ResultsTest)
52
53
54if __name__ == '__main__':
55  main()
56