Guard staged prefix stripping

This commit is contained in:
2026-06-13 14:32:29 +08:00
parent dfc343b6e7
commit 1d40980fed
3 changed files with 77 additions and 2 deletions

View File

@@ -4694,10 +4694,18 @@
}
}
function stripInterpIniContextStagingPrefix(name, wasmPath) {
const prefix = `/work/browser-interp/${name}/`;
if (!wasmPath.startsWith(prefix)) {
throw new Error(`browser_interp_${name}_staging_prefix: path drift ${wasmPath}`);
}
return wasmPath.slice(prefix.length);
}
function assertInterpIniContextNgcStaging(name, files, plan) {
const stagedNgcFiles = plan.files
.filter((file) => file.sourceRel.endsWith(".ngc"))
.map((file) => file.wasmPath.replace(`/work/browser-interp/${name}/`, ""))
.map((file) => stripInterpIniContextStagingPrefix(name, file.wasmPath))
.sort();
if (stagedNgcFiles.join(",") !== files.join(",")) {
throw new Error(`browser_interp_${name}_staging_manifest: list drift`);

View File

@@ -297,11 +297,21 @@ function assertInterpRegressionFileStaging(name, filename, wasmPath) {
);
}
function stripInterpIniContextStagingPrefix(name, wasmPath) {
const prefix = `/work/interp/${name}/`;
assert.equal(
wasmPath.startsWith(prefix),
true,
`interp ${name} staging prefix drift: ${wasmPath}`,
);
return wasmPath.slice(prefix.length);
}
function assertInterpIniContextNgcStaging(name, files, plan) {
assert.deepEqual(
plan.files
.filter((file) => file.sourceRel.endsWith(".ngc"))
.map((file) => file.wasmPath.replace(`/work/interp/${name}/`, ""))
.map((file) => stripInterpIniContextStagingPrefix(name, file.wasmPath))
.sort(),
files,
`interp ${name} staging manifest drift`,