]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/t5701-git-serve.sh
Turn `git serve` into a test helper
[thirdparty/git.git] / t / t5701-git-serve.sh
index fe45bf828d09cd9d95a66742ef938837d35141a3..ffb9613885904eaf474a726f6124032d13db9753 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-test_description='test git-serve and server commands'
+test_description='test protocol v2 server commands'
 
 . ./test-lib.sh
 
@@ -14,7 +14,8 @@ test_expect_success 'test capability advertisement' '
        0000
        EOF
 
-       GIT_TEST_SIDEBAND_ALL=0 git serve --advertise-capabilities >out &&
+       GIT_TEST_SIDEBAND_ALL=0 test-tool serve-v2 \
+               --advertise-capabilities >out &&
        test-tool pkt-line unpack <out >actual &&
        test_cmp expect actual
 '
@@ -24,11 +25,11 @@ test_expect_success 'stateless-rpc flag does not list capabilities' '
        test-tool pkt-line pack >in <<-EOF &&
        0000
        EOF
-       git serve --stateless-rpc >out <in &&
+       test-tool serve-v2 --stateless-rpc >out <in &&
        test_must_be_empty out &&
 
        # EOF
-       git serve --stateless-rpc >out &&
+       test-tool serve-v2 --stateless-rpc >out &&
        test_must_be_empty out
 '
 
@@ -37,7 +38,7 @@ test_expect_success 'request invalid capability' '
        foobar
        0000
        EOF
-       test_must_fail git serve --stateless-rpc 2>err <in &&
+       test_must_fail test-tool serve-v2 --stateless-rpc 2>err <in &&
        test_i18ngrep "unknown capability" err
 '
 
@@ -46,7 +47,7 @@ test_expect_success 'request with no command' '
        agent=git/test
        0000
        EOF
-       test_must_fail git serve --stateless-rpc 2>err <in &&
+       test_must_fail test-tool serve-v2 --stateless-rpc 2>err <in &&
        test_i18ngrep "no command requested" err
 '
 
@@ -56,7 +57,7 @@ test_expect_success 'request invalid command' '
        agent=git/test
        0000
        EOF
-       test_must_fail git serve --stateless-rpc 2>err <in &&
+       test_must_fail test-tool serve-v2 --stateless-rpc 2>err <in &&
        test_i18ngrep "invalid command" err
 '
 
@@ -87,7 +88,7 @@ test_expect_success 'basics of ls-refs' '
        0000
        EOF
 
-       git serve --stateless-rpc <in >out &&
+       test-tool serve-v2 --stateless-rpc <in >out &&
        test-tool pkt-line unpack <out >actual &&
        test_cmp expect actual
 '
@@ -107,7 +108,7 @@ test_expect_success 'basic ref-prefixes' '
        0000
        EOF
 
-       git serve --stateless-rpc <in >out &&
+       test-tool serve-v2 --stateless-rpc <in >out &&
        test-tool pkt-line unpack <out >actual &&
        test_cmp expect actual
 '
@@ -127,7 +128,7 @@ test_expect_success 'refs/heads prefix' '
        0000
        EOF
 
-       git serve --stateless-rpc <in >out &&
+       test-tool serve-v2 --stateless-rpc <in >out &&
        test-tool pkt-line unpack <out >actual &&
        test_cmp expect actual
 '
@@ -148,7 +149,7 @@ test_expect_success 'peel parameter' '
        0000
        EOF
 
-       git serve --stateless-rpc <in >out &&
+       test-tool serve-v2 --stateless-rpc <in >out &&
        test-tool pkt-line unpack <out >actual &&
        test_cmp expect actual
 '
@@ -169,7 +170,7 @@ test_expect_success 'symrefs parameter' '
        0000
        EOF
 
-       git serve --stateless-rpc <in >out &&
+       test-tool serve-v2 --stateless-rpc <in >out &&
        test-tool pkt-line unpack <out >actual &&
        test_cmp expect actual
 '
@@ -189,7 +190,7 @@ test_expect_success 'sending server-options' '
        0000
        EOF
 
-       git serve --stateless-rpc <in >out &&
+       test-tool serve-v2 --stateless-rpc <in >out &&
        test-tool pkt-line unpack <out >actual &&
        test_cmp expect actual
 '
@@ -204,7 +205,10 @@ test_expect_success 'unexpected lines are not allowed in fetch request' '
        0000
        EOF
 
-       test_must_fail git -C server serve --stateless-rpc <in >/dev/null 2>err &&
+       (
+               cd server &&
+               test_must_fail test-tool serve-v2 --stateless-rpc
+       ) <in >/dev/null 2>err &&
        grep "unexpected line: .this-is-not-a-command." err
 '