1 # Copyright 2016 The Chromium Authors. All rights reserved. 2 # Use of this source code is governed by a BSD-style license that can be 3 # found in the LICENSE file. 4 5 import unittest 6 import os 7 8 from perf_insights import function_handle 9 from perf_insights.mre import failure 10 from perf_insights.mre import job as job_module 11 12 from telemetry import page 13 from telemetry import story 14 from telemetry.value import translate_common_values 15 16 17 def _SingleFileFunctionHandle(filename, function_name, guid): 18 return function_handle.FunctionHandle( 19 modules_to_load=[function_handle.ModuleToLoad(filename=filename)], 20 function_name=function_name, guid=guid) 21 22 23 class TranslateCommonValuesTest(unittest.TestCase): 24 def testTranslateMreFailure(self): 25 map_function_handle = _SingleFileFunctionHandle('foo.html', 'Foo', '2') 26 reduce_function_handle = _SingleFileFunctionHandle('bar.html', 'Bar', '3') 27 job = job_module.Job(map_function_handle, reduce_function_handle, '1') 28 29 story_set = story.StorySet(base_dir=os.path.dirname(__file__)) 30 p = page.Page('http://www.foo.com/', story_set, story_set.base_dir) 31 32 f = failure.Failure(job, 'foo', '/a.json', 'MyFailure', 'failure', 'stack') 33 fv = translate_common_values.TranslateMreFailure(f, p) 34 35 self.assertIn('stack', str(fv)) 36