2013-12-23 22:47:15 +00:00
|
|
|
#!/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.
|
|
|
|
|
2014-03-21 17:54:14 +00:00
|
|
|
Test compare_to_expectations.py
|
2013-12-23 22:47:15 +00:00
|
|
|
|
|
|
|
TODO(epoger): Create a command to update the expected results (in
|
2014-02-19 15:38:13 +00:00
|
|
|
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
|
2013-12-23 22:47:15 +00:00
|
|
|
Although, if you're using an SVN checkout, this will blow away .svn directories
|
2014-02-19 15:38:13 +00:00
|
|
|
within self._output_dir_expected, which wouldn't be good...
|
2013-12-23 22:47:15 +00:00
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
# Imports from within Skia
|
2014-02-19 15:38:13 +00:00
|
|
|
import base_unittest
|
2014-03-21 17:54:14 +00:00
|
|
|
import compare_to_expectations
|
2013-12-23 22:47:15 +00:00
|
|
|
import results
|
|
|
|
import gm_json # must import results first, so that gm_json will be in sys.path
|
|
|
|
|
2014-01-03 16:04:11 +00:00
|
|
|
|
2014-03-21 17:54:14 +00:00
|
|
|
class CompareToExpectationsTest(base_unittest.TestCase):
|
2014-01-06 18:33:19 +00:00
|
|
|
|
2013-12-23 22:47:15 +00:00
|
|
|
def test_gm(self):
|
2014-03-31 15:17:52 +00:00
|
|
|
"""Process results of a GM run with the ExpectationComparisons object."""
|
|
|
|
results_obj = compare_to_expectations.ExpectationComparisons(
|
2014-02-19 15:38:13 +00:00
|
|
|
actuals_root=os.path.join(self._input_dir, 'gm-actuals'),
|
|
|
|
expected_root=os.path.join(self._input_dir, 'gm-expectations'),
|
2014-03-20 17:27:46 +00:00
|
|
|
generated_images_root=self._temp_dir,
|
|
|
|
diff_base_url='/static/generated-images')
|
2014-03-13 16:33:36 +00:00
|
|
|
results_obj.get_timestamp = mock_get_timestamp
|
2014-02-26 19:05:20 +00:00
|
|
|
gm_json.WriteToFile(
|
2014-03-13 16:33:36 +00:00
|
|
|
results_obj.get_packaged_results_of_type(
|
|
|
|
results.KEY__HEADER__RESULTS_ALL),
|
2014-02-26 19:05:20 +00:00
|
|
|
os.path.join(self._output_dir_actual, 'gm.json'))
|
2014-01-03 16:04:11 +00:00
|
|
|
|
|
|
|
|
2014-03-13 16:33:36 +00:00
|
|
|
def mock_get_timestamp():
|
2014-03-31 15:17:52 +00:00
|
|
|
"""Mock version of BaseComparisons.get_timestamp() for testing."""
|
2014-03-13 16:33:36 +00:00
|
|
|
return 12345678
|
|
|
|
|
|
|
|
|
2013-12-23 22:47:15 +00:00
|
|
|
def main():
|
2014-03-21 17:54:14 +00:00
|
|
|
base_unittest.main(CompareToExpectationsTest)
|
2013-12-23 22:47:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|