def testGetBenchmarkExpectationsFromParserMultipleDisablesSameBenchmark( self): raw_data = [ expectations_parser.Expectation('crbug.com/123', 'benchmark1/story', ['Win'], ['Skip']), expectations_parser.Expectation('crbug.com/234', 'benchmark2/story2', ['Win'], ['Skip']), expectations_parser.Expectation('crbug.com/345', 'benchmark1/story', ['Mac'], ['Skip']), ] e = expectations.StoryExpectations() e.GetBenchmarkExpectationsFromParser(raw_data, 'benchmark1') actual = self._ConvertTestConditionsToStrings(e.AsDict()) expected = { 'platforms': (), 'stories': { 'story': [ (['Win'], 'crbug.com/123'), (['Mac'], 'crbug.com/345'), ], } } self.assertEqual(actual, expected)
def testParseExpectationLineNoBugNoConditions(self): raw_data = '# tags: All\nb1/s1 [ Skip ]' parser = expectations_parser.TestExpectationParser(raw_data) expected_outcome = [ expectations_parser.Expectation(None, 'b1/s1', [], ['Skip']), ] for i in range(len(parser.expectations)): self.assertEqual(parser.expectations[i], expected_outcome[i])
def testGetBenchmarkExpectationsFromParserUnmappedTag(self): raw_data = [ expectations_parser.Expectation( 'crbug.com/23456', 'benchmark1/story', ['Unmapped_Tag'], ['Skip']), ] e = expectations.StoryExpectations() with self.assertRaises(KeyError): e.GetBenchmarkExpectationsFromParser(raw_data, 'benchmark1')
def testParseExpectationLineEverythingThere(self): raw_data = '# tags: Mac\ncrbug.com/23456 [ Mac ] b1/s2 [ Skip ]' parser = expectations_parser.TestExpectationParser(raw_data) expected_outcome = [ expectations_parser.Expectation('crbug.com/23456', 'b1/s2', ['Mac'], ['Skip']) ] for i in range(len(parser.expectations)): self.assertEqual(parser.expectations[i], expected_outcome[i])
def testGetBenchmarkExpectationsFromParserRefreeze(self): raw_data = [ expectations_parser.Expectation( 'crbug.com/23456', 'benchmark1/story', ['All'], ['Skip']), ] e = expectations.StoryExpectations() e.GetBenchmarkExpectationsFromParser(raw_data, 'benchmark1') with self.assertRaises(AssertionError): e.DisableStory('story', [], 'reason')
def testGetBenchmarkExpectationsFromParserDisableBenchmarkAndStory(self): raw_data = [ expectations_parser.Expectation( 'crbug.com/123', 'benchmark1/*', ['Desktop'], ['Skip']), expectations_parser.Expectation( 'crbug.com/234', 'benchmark1/story', ['Mac'], ['Skip']), ] e = expectations.StoryExpectations() e.GetBenchmarkExpectationsFromParser(raw_data, 'benchmark1') actual = self._ConvertTestConditionsToStrings(e.AsDict()) expected = { 'platforms': [('Desktop', 'crbug.com/123')], 'stories': { 'story': [ (['Mac'], 'crbug.com/234'), ], }, } self.assertEqual(actual, expected)
def testGetBenchmarkExpectationsFromParserNoBenchmarkMatch(self): raw_data = [ expectations_parser.Expectation( 'crbug.com/12345', 'benchmark2/story', ['All'], ['Skip']), ] e = expectations.StoryExpectations() e.GetBenchmarkExpectationsFromParser(raw_data, 'benchmark1') actual = e.AsDict() expected = {'platforms': [], 'stories': {}} self.assertEqual(actual, expected)
def testParseExpectationLineMultipleConditions(self): raw_data = ('# tags:All None Batman\n' 'crbug.com/123 [ All None Batman ] b1/s1 [ Skip ]') parser = expectations_parser.TestExpectationParser(raw_data) expected_outcome = [ expectations_parser.Expectation('crbug.com/123', 'b1/s1', ['All', 'None', 'Batman'], ['Skip']), ] for i in range(len(parser.expectations)): self.assertEqual(parser.expectations[i], expected_outcome[i])
def testInitWithGoodData(self): good_data = """ # This is a test expectation file. # # tags: tag1 tag2 tag3 # tags: tag4 Mac Win Debug crbug.com/12345 [ Mac ] b1/s1 [ Skip ] crbug.com/23456 [ Mac Debug ] b1/s2 [ Skip ] """ parser = expectations_parser.TestExpectationParser(good_data) tags = ['tag1', 'tag2', 'tag3', 'tag4', 'Mac', 'Win', 'Debug'] self.assertEqual(parser.tags, tags) expected_outcome = [ expectations_parser.Expectation('crbug.com/12345', 'b1/s1', ['Mac'], ['Skip']), expectations_parser.Expectation('crbug.com/23456', 'b1/s2', ['Mac', 'Debug'], ['Skip']) ] for i in range(len(parser.expectations)): self.assertEqual(parser.expectations[i], expected_outcome[i])
def testParseExpectationLineUrlInTestName(self): raw_data = ( '# tags: Mac\ncrbug.com/123 [ Mac ] b.1/http://google.com [ Skip ]' ) expected_outcomes = [ expectations_parser.Expectation('crbug.com/123', 'b.1/http://google.com', ['Mac'], ['Skip']) ] parser = expectations_parser.TestExpectationParser(raw_data) for i in range(len(parser.expectations)): self.assertEqual(parser.expectations[i], expected_outcomes[i])
def testGetBenchmarkExpectationsFromParserMultipleConditions(self): raw_data = [ expectations_parser.Expectation( 'crbug.com/23456', 'benchmark1/story', ['Win', 'Mac'], ['Skip']), ] e = expectations.StoryExpectations() e.GetBenchmarkExpectationsFromParser(raw_data, 'benchmark1') actual = self._ConvertTestConditionsToStrings(e.AsDict()) expected = { 'platforms': [], 'stories': { 'story': [(['Win+Mac'], 'crbug.com/23456')], } } self.assertEqual(actual, expected)