Skip to content

Commit

Permalink
Bug 1938128 - test262-export: improve handling of unsupported feature…
Browse files Browse the repository at this point in the history
…s; r=dminor

And exclude two more early-stage proposals.

This reorganizes the code a bit so that the computation of the front matter is separated from inserting it into the exported source; this also makes it easier to skip tests based on the final feature flags rather than only on the ones extracted from the reftest skip-if line.

Differential Revision: https://phabricator.services.mozilla.com/D232525
  • Loading branch information
Ms2ger committed Jan 7, 2025
1 parent 9fc5e56 commit a86159d
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions js/src/tests/test262-export.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ def skipTest(source: bytes) -> Optional[bytes]:

MODELINE_PATTERN = re.compile(rb"/(/|\*) -\*- .* -\*-( \*/)?[\r\n]+")

UNSUPPORTED_FEATURES = [
"async-iterator-helpers",
"Iterator.range",
"record-tuple",
]


def convertTestFile(source: bytes, includes: "list[str]") -> Optional[bytes]:
"""
Expand All @@ -131,16 +137,22 @@ def convertTestFile(source: bytes, includes: "list[str]") -> Optional[bytes]:

# Extract the reftest data from the source
source, reftest = parseHeader(source)
if reftest and "record-tuple" in reftest.features:
return None

# Add copyright, if needed.
copyright, source = insertCopyrightLines(source)

# Extract the frontmatter data from the source
frontmatter, source = extractMeta(source)

source = updateMeta(source, reftest, frontmatter, includes)
source, addincludes = translateHelpers(source)
includes = includes + addincludes

meta = computeMeta(source, reftest, frontmatter, includes)

if "features" in meta and any(f in UNSUPPORTED_FEATURES for f in meta["features"]):
return None

source = insertMeta(source, meta)

source = convertReportCompare(source)

Expand Down Expand Up @@ -170,7 +182,7 @@ def featureFromReftest(reftest: str) -> Optional[str]:
if reftest == "Iterator":
return "iterator-helpers"
if reftest == "AsyncIterator":
return "async-iteration"
return "async-iterator-helpers"
if reftest == "Temporal":
return "Temporal"
if reftest in ("Intl", "addIntlExtras", "ReadableStream"):
Expand Down Expand Up @@ -360,7 +372,7 @@ def extractMeta(source: bytes) -> "tuple[dict[str, Any], bytes]":
return result, source[:start] + source[end:]


## updateMeta
## computeMeta


def translateHelpers(source: bytes) -> "tuple[bytes, list[str]]":
Expand Down Expand Up @@ -545,12 +557,12 @@ def insertMeta(source: bytes, frontmatter: "dict[str, Any]") -> bytes:
return source


def updateMeta(
def computeMeta(
source: bytes,
reftest: "Optional[ReftestEntry]",
frontmatter: "dict[str, Any]",
includes: "list[str]",
) -> bytes:
) -> "dict[str, Any]":
"""
Captures the reftest meta and a pre-existing meta if any and merge them
into a single dict.
Expand All @@ -562,16 +574,11 @@ def updateMeta(
if b"createIsHTMLDDA" in source:
frontmatter.setdefault("features", []).append("IsHTMLDDA")

source, addincludes = translateHelpers(source)
includes = includes + addincludes

# Merge the reftest and frontmatter
merged = mergeMeta(reftest, frontmatter, includes)

# Cleanup the metadata
properData = cleanupMeta(merged)

return insertMeta(source, properData)
return cleanupMeta(merged)


## convertReportCompare
Expand Down

0 comments on commit a86159d

Please sign in to comment.