]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: add SCS escape sequence test for column
authorKarel Zak <kzak@redhat.com>
Wed, 18 Mar 2026 12:04:08 +0000 (13:04 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 18 Mar 2026 12:04:08 +0000 (13:04 +0100)
Convert the ansiescape test to use subtests and add a test
for SCS (Select Character Set) escape sequences to verify
they are properly skipped in width calculation.

Addresses: https://github.com/util-linux/util-linux/issues/4121
Signed-off-by: Karel Zak <kzak@redhat.com>
tests/expected/column/ansiescape-scs [new file with mode: 0644]
tests/expected/column/ansiescape-sgr [moved from tests/expected/column/ansiescape with 100% similarity]
tests/ts/column/ansiescape

diff --git a/tests/expected/column/ansiescape-scs b/tests/expected/column/ansiescape-scs
new file mode 100644 (file)
index 0000000..4f3a4ea
--- /dev/null
@@ -0,0 +1,3 @@
+\e[32mgreen\e(B\e[m |colored with SCS reset
+\e[31mred\e[m   |colored without SCS
+normal|no colors
index 46edd0bb1e991649bc72b8bf97e93be5a2e8f2c0..004ad8d719d8fe9871871b0e59e85fe2feef2c7f 100755 (executable)
@@ -25,6 +25,13 @@ ts_check_test_command "$TS_CMD_COLUMN"
 
 ts_cd "$TS_OUTDIR"
 
-printf '%b' "$(cat $TS_SELF/files/ansiescape)" | $TS_CMD_COLUMN -c 32 | cat -v >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_init_subtest "sgr"
+printf '%b' "$(cat $TS_SELF/files/ansiescape)" | $TS_CMD_COLUMN --columns 32 | cat -v >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+ts_init_subtest "scs"
+printf '%b' "\033[32mgreen\033(B\033[m|colored with SCS reset\n\033[31mred\033[m|colored without SCS\nnormal|no colors\n" \
+       | $TS_CMD_COLUMN --table --separator '|' --output-separator '|' >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
 
 ts_finalize