Meta: Validate proper formatting for FIXMEs and AD-HOCs

This commit is contained in:
Psychpsyo 2025-11-13 15:12:21 +01:00 committed by Ali Mohammad Pur
parent 100f37995f
commit 6951ef4ee3
Notes: github-actions[bot] 2025-11-14 08:18:28 +00:00
2 changed files with 14 additions and 3 deletions

View file

@ -1259,8 +1259,8 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::process_media_data(Function<void(Str
if (enable == TriState::True) if (enable == TriState::True)
audio_track->set_enabled(true); audio_track->set_enabled(true);
// AD-HOC(ish): According to https://dev.w3.org/html5/html-sourcing-inband-tracks/, kind should be set according to format, and the following criteria within // NB: According to https://dev.w3.org/html5/html-sourcing-inband-tracks/, kind should be set according to format, and the following criteria within
// the specified formats. // the specified formats.
// WebM: // WebM:
// - "main": the FlagDefault element is set on the track // - "main": the FlagDefault element is set on the track
// - "translation": not first audio (video) track // - "translation": not first audio (video) track
@ -1318,7 +1318,7 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::process_media_data(Function<void(Str
if (enable == TriState::True) if (enable == TriState::True)
video_track->set_selected(true); video_track->set_selected(true);
// AD-HOC(ish): See the comment regarding AudioTrack.kind above with regard to https://dev.w3.org/html5/html-sourcing-inband-tracks/. // NB: See the comment regarding AudioTrack.kind above with regard to https://dev.w3.org/html5/html-sourcing-inband-tracks/.
video_track->set_kind(enable == TriState::True ? "main"_utf16 : "translation"_utf16); video_track->set_kind(enable == TriState::True ? "main"_utf16 : "translation"_utf16);
// 7. Fire an event named addtrack at this VideoTrackList object, using TrackEvent, with the track attribute initialized to the new VideoTrack object. // 7. Fire an event named addtrack at this VideoTrackList object, using TrackEvent, with the track attribute initialized to the new VideoTrack object.

View file

@ -57,6 +57,9 @@ LOCAL_INCLUDE_SUFFIX_EXCLUDES = [
# We check for and disallow any comments linking to the single-page HTML spec because it takes a long time to load. # We check for and disallow any comments linking to the single-page HTML spec because it takes a long time to load.
SINGLE_PAGE_HTML_SPEC_LINK = re.compile("//.*https://html\\.spec\\.whatwg\\.org/#") SINGLE_PAGE_HTML_SPEC_LINK = re.compile("//.*https://html\\.spec\\.whatwg\\.org/#")
# We similarily check and disallow AD-HOCs and FIXMEs that aren't followed by a colon.
INVALID_AD_HOC_OR_FIXME = re.compile(r'^(?:[\s\d./\-(*]+(?:AD-HOC|FIXME)[^:]|.*"FIXME[^:"]).*$', re.MULTILINE)
def should_check_file(filename): def should_check_file(filename):
if not filename.endswith(".cpp") and not filename.endswith(".h"): if not filename.endswith(".cpp") and not filename.endswith(".h"):
@ -97,6 +100,7 @@ def run():
errors_include_missing_local = [] errors_include_missing_local = []
errors_include_bad_complex = [] errors_include_bad_complex = []
errors_single_page_html_spec = [] errors_single_page_html_spec = []
errors_invalid_ad_hoc_or_fixme = {}
for filename in find_files_here_or_argv(): for filename in find_files_here_or_argv():
with open(filename, mode="r", encoding="utf-8") as f: with open(filename, mode="r", encoding="utf-8") as f:
@ -146,6 +150,9 @@ def run():
errors_include_missing_local.append(filename) errors_include_missing_local.append(filename)
if SINGLE_PAGE_HTML_SPEC_LINK.search(file_content): if SINGLE_PAGE_HTML_SPEC_LINK.search(file_content):
errors_single_page_html_spec.append(filename) errors_single_page_html_spec.append(filename)
invalid_ad_hocs_or_fixmes = INVALID_AD_HOC_OR_FIXME.findall(file_content)
if invalid_ad_hocs_or_fixmes:
errors_invalid_ad_hoc_or_fixme[filename] = invalid_ad_hocs_or_fixmes
have_errors = False have_errors = False
if errors_license: if errors_license:
@ -184,6 +191,10 @@ def run():
if errors_single_page_html_spec: if errors_single_page_html_spec:
print("Files with links to the single-page HTML spec:", " ".join(errors_single_page_html_spec)) print("Files with links to the single-page HTML spec:", " ".join(errors_single_page_html_spec))
have_errors = True have_errors = True
if errors_invalid_ad_hoc_or_fixme:
for file in errors_invalid_ad_hoc_or_fixme:
print(f"{file} contains invalid AD-HOC or FIXME usages:", "".join(errors_invalid_ad_hoc_or_fixme[file]))
have_errors = True
if have_errors: if have_errors:
sys.exit(1) sys.exit(1)