Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
123 lines
4.6 KiB
JavaScript
123 lines
4.6 KiB
JavaScript
/* global __dirname, process */
|
|
const test = require("node:test");
|
|
const assert = require("node:assert/strict");
|
|
const fs = require("node:fs");
|
|
const os = require("node:os");
|
|
const path = require("node:path");
|
|
const { execFile } = require("node:child_process");
|
|
const { promisify } = require("node:util");
|
|
|
|
const execFileAsync = promisify(execFile);
|
|
const script = path.resolve(__dirname, "patch-xterm-webgl-atlas.cjs");
|
|
|
|
/** Minimal stand-in for upstream #6055 + #5987 + #6043 (beta.291+). */
|
|
function upstreamAllFixedSource() {
|
|
return (
|
|
`for(let c=0;c<e0.length;c++){let u=e0[c];if(Ee(u.config,h))return u.ownedBy.push(i),u.atlas} ` +
|
|
`clearTexture(){if(!(this._pages[0].currentRow.x===0&&this._pages[0].currentRow.y===0)){` +
|
|
`for(let e of this._pages)e.clear();this._cacheMap.clear(),this._cacheMapCombined.clear(),` +
|
|
`this._didWarmUp=!1,this._pageLayoutVersion++} ` +
|
|
`_evictAllPages(){this._pages.length=0} maxAtlasPages ` +
|
|
`t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),` +
|
|
`t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),` +
|
|
`t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,r.pages[n].canvas),` +
|
|
`this._atlasTextures[n].version=r.pages[n].version`
|
|
);
|
|
}
|
|
|
|
function makeTmp(t) {
|
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "netcatty-xterm-webgl-patch-"));
|
|
t.after(() => fs.rmSync(dir, { recursive: true, force: true }));
|
|
return dir;
|
|
}
|
|
|
|
function writeWebglVersion(root, version) {
|
|
const packageJson = path.join(root, "node_modules/@xterm/addon-webgl/package.json");
|
|
fs.mkdirSync(path.dirname(packageJson), { recursive: true });
|
|
fs.writeFileSync(packageJson, JSON.stringify({ version }));
|
|
}
|
|
|
|
function writeRawWebglBuild(root, file, source) {
|
|
const abs = path.join(root, file);
|
|
fs.mkdirSync(path.dirname(abs), { recursive: true });
|
|
fs.writeFileSync(abs, source);
|
|
}
|
|
|
|
function writeBothBuilds(root, source) {
|
|
writeRawWebglBuild(root, "node_modules/@xterm/addon-webgl/lib/addon-webgl.mjs", source);
|
|
writeRawWebglBuild(root, "node_modules/@xterm/addon-webgl/lib/addon-webgl.js", source);
|
|
}
|
|
|
|
test("accepts packages that ship upstream #6055/#5987/#6043", async (t) => {
|
|
const root = makeTmp(t);
|
|
writeWebglVersion(root, "0.20.0-beta.291");
|
|
writeBothBuilds(root, upstreamAllFixedSource());
|
|
|
|
const { stdout, stderr } = await execFileAsync(process.execPath, [script], { cwd: root });
|
|
|
|
assert.match(stdout, /verify version=0\.20\.0-beta\.291 ok=2 missing=0/);
|
|
assert.equal(stderr, "");
|
|
// Verify mode must not rewrite node_modules.
|
|
assert.equal(
|
|
fs.readFileSync(path.join(root, "node_modules/@xterm/addon-webgl/lib/addon-webgl.mjs"), "utf8"),
|
|
upstreamAllFixedSource(),
|
|
);
|
|
});
|
|
|
|
test("fails closed when shared-atlas clear fix is missing", async (t) => {
|
|
const root = makeTmp(t);
|
|
writeWebglVersion(root, "0.20.0-beta.219");
|
|
// Capacity + no mipmap, but no pageLayoutVersion on clearTexture.
|
|
writeBothBuilds(
|
|
root,
|
|
`clearTexture(){this._pages[0].clear()} _evictAllPages(){} maxAtlasPages LINEAR`,
|
|
);
|
|
|
|
await assert.rejects(execFileAsync(process.execPath, [script], { cwd: root }), (error) => {
|
|
assert.equal(error.code, 1);
|
|
assert.match(error.stderr, /shared-atlas clear \(#6055\)/);
|
|
assert.match(error.stdout, /ok=0 missing=2/);
|
|
return true;
|
|
});
|
|
});
|
|
|
|
test("fails closed when generateMipmap is still present", async (t) => {
|
|
const root = makeTmp(t);
|
|
writeWebglVersion(root, "0.20.0-beta.291");
|
|
writeBothBuilds(
|
|
root,
|
|
`clearTexture(){this._pageLayoutVersion++} _evictAllPages(){} maxAtlasPages ` +
|
|
`gl.generateMipmap(gl.TEXTURE_2D)`,
|
|
);
|
|
|
|
await assert.rejects(execFileAsync(process.execPath, [script], { cwd: root }), (error) => {
|
|
assert.equal(error.code, 1);
|
|
assert.match(error.stderr, /no atlas mipmaps \(#5987\)/);
|
|
return true;
|
|
});
|
|
});
|
|
|
|
test("fails closed when capacity eviction is missing", async (t) => {
|
|
const root = makeTmp(t);
|
|
writeWebglVersion(root, "0.20.0-beta.291");
|
|
writeBothBuilds(root, `clearTexture(){this._pageLayoutVersion++}`);
|
|
|
|
await assert.rejects(execFileAsync(process.execPath, [script], { cwd: root }), (error) => {
|
|
assert.equal(error.code, 1);
|
|
assert.match(error.stderr, /atlas capacity eviction \(#6043\)/);
|
|
return true;
|
|
});
|
|
});
|
|
|
|
test("fails closed when addon builds are missing", async (t) => {
|
|
const root = makeTmp(t);
|
|
writeWebglVersion(root, "0.20.0-beta.291");
|
|
|
|
await assert.rejects(execFileAsync(process.execPath, [script], { cwd: root }), (error) => {
|
|
assert.equal(error.code, 1);
|
|
assert.match(error.stderr, /not found/);
|
|
assert.match(error.stdout, /ok=0 missing=2/);
|
|
return true;
|
|
});
|
|
});
|