Skip to content

Commit 0047d2c

Browse files
test: regenerate conformance golden data and add new test cases
Upgrade @xterm/headless to 6.1.0-beta.195 to capture upstream behavioral changes (soft hyphen ignored, CSI ^ scroll down alias, XTVERSION response, cursor Y clamping after resize). Add four new conformance test cases: - csi_caret_scroll_down: CSI ^ as scroll down alias - xtversion_response: XTVERSION (CSI > q) response - soft_hyphen_ignored: U+00AD soft hyphen is dropped - cursor_clamp_resize_shrink: cursor Y clamped after resize to fewer rows Handle XTVERSION response comparison by verifying DCS envelope format rather than exact string, since the Go port identifies itself differently. Fixes #6 Co-authored-by: Ona <no-reply@ona.com>
1 parent 5775050 commit 0047d2c

5 files changed

Lines changed: 201 additions & 7 deletions

File tree

conformance/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
"generate": "node generate.mjs"
77
},
88
"dependencies": {
9-
"@xterm/headless": "^6.0.0"
9+
"@xterm/headless": "6.1.0-beta.195"
1010
}
1111
}

conformance/testcases.mjs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,4 +340,34 @@ export const testCases = [
340340
cols: 20, rows: 5,
341341
input: "\x1b(0lqqqqk\r\nx x\r\nmqqqqj\x1b(B",
342342
},
343+
344+
// --- CSI ^ scroll down alias ---
345+
{
346+
name: "csi_caret_scroll_down",
347+
cols: 20, rows: 5,
348+
input: "AAA\r\nBBB\r\nCCC\r\nDDD\r\nEEE\x1b[2^",
349+
},
350+
351+
// --- XTVERSION response ---
352+
{
353+
name: "xtversion_response",
354+
cols: 80, rows: 24,
355+
input: "\x1b[>q",
356+
captureResponse: true,
357+
},
358+
359+
// --- Soft hyphen ignored ---
360+
{
361+
name: "soft_hyphen_ignored",
362+
cols: 80, rows: 24,
363+
input: "AB\u00ADCD",
364+
},
365+
366+
// --- Cursor clamp after resize to fewer rows ---
367+
{
368+
name: "cursor_clamp_resize_shrink",
369+
cols: 20, rows: 10,
370+
input: "\x1b[9;1H",
371+
resize: { cols: 20, rows: 3 },
372+
},
343373
];

conformance/testdata/golden.json

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4870,5 +4870,160 @@
48704870
],
48714871
"bufferType": "normal"
48724872
}
4873+
},
4874+
{
4875+
"name": "csi_caret_scroll_down",
4876+
"cols": 20,
4877+
"rows": 5,
4878+
"initialCols": 20,
4879+
"initialRows": 5,
4880+
"input": "AAA\r\nBBB\r\nCCC\r\nDDD\r\nEEE\u001b[2^",
4881+
"expected": {
4882+
"cursor": {
4883+
"x": 3,
4884+
"y": 4
4885+
},
4886+
"lines": [
4887+
{
4888+
"text": "",
4889+
"isWrapped": false
4890+
},
4891+
{
4892+
"text": "",
4893+
"isWrapped": false
4894+
},
4895+
{
4896+
"text": "AAA",
4897+
"isWrapped": false,
4898+
"cells": [
4899+
{
4900+
"chars": "A",
4901+
"width": 1
4902+
},
4903+
{
4904+
"chars": "A",
4905+
"width": 1
4906+
},
4907+
{
4908+
"chars": "A",
4909+
"width": 1
4910+
}
4911+
]
4912+
},
4913+
{
4914+
"text": "BBB",
4915+
"isWrapped": false,
4916+
"cells": [
4917+
{
4918+
"chars": "B",
4919+
"width": 1
4920+
},
4921+
{
4922+
"chars": "B",
4923+
"width": 1
4924+
},
4925+
{
4926+
"chars": "B",
4927+
"width": 1
4928+
}
4929+
]
4930+
},
4931+
{
4932+
"text": "CCC",
4933+
"isWrapped": false,
4934+
"cells": [
4935+
{
4936+
"chars": "C",
4937+
"width": 1
4938+
},
4939+
{
4940+
"chars": "C",
4941+
"width": 1
4942+
},
4943+
{
4944+
"chars": "C",
4945+
"width": 1
4946+
}
4947+
]
4948+
}
4949+
],
4950+
"bufferType": "normal"
4951+
}
4952+
},
4953+
{
4954+
"name": "xtversion_response",
4955+
"cols": 80,
4956+
"rows": 24,
4957+
"initialCols": 80,
4958+
"initialRows": 24,
4959+
"input": "\u001b[>q",
4960+
"expected": {
4961+
"cursor": {
4962+
"x": 0,
4963+
"y": 0
4964+
},
4965+
"lines": [],
4966+
"bufferType": "normal"
4967+
},
4968+
"expectedResponse": "\u001bP>|xterm.js(6.0.0)\u001b\\"
4969+
},
4970+
{
4971+
"name": "soft_hyphen_ignored",
4972+
"cols": 80,
4973+
"rows": 24,
4974+
"initialCols": 80,
4975+
"initialRows": 24,
4976+
"input": "AB­CD",
4977+
"expected": {
4978+
"cursor": {
4979+
"x": 4,
4980+
"y": 0
4981+
},
4982+
"lines": [
4983+
{
4984+
"text": "ABCD",
4985+
"isWrapped": false,
4986+
"cells": [
4987+
{
4988+
"chars": "A",
4989+
"width": 1
4990+
},
4991+
{
4992+
"chars": "B",
4993+
"width": 1
4994+
},
4995+
{
4996+
"chars": "C",
4997+
"width": 1
4998+
},
4999+
{
5000+
"chars": "D",
5001+
"width": 1
5002+
}
5003+
]
5004+
}
5005+
],
5006+
"bufferType": "normal"
5007+
}
5008+
},
5009+
{
5010+
"name": "cursor_clamp_resize_shrink",
5011+
"cols": 20,
5012+
"rows": 3,
5013+
"initialCols": 20,
5014+
"initialRows": 10,
5015+
"input": "\u001b[9;1H",
5016+
"expected": {
5017+
"cursor": {
5018+
"x": 0,
5019+
"y": 2
5020+
},
5021+
"lines": [],
5022+
"bufferType": "normal"
5023+
},
5024+
"resize": {
5025+
"cols": 20,
5026+
"rows": 3
5027+
}
48735028
}
48745029
]

conformance/yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# yarn lockfile v1
33

44

5-
"@xterm/headless@^6.0.0":
6-
version "6.0.0"
7-
resolved "https://registry.yarnpkg.com/@xterm/headless/-/headless-6.0.0.tgz#a839dee397c49834bb220fa5951d60f4b7f0aa11"
8-
integrity sha512-5Yj1QINYCyzrZtf8OFIHi47iQtI+0qYFPHmouEfG8dHNxbZ9Tb9YGSuLcsEwj9Z+OL75GJqPyJbyoFer80a2Hw==
5+
"@xterm/headless@6.1.0-beta.195":
6+
version "6.1.0-beta.195"
7+
resolved "https://registry.yarnpkg.com/@xterm/headless/-/headless-6.1.0-beta.195.tgz#a83df9a8c4bfe740a36461e5f3b9fd04256d4455"
8+
integrity sha512-sUOeZ08431n5wx6ukrQ96eXEGN7z8swUfvHkl4nAEqpYEMxS/ua+E6v5PGT6fpQFbOt2R3zIm6LDIfy9GX24mA==

conformance_test.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"encoding/json"
55
"fmt"
66
"os"
7+
"strings"
78
"testing"
89

910
"github.com/google/go-cmp/cmp"
@@ -281,9 +282,17 @@ func TestConformance(t *testing.T) {
281282
t.Errorf("scrollback mismatch (-xterm.js +go):\n%s", diff)
282283
}
283284

284-
// Compare response (for DA1, DSR tests)
285+
// Compare response (for DA1, DSR tests).
286+
// XTVERSION responses differ by design: xterm.js reports its own
287+
// name/version while the Go port reports "xterm-go". We only verify
288+
// the DCS envelope format for XTVERSION.
285289
if tc.ExpectedResponse != "" {
286-
if diff := cmp.Diff(tc.ExpectedResponse, gotResponse); diff != "" {
290+
if strings.HasPrefix(tc.ExpectedResponse, "\x1bP>|") {
291+
// XTVERSION: verify DCS >| ... ST format
292+
if !strings.HasPrefix(gotResponse, "\x1bP>|") || !strings.HasSuffix(gotResponse, "\x1b\\") {
293+
t.Errorf("xtversion response format mismatch: got %q, want DCS >|...<ST> envelope", gotResponse)
294+
}
295+
} else if diff := cmp.Diff(tc.ExpectedResponse, gotResponse); diff != "" {
287296
t.Errorf("response mismatch (-xterm.js +go):\n%s", diff)
288297
}
289298
}

0 commit comments

Comments
 (0)