Home | History | Annotate | Download | only in rebaseline_server
      1 #!/usr/bin/python
      2 
      3 """
      4 Copyright 2014 Google Inc.
      5 
      6 Use of this source code is governed by a BSD-style license that can be
      7 found in the LICENSE file.
      8 
      9 Test results.py
     10 
     11 """
     12 
     13 # Imports from within Skia
     14 import base_unittest
     15 import results
     16 
     17 
     18 class ResultsTest(base_unittest.TestCase):
     19 
     20   def test_ignore_builder(self):
     21     """Test _ignore_builder()."""
     22     results_obj = results.BaseComparisons()
     23     self.assertEqual(results_obj._ignore_builder('SomethingTSAN'), True)
     24     self.assertEqual(results_obj._ignore_builder('Something-Trybot'), True)
     25     self.assertEqual(results_obj._ignore_builder(
     26         'Test-Ubuntu12-ShuttleA-GTX660-x86-Release'), False)
     27     results_obj.set_skip_builders_pattern_list(['.*TSAN.*', '.*GTX660.*'])
     28     self.assertEqual(results_obj._ignore_builder('SomethingTSAN'), True)
     29     self.assertEqual(results_obj._ignore_builder('Something-Trybot'), False)
     30     self.assertEqual(results_obj._ignore_builder(
     31         'Test-Ubuntu12-ShuttleA-GTX660-x86-Release'), True)
     32     results_obj.set_skip_builders_pattern_list(None)
     33     self.assertEqual(results_obj._ignore_builder('SomethingTSAN'), False)
     34     self.assertEqual(results_obj._ignore_builder('Something-Trybot'), False)
     35     self.assertEqual(results_obj._ignore_builder(
     36         'Test-Ubuntu12-ShuttleA-GTX660-x86-Release'), False)
     37     results_obj.set_match_builders_pattern_list(['.*TSAN'])
     38     self.assertEqual(results_obj._ignore_builder('SomethingTSAN'), False)
     39     self.assertEqual(results_obj._ignore_builder('Something-Trybot'), True)
     40     self.assertEqual(results_obj._ignore_builder(
     41         'Test-Ubuntu12-ShuttleA-GTX660-x86-Release'), True)
     42 
     43   def test_combine_subdicts_typical(self):
     44     """Test combine_subdicts() with no merge conflicts. """
     45     input_dict = {
     46       "failed" : {
     47         "changed.png" : [ "bitmap-64bitMD5", 8891695120562235492 ],
     48       },
     49       "no-comparison" : {
     50         "unchanged.png" : [ "bitmap-64bitMD5", 11092453015575919668 ],
     51       }
     52     }
     53     expected_output_dict = {
     54       "changed.png" : [ "bitmap-64bitMD5", 8891695120562235492 ],
     55       "unchanged.png" : [ "bitmap-64bitMD5", 11092453015575919668 ],
     56     }
     57     actual_output_dict = results.BaseComparisons.combine_subdicts(
     58         input_dict=input_dict)
     59     self.assertEqual(actual_output_dict, expected_output_dict)
     60 
     61   def test_combine_subdicts_with_merge_conflict(self):
     62     """Test combine_subdicts() with a merge conflict. """
     63     input_dict = {
     64       "failed" : {
     65         "changed.png" : [ "bitmap-64bitMD5", 8891695120562235492 ],
     66       },
     67       "no-comparison" : {
     68         "changed.png" : [ "bitmap-64bitMD5", 11092453015575919668 ],
     69       }
     70     }
     71     with self.assertRaises(Exception):
     72       actual_output_dict = results.BaseComparisons.combine_subdicts(
     73           input_dict=input_dict)
     74 
     75 
     76 def main():
     77   base_unittest.main(ResultsTest)
     78 
     79 
     80 if __name__ == '__main__':
     81   main()
     82