| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 """ | 3 """ |
| 4 Copyright 2014 Google Inc. | 4 Copyright 2014 Google Inc. |
| 5 | 5 |
| 6 Use of this source code is governed by a BSD-style license that can be | 6 Use of this source code is governed by a BSD-style license that can be |
| 7 found in the LICENSE file. | 7 found in the LICENSE file. |
| 8 | 8 |
| 9 Test compare_configs.py | 9 Test compare_configs.py |
| 10 | 10 |
| 11 TODO(epoger): Create a command to update the expected results (in | 11 TODO(epoger): Create a command to update the expected results (in |
| 12 self._output_dir_expected) when appropriate. For now, you should: | 12 self._output_dir_expected) when appropriate. For now, you should: |
| 13 1. examine the results in self._output_dir_actual and make sure they are ok | 13 1. examine the results in self.output_dir_actual and make sure they are ok |
| 14 2. rm -rf self._output_dir_expected | 14 2. rm -rf self._output_dir_expected |
| 15 3. mv self._output_dir_actual self._output_dir_expected | 15 3. mv self.output_dir_actual self._output_dir_expected |
| 16 Although, if you're using an SVN checkout, this will blow away .svn directories | 16 Although, if you're using an SVN checkout, this will blow away .svn directories |
| 17 within self._output_dir_expected, which wouldn't be good... | 17 within self._output_dir_expected, which wouldn't be good... |
| 18 | 18 |
| 19 """ | 19 """ |
| 20 | 20 |
| 21 # System-level imports |
| 21 import os | 22 import os |
| 22 import sys | 23 |
| 24 # Must fix up PYTHONPATH before importing from within Skia |
| 25 import fix_pythonpath # pylint: disable=W0611 |
| 23 | 26 |
| 24 # Imports from within Skia | 27 # Imports from within Skia |
| 25 import base_unittest | 28 import base_unittest |
| 26 import compare_configs | 29 import compare_configs |
| 30 import gm_json |
| 27 import results | 31 import results |
| 28 import gm_json # must import results first, so that gm_json will be in sys.path | |
| 29 | 32 |
| 30 | 33 |
| 31 class CompareConfigsTest(base_unittest.TestCase): | 34 class CompareConfigsTest(base_unittest.TestCase): |
| 32 | 35 |
| 33 def test_gm(self): | 36 def test_gm(self): |
| 34 """Process results of a GM run with the ConfigComparisons object.""" | 37 """Process results of a GM run with the ConfigComparisons object.""" |
| 35 results_obj = compare_configs.ConfigComparisons( | 38 results_obj = compare_configs.ConfigComparisons( |
| 36 configs=('8888', 'gpu'), | 39 configs=('8888', 'gpu'), |
| 37 actuals_root=os.path.join(self._input_dir, 'gm-actuals'), | 40 actuals_root=os.path.join(self.input_dir, 'gm-actuals'), |
| 38 generated_images_root=self._temp_dir, | 41 generated_images_root=self.temp_dir, |
| 39 diff_base_url='/static/generated-images') | 42 diff_base_url='/static/generated-images') |
| 40 results_obj.get_timestamp = mock_get_timestamp | 43 results_obj.get_timestamp = mock_get_timestamp |
| 41 gm_json.WriteToFile( | 44 gm_json.WriteToFile( |
| 42 results_obj.get_packaged_results_of_type( | 45 results_obj.get_packaged_results_of_type( |
| 43 results.KEY__HEADER__RESULTS_ALL), | 46 results.KEY__HEADER__RESULTS_ALL), |
| 44 os.path.join(self._output_dir_actual, 'gm.json')) | 47 os.path.join(self.output_dir_actual, 'gm.json')) |
| 45 | 48 |
| 46 | 49 |
| 47 def mock_get_timestamp(): | 50 def mock_get_timestamp(): |
| 48 """Mock version of BaseComparisons.get_timestamp() for testing.""" | 51 """Mock version of BaseComparisons.get_timestamp() for testing.""" |
| 49 return 12345678 | 52 return 12345678 |
| 50 | 53 |
| 51 | 54 |
| 52 def main(): | 55 def main(): |
| 53 base_unittest.main(CompareConfigsTest) | 56 base_unittest.main(CompareConfigsTest) |
| 54 | 57 |
| 55 | 58 |
| 56 if __name__ == '__main__': | 59 if __name__ == '__main__': |
| 57 main() | 60 main() |
| OLD | NEW |