t/helper: merge test-pkt-line into test-tool
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Sun, 9 Sep 2018 17:36:28 +0000 (19:36 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 11 Sep 2018 17:54:19 +0000 (10:54 -0700)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Makefile
t/helper/test-pkt-line.c
t/helper/test-tool.c
t/helper/test-tool.h
t/t5701-git-serve.sh
t/t5702-protocol-v2.sh
t/t5703-upload-pack-ref-in-want.sh
index fa67d767801a7848c472dffeb4e950b717d06a7a..d9a4029895a4cf4d7cff5aba4a80b299ba461bfc 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -722,6 +722,7 @@ TEST_BUILTINS_OBJS += test-mergesort.o
 TEST_BUILTINS_OBJS += test-mktemp.o
 TEST_BUILTINS_OBJS += test-online-cpus.o
 TEST_BUILTINS_OBJS += test-path-utils.o
+TEST_BUILTINS_OBJS += test-pkt-line.o
 TEST_BUILTINS_OBJS += test-prio-queue.o
 TEST_BUILTINS_OBJS += test-read-cache.o
 TEST_BUILTINS_OBJS += test-ref-store.o
@@ -745,7 +746,6 @@ TEST_PROGRAMS_NEED_X += test-dump-fsmonitor
 TEST_PROGRAMS_NEED_X += test-fake-ssh
 TEST_PROGRAMS_NEED_X += test-line-buffer
 TEST_PROGRAMS_NEED_X += test-parse-options
-TEST_PROGRAMS_NEED_X += test-pkt-line
 TEST_PROGRAMS_NEED_X += test-svn-fe
 TEST_PROGRAMS_NEED_X += test-tool
 
index 30775f986f8067323808f6ccd064067f6c27489b..282d53638446bb2f0c91b81b313852cbadfb3c1f 100644 (file)
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "test-tool.h"
 #include "pkt-line.h"
 
 static void pack_line(const char *line)
@@ -79,7 +80,7 @@ static void unpack_sideband(void)
        }
 }
 
-int cmd_main(int argc, const char **argv)
+int cmd__pkt_line(int argc, const char **argv)
 {
        if (argc < 2)
                die("too few arguments");
index 820335704a417abb78eb6d963392373678af66cb..0ef53152c42837733d3b85239ce65c493325980c 100644 (file)
@@ -27,6 +27,7 @@ static struct test_cmd cmds[] = {
        { "mktemp", cmd__mktemp },
        { "online-cpus", cmd__online_cpus },
        { "path-utils", cmd__path_utils },
+       { "pkt-line", cmd__pkt_line },
        { "prio-queue", cmd__prio_queue },
        { "read-cache", cmd__read_cache },
        { "ref-store", cmd__ref_store },
index 118c700c7a7dae03b514934d9ba8bbb5e5f4c62a..7a0ac22ef72f05a39b04873b70bdc2214241a1e2 100644 (file)
@@ -23,6 +23,7 @@ int cmd__mergesort(int argc, const char **argv);
 int cmd__mktemp(int argc, const char **argv);
 int cmd__online_cpus(int argc, const char **argv);
 int cmd__path_utils(int argc, const char **argv);
+int cmd__pkt_line(int argc, const char **argv);
 int cmd__prio_queue(int argc, const char **argv);
 int cmd__read_cache(int argc, const char **argv);
 int cmd__ref_store(int argc, const char **argv);
index 75ec79e6cb839e71f6830d9301d1982d0fc68925..29a54fbfff2b1ade62cea815192ca12b941c6acd 100755 (executable)
@@ -15,13 +15,13 @@ test_expect_success 'test capability advertisement' '
        EOF
 
        git serve --advertise-capabilities >out &&
-       test-pkt-line unpack <out >actual &&
+       test-tool pkt-line unpack <out >actual &&
        test_cmp actual expect
 '
 
 test_expect_success 'stateless-rpc flag does not list capabilities' '
        # Empty request
-       test-pkt-line pack >in <<-EOF &&
+       test-tool pkt-line pack >in <<-EOF &&
        0000
        EOF
        git serve --stateless-rpc >out <in &&
@@ -33,7 +33,7 @@ test_expect_success 'stateless-rpc flag does not list capabilities' '
 '
 
 test_expect_success 'request invalid capability' '
-       test-pkt-line pack >in <<-EOF &&
+       test-tool pkt-line pack >in <<-EOF &&
        foobar
        0000
        EOF
@@ -42,7 +42,7 @@ test_expect_success 'request invalid capability' '
 '
 
 test_expect_success 'request with no command' '
-       test-pkt-line pack >in <<-EOF &&
+       test-tool pkt-line pack >in <<-EOF &&
        agent=git/test
        0000
        EOF
@@ -51,7 +51,7 @@ test_expect_success 'request with no command' '
 '
 
 test_expect_success 'request invalid command' '
-       test-pkt-line pack >in <<-EOF &&
+       test-tool pkt-line pack >in <<-EOF &&
        command=foo
        agent=git/test
        0000
@@ -71,7 +71,7 @@ test_expect_success 'setup some refs and tags' '
 '
 
 test_expect_success 'basics of ls-refs' '
-       test-pkt-line pack >in <<-EOF &&
+       test-tool pkt-line pack >in <<-EOF &&
        command=ls-refs
        0000
        EOF
@@ -88,12 +88,12 @@ test_expect_success 'basics of ls-refs' '
        EOF
 
        git serve --stateless-rpc <in >out &&
-       test-pkt-line unpack <out >actual &&
+       test-tool pkt-line unpack <out >actual &&
        test_cmp actual expect
 '
 
 test_expect_success 'basic ref-prefixes' '
-       test-pkt-line pack >in <<-EOF &&
+       test-tool pkt-line pack >in <<-EOF &&
        command=ls-refs
        0001
        ref-prefix refs/heads/master
@@ -108,12 +108,12 @@ test_expect_success 'basic ref-prefixes' '
        EOF
 
        git serve --stateless-rpc <in >out &&
-       test-pkt-line unpack <out >actual &&
+       test-tool pkt-line unpack <out >actual &&
        test_cmp actual expect
 '
 
 test_expect_success 'refs/heads prefix' '
-       test-pkt-line pack >in <<-EOF &&
+       test-tool pkt-line pack >in <<-EOF &&
        command=ls-refs
        0001
        ref-prefix refs/heads/
@@ -128,12 +128,12 @@ test_expect_success 'refs/heads prefix' '
        EOF
 
        git serve --stateless-rpc <in >out &&
-       test-pkt-line unpack <out >actual &&
+       test-tool pkt-line unpack <out >actual &&
        test_cmp actual expect
 '
 
 test_expect_success 'peel parameter' '
-       test-pkt-line pack >in <<-EOF &&
+       test-tool pkt-line pack >in <<-EOF &&
        command=ls-refs
        0001
        peel
@@ -149,12 +149,12 @@ test_expect_success 'peel parameter' '
        EOF
 
        git serve --stateless-rpc <in >out &&
-       test-pkt-line unpack <out >actual &&
+       test-tool pkt-line unpack <out >actual &&
        test_cmp actual expect
 '
 
 test_expect_success 'symrefs parameter' '
-       test-pkt-line pack >in <<-EOF &&
+       test-tool pkt-line pack >in <<-EOF &&
        command=ls-refs
        0001
        symrefs
@@ -170,12 +170,12 @@ test_expect_success 'symrefs parameter' '
        EOF
 
        git serve --stateless-rpc <in >out &&
-       test-pkt-line unpack <out >actual &&
+       test-tool pkt-line unpack <out >actual &&
        test_cmp actual expect
 '
 
 test_expect_success 'sending server-options' '
-       test-pkt-line pack >in <<-EOF &&
+       test-tool pkt-line pack >in <<-EOF &&
        command=ls-refs
        server-option=hello
        server-option=world
@@ -190,14 +190,14 @@ test_expect_success 'sending server-options' '
        EOF
 
        git serve --stateless-rpc <in >out &&
-       test-pkt-line unpack <out >actual &&
+       test-tool pkt-line unpack <out >actual &&
        test_cmp actual expect
 '
 
 test_expect_success 'unexpected lines are not allowed in fetch request' '
        git init server &&
 
-       test-pkt-line pack >in <<-EOF &&
+       test-tool pkt-line pack >in <<-EOF &&
        command=fetch
        0001
        this-is-not-a-command
index 3beeed4546cee6c7793de94ba2735b0e6d63b073..88a886975df1d031553efb96e33116df122f0491 100755 (executable)
@@ -334,7 +334,7 @@ test_expect_success 'even with handcrafted request, filter does not work if not
        git -C server config uploadpack.allowfilter 0 &&
 
        # Custom request that tries to filter even though it is not advertised.
-       test-pkt-line pack >in <<-EOF &&
+       test-tool pkt-line pack >in <<-EOF &&
        command=fetch
        0001
        want $(git -C server rev-parse master)
index d1ccc22331338b016646de6af5f15387b3119665..3f58f05cbb49d3b4a7f50e946e0f46bbc953140a 100755 (executable)
@@ -9,14 +9,14 @@ get_actual_refs () {
                /wanted-refs/d
                /0001/d
                p
-               }' <out | test-pkt-line unpack >actual_refs
+               }' <out | test-tool pkt-line unpack >actual_refs
 }
 
 get_actual_commits () {
        sed -n -e '/packfile/,/0000/{
                /packfile/d
                p
-               }' <out | test-pkt-line unpack-sideband >o.pack &&
+               }' <out | test-tool pkt-line unpack-sideband >o.pack &&
        git index-pack o.pack &&
        git verify-pack -v o.idx | grep commit | cut -c-40 | sort >actual_commits
 }
@@ -61,7 +61,7 @@ test_expect_success 'config controls ref-in-want advertisement' '
 '
 
 test_expect_success 'invalid want-ref line' '
-       test-pkt-line pack >in <<-EOF &&
+       test-tool pkt-line pack >in <<-EOF &&
        command=fetch
        0001
        no-progress
@@ -80,7 +80,7 @@ test_expect_success 'basic want-ref' '
        EOF
        git rev-parse f | sort >expected_commits &&
 
-       test-pkt-line pack >in <<-EOF &&
+       test-tool pkt-line pack >in <<-EOF &&
        command=fetch
        0001
        no-progress
@@ -101,7 +101,7 @@ test_expect_success 'multiple want-ref lines' '
        EOF
        git rev-parse c d | sort >expected_commits &&
 
-       test-pkt-line pack >in <<-EOF &&
+       test-tool pkt-line pack >in <<-EOF &&
        command=fetch
        0001
        no-progress
@@ -122,7 +122,7 @@ test_expect_success 'mix want and want-ref' '
        EOF
        git rev-parse e f | sort >expected_commits &&
 
-       test-pkt-line pack >in <<-EOF &&
+       test-tool pkt-line pack >in <<-EOF &&
        command=fetch
        0001
        no-progress
@@ -143,7 +143,7 @@ test_expect_success 'want-ref with ref we already have commit for' '
        EOF
        >expected_commits &&
 
-       test-pkt-line pack >in <<-EOF &&
+       test-tool pkt-line pack >in <<-EOF &&
        command=fetch
        0001
        no-progress