test core.gitproxy configuration

This is just a basic sanity test to see whether core.gitproxy works at all. Until now, we were not testing anywhere. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed May 18, 2011 at 04:57 UTC c7730e6f5f5757ac278319f33b94c32458e21f12
1 file changed +43
t/t5532-fetch-proxy.sh new
+43
@@ -0,0 +1,43 @@
1 +#!/bin/sh
2 +
3 +test_description='fetching via git:// using core.gitproxy'
4 +. ./test-lib.sh
5 +
6 +test_expect_success 'setup remote repo' '
7 + git init remote &&
8 + (cd remote &&
9 + echo content >file &&
10 + git add file &&
11 + git commit -m one
12 + )
13 +'
14 +
15 +cat >proxy <<'EOF'
16 +#!/bin/sh
17 +echo >&2 "proxying for $*"
18 +cmd=`perl -e '
19 + read(STDIN, $buf, 4);
20 + my $n = hex($buf) - 4;
21 + read(STDIN, $buf, $n);
22 + my ($cmd, $other) = split /\0/, $buf;
23 + # drop absolute-path on repo name
24 + $cmd =~ s{ /}{ };
25 + print $cmd;
26 +'`
27 +echo >&2 "Running '$cmd'"
28 +exec $cmd
29 +EOF
30 +chmod +x proxy
31 +test_expect_success 'setup local repo' '
32 + git remote add fake git://example.com/remote &&
33 + git config core.gitproxy ./proxy
34 +'
35 +
36 +test_expect_success 'fetch through proxy works' '
37 + git fetch fake &&
38 + echo one >expect &&
39 + git log -1 --format=%s FETCH_HEAD >actual &&
40 + test_cmp expect actual
41 +'
42 +
43 +test_done