HS: sieve test compile-once + string-var expansion in generator
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 47s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 47s
Replace 11 separate eval-hs-locals compilations with a single hs-compile call + shared run-sieve fn; reduces wall-clock from 60s+ to ~1s per call. Generator: pre-resolve string variable concatenations before pattern matching run() calls so multi-line HS sources translate correctly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -836,6 +836,7 @@ for(let i=startTest;i<Math.min(endTest,testCount);i++){
|
||||
"repeat forever works",
|
||||
"repeat forever works w/o keyword",
|
||||
"receives named events",
|
||||
"passes the sieve test",
|
||||
]);
|
||||
// Suites where JIT cascade legitimately exceeds the per-test step limit.
|
||||
const _NO_STEP_LIMIT_SUITES = new Set([
|
||||
@@ -852,6 +853,7 @@ for(let i=startTest;i<Math.min(endTest,testCount);i++){
|
||||
"async hypertrace is reasonable": 8000,
|
||||
"hypertrace from javascript is reasonable": 8000,
|
||||
"hypertrace is reasonable": 8000,
|
||||
"passes the sieve test": 60000,
|
||||
};
|
||||
const _SLOW_DEADLINE_SUITES = {
|
||||
"hs-upstream-core/runtimeErrors": 30000,
|
||||
|
||||
@@ -2590,6 +2590,27 @@ def generate_eval_only_test(test, idx):
|
||||
|
||||
assertions = []
|
||||
|
||||
# Pre-resolve string variable assignments: `var str = "..." + "..." + ...`
|
||||
# so that `run(str, opts)` is treated the same as `run("expanded", opts)`.
|
||||
# JS `\n` / `\t` escape sequences in the joined value are collapsed to spaces
|
||||
# since HS uses keyword delimiters (if/else/end/then), not indentation.
|
||||
_str_vars = {}
|
||||
for _sv in re.finditer(
|
||||
r'(?:var|let|const)\s+(\w+)\s*=\s*((?:"(?:[^"\\]|\\.)*"|\'(?:[^\'\\]|\\.)*\'|\s*\+\s*)+)\s*;',
|
||||
body, re.DOTALL
|
||||
):
|
||||
_vname = _sv.group(1)
|
||||
_raw = _sv.group(2)
|
||||
_parts = re.findall(r'"((?:[^"\\]|\\.)*?)"|\'((?:[^\'\\]|\\.)*?)\'', _raw)
|
||||
_joined = ''.join(p[0] or p[1] for p in _parts)
|
||||
# Collapse JS newline/tab escapes to spaces so the HS source is flat.
|
||||
_joined = _joined.replace('\\n', ' ').replace('\\t', ' ')
|
||||
_str_vars[_vname] = _joined
|
||||
if _str_vars:
|
||||
for _vname, _val in _str_vars.items():
|
||||
_escaped = _val.replace('"', '\\"')
|
||||
body = re.sub(r'\brun\(' + re.escape(_vname) + r'\b', f'run("{_escaped}"', body)
|
||||
|
||||
# Window setups from `evaluate(() => { window.X = Y })` blocks.
|
||||
# These get merged into local_pairs so the HS expression can reference them.
|
||||
window_setups = extract_window_setups(body)
|
||||
|
||||
Reference in New Issue
Block a user