js-on-sx: runner inlines small upstream harness includes per-test (allowlisted)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 45s

This commit is contained in:
2026-05-10 17:30:23 +00:00
parent 01d0e97706
commit 7c229eb321
2 changed files with 39 additions and 3 deletions

View File

@@ -1060,11 +1060,45 @@ def _worker_run(args):
# ---------------------------------------------------------------------------
_HARNESS_INCLUDE_CACHE: dict = {}
# Only inline these small harness files per-test. Large ones like propertyHelper.js
# multiply js-eval/JIT cost by ~5-10x and push tests over the per-test timeout.
_INLINE_INCLUDES = {"nans.js", "sta.js", "byteConversionValues.js", "compareArray.js"}
def _load_harness_include(name: str) -> str:
"""Read an upstream harness include file (e.g. nans.js).
Returns empty string if the file isn't present.
"""
if name in _HARNESS_INCLUDE_CACHE:
return _HARNESS_INCLUDE_CACHE[name]
path = HARNESS_DIR / name
try:
src = path.read_text()
except OSError:
src = ""
_HARNESS_INCLUDE_CACHE[name] = src
return src
def assemble_source(t):
"""Return JS source to feed to js-eval. Harness is preloaded, so we only
append the test source (plus negative-test prep if needed).
append the test source (plus a small allowlist of per-test includes).
"""
return t.src
if not getattr(t.fm, "includes", None):
return t.src
parts = []
for inc in t.fm.includes:
if inc not in _INLINE_INCLUDES:
continue
chunk = _load_harness_include(inc)
if chunk:
parts.append(chunk)
if not parts:
return t.src
parts.append(t.src)
return "\n".join(parts)
def aggregate(results):
@@ -1242,7 +1276,7 @@ def main(argv):
shards = [[] for _ in range(n_workers)]
for i, t in enumerate(tests):
shards[i % n_workers].append(
(t.rel, t.category, t.src, t.fm.negative_phase, t.fm.negative_type)
(t.rel, t.category, assemble_source(t), t.fm.negative_phase, t.fm.negative_type)
)
t_run_start = time.monotonic()