1 # Copyright (c) 2013 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.
7 from trace_viewer import trace_viewer_project
10 FILE_GROUPS = ["tracing_css_files",
11 "tracing_js_html_files",
14 def GetFileGroupFromFileName(filename):
15 extension = os.path.splitext(filename)[1]
17 '.css': 'tracing_css_files',
18 '.html': 'tracing_js_html_files',
19 '.js': 'tracing_js_html_files',
20 '.png': 'tracing_img_files'
23 def CheckListedFilesSorted(src_file, group_name, listed_files):
24 sorted_files = sorted(listed_files)
25 if sorted_files != listed_files:
27 for i in range(len(listed_files)):
28 if listed_files[i] != sorted_files[i]:
29 mismatch = listed_files[i]
31 what_is = ' ' + '\n '.join(listed_files)
32 what_should_be = ' ' + '\n '.join(sorted_files)
33 return '''In group {0} from file {1}, filenames aren't sorted.
42 {4}\n\n'''.format(group_name, src_file, mismatch, what_is, what_should_be)
47 p = trace_viewer_project.TraceViewerProject()
48 m = p.loader.LoadModule(module_name='about_tracing')
49 absolute_filenames = m.GetAllDependentFilenamesRecursive(
50 include_raw_scripts=False)
52 return list(set([os.path.relpath(f, p.trace_viewer_path)
53 for f in absolute_filenames]))
55 def CheckCommon(file_name, listed_files):
56 project = trace_viewer_project.TraceViewerProject()
57 build_dir = os.path.join(project.src_path, 'build')
59 known_files = GetKnownFiles()
60 u = set(listed_files).union(set(known_files))
61 i = set(listed_files).intersection(set(known_files))
67 error = 'Entries in ' + file_name + ' do not match files on disk:\n'
68 in_file_only = list(set(listed_files) - set(known_files))
69 in_known_only = list(set(known_files) - set(listed_files))
71 if len(in_file_only) > 0:
72 error += ' In file only:\n ' + '\n '.join(sorted(in_file_only))
73 if len(in_known_only) > 0:
74 if len(in_file_only) > 0:
76 error += ' On disk only:\n ' + '\n '.join(sorted(in_known_only))