def GenerateSystemHealthCSV(file_path): system_health_stories = list(IterAllSystemHealthStories()) e = expectations.StoryExpectations() with open(path_util.GetExpectationsPath()) as fp: parser = expectations_parser.TestExpectationParser(fp.read()) benchmarks = [ 'system_health.common_desktop', 'system_health.common_mobile', 'system_health.memory_desktop', 'system_health.memory_mobile' ] for benchmark in benchmarks: e.GetBenchmarkExpectationsFromParser(parser.expectations, benchmark) disabed_platforms = PopulateExpectations([e.AsDict()['stories']]) system_health_stories.sort(key=lambda s: s.name) with open(file_path, 'w') as f: csv_writer = csv.writer(f) csv_writer.writerow( ['Story name', 'Platform', 'Description', 'Disabled Platforms']) for s in system_health_stories: p = s.SUPPORTED_PLATFORMS if len(p) == 2: p = 'all' else: p = list(p)[0] if s.name in disabed_platforms: csv_writer.writerow([ s.name, p, s.GetStoryDescription(), disabed_platforms[s.name] ]) else: csv_writer.writerow([s.name, p, s.GetStoryDescription(), " "]) return 0
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 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 testInitWithBadData(self): bad_data = """ # This is a test expectation file. # # tags: tag1 tag2 tag3 # tags: tag4 crbug.com/12345 [ Mac b1/s1 [ Skip ] """ with self.assertRaises(expectations_parser.ParseError): expectations_parser.TestExpectationParser(bad_data)
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 testTagAfterExpectationsStart(self): bad_data = """ # This is a test expectation file. # # tags: tag1 tag2 tag3 crbug.com/12345 [ tag1 ] b1/s1 [ Skip ] # tags: tag4 """ with self.assertRaises(expectations_parser.ParseError): expectations_parser.TestExpectationParser(bad_data)
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 AugmentExpectationsWithFile(self, raw_data): typ_parser = typ_expectations_parser.TestExpectations() error, _ = typ_parser.parse_tagged_list(raw_data) if not error: self._expectations = typ_expectations.StoryExpectations(self.Name()) self._expectations.GetBenchmarkExpectationsFromParser(raw_data) else: # If we can't parse the file using typ's expectation parser # then we fall back to using py_util's expectation parser # TODO(crbug.com/973936): When all expectations files have # been migrated, we will remove this if else statement and # only use typ's expectations parser. self._expectations.GetBenchmarkExpectationsFromParser( expectations_parser.TestExpectationParser( raw_data).expectations, self.Name())
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 AugmentExpectationsWithParser(self, data): parser = expectations_parser.TestExpectationParser(data) self._expectations.GetBenchmarkExpectationsFromParser( parser.expectations, self.Name())
def testParseExpectationLineBadTag(self): raw_data = '# tags: None\ncrbug.com/23456 [ Mac ] b1/s2 [ Skip ]' with self.assertRaises(expectations_parser.ParseError): expectations_parser.TestExpectationParser(raw_data)
def testParseExpectationLineNoClosingResultBracket(self): raw_data = '# tags: Mac\ncrbug.com/2345 [ Mac ] b1/s1 [ Skip' with self.assertRaises(expectations_parser.ParseError): expectations_parser.TestExpectationParser(raw_data)
def testParseExpectationLineBadConditionBracketSpacing(self): raw_data = '# tags: Mac\ncrbug.com/2345 [Mac] b1/s1 [ Skip ]' with self.assertRaises(expectations_parser.ParseError): expectations_parser.TestExpectationParser(raw_data)
def testParseExpectationLineBadResultBracket(self): raw_data = '# tags: Mac\ncrbug.com/23456 ] Mac ] b1/s2 ] Skip ]' with self.assertRaises(expectations_parser.ParseError): expectations_parser.TestExpectationParser(raw_data)