aboutsummaryrefslogtreecommitdiffstats
path: root/python/tidy.py
diff options
context:
space:
mode:
authorGreg Guthe <greg.guthe@gmail.com>2015-08-09 22:04:59 -0400
committerGreg Guthe <greg.guthe@gmail.com>2015-08-19 14:16:35 -0400
commit8b4b9ed99bb82fc6908529a0d8648bb5982e9b13 (patch)
tree8054f1daae55d00bb53a82576968deb3fd1f485d /python/tidy.py
parent5c284a546a539ddcc546fc5c00ab06568f352f11 (diff)
downloadservo-8b4b9ed99bb82fc6908529a0d8648bb5982e9b13.tar.gz
servo-8b4b9ed99bb82fc6908529a0d8648bb5982e9b13.zip
Add tidy check for unused reftest html files
Refs: https://github.com/servo/servo/issues/7078
Diffstat (limited to 'python/tidy.py')
-rw-r--r--python/tidy.py24
1 files changed, 21 insertions, 3 deletions
diff --git a/python/tidy.py b/python/tidy.py
index 20306baf1bb..5bb8469d461 100644
--- a/python/tidy.py
+++ b/python/tidy.py
@@ -352,13 +352,29 @@ def check_reftest_order(files_to_check):
def get_reftest_names(line):
tokens = line.split()
- if (len(tokens) == 3):
+ if len(tokens) == 3:
return tokens[1] + tokens[2]
- if (len(tokens) == 4):
+ if len(tokens) == 4:
return tokens[2] + tokens[3]
return None
+def get_html_file_names_from_reftest_list(reftest_dir, file_name):
+ for line in open(os.path.join(reftest_dir, file_name), "r"):
+ for token in line.split():
+ if fnmatch.fnmatch(token, '*.html'):
+ yield os.path.join(reftest_dir, token)
+
+
+def check_reftest_html_files_in_basic_list(reftest_dir):
+ basic_list_files = set(get_html_file_names_from_reftest_list(reftest_dir, "basic" + reftest_filetype))
+
+ for file_name in os.listdir(reftest_dir):
+ file_path = os.path.join(reftest_dir, file_name)
+ if fnmatch.fnmatch(file_path, '*.html') and file_path not in basic_list_files:
+ yield (file_path, "", "not found in basic.list")
+
+
def scan():
sys.path += python_dependencies
@@ -370,10 +386,12 @@ def scan():
errors = collect_errors_for_files(files_to_check, checking_functions)
reftest_files = collect_file_names(reftest_directories)
+
reftest_to_check = filter(should_check_reftest, reftest_files)
r_errors = check_reftest_order(reftest_to_check)
+ not_found_in_basic_list_errors = check_reftest_html_files_in_basic_list(reftest_directories[0])
- errors = list(itertools.chain(errors, r_errors))
+ errors = list(itertools.chain(errors, r_errors, not_found_in_basic_list_errors))
if errors:
for error in errors: