Commit 65101fc8 authored by Weilun Shi's avatar Weilun Shi Committed by Commit Bot

Normalize both histograms paths before comparing

Besides normalizing the histograms paths in the index file, we also need
to normalize all paths in the |histogram_paths.HISTOGRAMS_XMLS_RELATIVE|
because it contains a hardcode path.

Change-Id: I820de86efc7b816c0dba52e42838cbc55b5319c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2386837
Commit-Queue: Weilun Shi <sweilun@chromium.org>
Auto-Submit: Weilun Shi <sweilun@chromium.org>
Reviewed-by: default avatarSteven Holte <holte@chromium.org>
Cr-Commit-Position: refs/heads/master@{#803406}
parent d5136ab4
...@@ -30,7 +30,7 @@ def get_names(xml_files): ...@@ -30,7 +30,7 @@ def get_names(xml_files):
doc = merge_xml.MergeFiles(files=xml_files) doc = merge_xml.MergeFiles(files=xml_files)
histograms, had_errors = extract_histograms.ExtractHistogramsFromDom(doc) histograms, had_errors = extract_histograms.ExtractHistogramsFromDom(doc)
if had_errors: if had_errors:
raise Error("Error parsing inputs.") raise ValueError("Error parsing inputs.")
return extract_histograms.ExtractNames(histograms) return extract_histograms.ExtractNames(histograms)
...@@ -61,8 +61,10 @@ def get_diff(revision): ...@@ -61,8 +61,10 @@ def get_diff(revision):
current_histogram_names = set(get_names(histogram_xml_files())) current_histogram_names = set(get_names(histogram_xml_files()))
prev_histogram_names = set( prev_histogram_names = set(
get_names( get_names([
[get_file_at_revision(p) for p in histogram_paths.ALL_XMLS_RELATIVE])) get_file_at_revision(os.path.normpath(p))
for p in histogram_paths.ALL_XMLS_RELATIVE
]))
added_names = sorted(list(current_histogram_names - prev_histogram_names)) added_names = sorted(list(current_histogram_names - prev_histogram_names))
removed_names = sorted(list(prev_histogram_names - current_histogram_names)) removed_names = sorted(list(prev_histogram_names - current_histogram_names))
......
...@@ -18,7 +18,10 @@ def main(): ...@@ -18,7 +18,10 @@ def main():
exit_code = 0 exit_code = 0
with open(histogram_paths.HISTOGRAMS_INDEX, 'r') as f: with open(histogram_paths.HISTOGRAMS_INDEX, 'r') as f:
histograms_paths = [os.path.normpath(line.strip()) for line in f] histograms_paths = [os.path.normpath(line.strip()) for line in f]
if histograms_paths != histogram_paths.HISTOGRAMS_XMLS_RELATIVE: new_histograms_paths = [
os.path.normpath(p) for p in histogram_paths.HISTOGRAMS_XMLS_RELATIVE
]
if histograms_paths != new_histograms_paths:
exit_code = 1 exit_code = 1
logging.error( logging.error(
'histograms_index.txt is not up-to-date. Please run ' 'histograms_index.txt is not up-to-date. Please run '
...@@ -28,4 +31,4 @@ def main(): ...@@ -28,4 +31,4 @@ def main():
if __name__ == '__main__': if __name__ == '__main__':
main() main()
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment