mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-07 21:17:07 +09:00
Meta: Make CI enforce doctype in test cases
This currently does not enforce it on Layout tests, even though it seems most necessary there. This is to speed up the review on this PR due to an excessive amount of layout tests that would need rebaselining if DOCTYPEs were added to them.
This commit is contained in:
parent
0b0dd7d4a5
commit
528af90cd4
Notes:
github-actions[bot]
2025-03-20 10:51:45 +00:00
Author: https://github.com/Psychpsyo
Commit: 528af90cd4
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3456
Reviewed-by: https://github.com/gmta ✅
2 changed files with 48 additions and 0 deletions
47
Meta/check-html-doctype.py
Executable file
47
Meta/check-html-doctype.py
Executable file
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
# FIXME: Include Layout tests in general.
|
||||
# They are currently deferred to a later PR to make review easier for now.
|
||||
RE_RELEVANT_FILE = re.compile('^Tests/LibWeb/(Ref|Screenshot|Text)/(.(?!wpt-import/))*\\.html$')
|
||||
RE_DOCTYPE = re.compile('^<!doctype .*>', re.IGNORECASE)
|
||||
|
||||
|
||||
def should_check_file(filename):
|
||||
return RE_RELEVANT_FILE.match(filename) is not None
|
||||
|
||||
|
||||
def find_files_here_or_argv():
|
||||
if len(sys.argv) > 1:
|
||||
raw_list = sys.argv[1:]
|
||||
else:
|
||||
process = subprocess.run(["git", "ls-files"], check=True, capture_output=True)
|
||||
raw_list = process.stdout.decode().strip('\n').split('\n')
|
||||
|
||||
return filter(should_check_file, raw_list)
|
||||
|
||||
|
||||
def run():
|
||||
files_with_missing_doctypes = []
|
||||
|
||||
for filename in find_files_here_or_argv():
|
||||
with open(filename, 'r') as file:
|
||||
if not RE_DOCTYPE.search(file.readline()):
|
||||
files_with_missing_doctypes.append(filename)
|
||||
|
||||
if files_with_missing_doctypes:
|
||||
print('The following HTML files should include a doctype declaration at the start of the file but don\'t:\n' +
|
||||
'You should add <!DOCTYPE html> to the very beginning of these files, except if they absolutely need ' +
|
||||
'to run in quirks mode. In that case, you can clearly indicate so with a bogus doctype that says ' +
|
||||
'"quirks" instead of "html".\n',
|
||||
' '.join(files_with_missing_doctypes))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
os.chdir(os.path.dirname(__file__) + "/..")
|
||||
run()
|
|
@ -15,6 +15,7 @@ set +e
|
|||
|
||||
for cmd in \
|
||||
Meta/check-debug-flags.sh \
|
||||
Meta/check-html-doctype.py \
|
||||
Meta/check-idl-files.py \
|
||||
Meta/check-newlines-at-eof.py \
|
||||
Meta/check-png-sizes.sh \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue