]> git.ipfire.org Git - thirdparty/git.git/commit
test-pkt-line: add option parser for unpack-sideband
authorJiang Xin <zhiyou.jx@alibaba-inc.com>
Sun, 17 Dec 2023 14:41:36 +0000 (22:41 +0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 18 Dec 2023 21:24:37 +0000 (13:24 -0800)
commiteaa82f8e983199080369c44869ceac1e403f81fc
treec0926db3cfe8e41b8d609af3a6c053639b5c2e6c
parentbcb6cae2966cc407ca1afc77413b3ef11103c175
test-pkt-line: add option parser for unpack-sideband

We can use the test helper program "test-tool pkt-line" to test pkt-line
related functions. E.g.:

 * Use "test-tool pkt-line send-split-sideband" to generate sideband
   messages.

 * Pipe these generated sideband messages to command "test-tool pkt-line
   unpack-sideband" to test packet_reader_read() function.

In order to make a complete test of the packet_reader_read() function,
add option parser for command "test-tool pkt-line unpack-sideband".

 * To remove newlines in sideband messages, we can use:

        $ test-tool pkt-line unpack-sideband --chomp-newline

 * To preserve newlines in sideband messages, we can use:

        $ test-tool pkt-line unpack-sideband --no-chomp-newline

 * To parse sideband messages using "demultiplex_sideband()" inside the
   function "packet_reader_read()", we can use:

        $ test-tool pkt-line unpack-sideband --reader-use-sideband

We also add new example sideband packets in send_split_sideband() and
add several new test cases in t0070. Among these test cases, we pipe
output of the "send-split-sideband" subcommand to the "unpack-sideband"
subcommand. We found two issues:

 1. The two splitted sideband messages "Hello," and " world!\n" should
    be concatenated together. But when we turn on use_sideband field of
    reader to parse sideband messages, the first part of the splitted
    message ("Hello,") is lost.

 2. The newline characters in sideband 2 (progress info) and sideband 3
    (error message) should be preserved, but they are both trimmed.

Will fix the above two issues in subsequent commits.

Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/helper/test-pkt-line.c
t/t0070-fundamental.sh