def GetCurrentAndPreviousResults(debug, test_group_file_location, test_group_name, result_directory_location): """Get current and the latest previous analyzer results. In debug mode, they are read from predefined files. In non-debug mode, current analyzer results are dynamically obtained from Webkit SVN and the latest previous result is read from the corresponding file. Args: debug: please refer to |options|. test_group_file_location: please refer to |options|. test_group_name: please refer to |options|. result_directory_location: please refer to |options|. Returns: a tuple of the following: prev_time: the previous time string that is compared against. prev_analyzer_result_map: previous analyzer result map. Please refer to layouttest_analyzer_helpers.AnalyzerResultMap. analyzer_result_map: current analyzer result map. Please refer to layouttest_analyzer_helpers.AnalyzerResultMap. """ if not debug: if not test_group_file_location and not test_group_name: print( 'Either --test-group-name or --test_group_file_location must be ' 'specified. Exiting this program.') sys.exit() filter_names = [] if test_group_file_location and os.path.exists( test_group_file_location): filter_names = layouttests.LayoutTests.GetLayoutTestNamesFromCSV( test_group_file_location) parent_location_list = ( layouttests.LayoutTests.GetParentDirectoryList(filter_names)) recursion = False else: # When test group CSV file is not specified, test group name # (e.g., 'media') is used for getting layout tests. # The tests are in # http://svn.webkit.org/repository/webkit/trunk/LayoutTests/media # Filtering is not set so all HTML files are considered as valid tests. # Also, we look for the tests recursively. if not test_group_file_location or ( not os.path.exists(test_group_file_location)): print( 'Warning: CSV file (%s) does not exist. So it is ignored and ' '%s is used for obtaining test names') % ( test_group_file_location, test_group_name) if not test_group_name.endswith('/'): test_group_name += '/' parent_location_list = [test_group_name] filter_names = None recursion = True layouttests_object = layouttests.LayoutTests( parent_location_list=parent_location_list, recursion=recursion, filter_names=filter_names) analyzer_result_map = layouttest_analyzer_helpers.AnalyzerResultMap( layouttests_object.JoinWithTestExpectation(TestExpectations())) result = layouttest_analyzer_helpers.FindLatestResult( result_directory_location) if result: (prev_time, prev_analyzer_result_map) = result else: prev_time = None prev_analyzer_result_map = None else: analyzer_result_map = layouttest_analyzer_helpers.AnalyzerResultMap.Load( CURRENT_RESULT_FILE_FOR_DEBUG) prev_time = PREV_TIME_FOR_DEBUG prev_analyzer_result_map = ( layouttest_analyzer_helpers.AnalyzerResultMap.Load( os.path.join(DEFAULT_RESULT_DIR, prev_time))) return (prev_time, prev_analyzer_result_map, analyzer_result_map)
def testFindLatestResultWithNoData(self): self.assertFalse( layouttest_analyzer_helpers.FindLatestResult('test_data'))