1#!/bin/sh
2#
3
4test_description='git web--browse basic tests
5
6This test checks that git web--browse can handle various valid URLs.'
7
8. ./test-lib.sh
9
10test_expect_success \
11 'URL with an ampersand in it' '
12 echo http://example.com/foo\&bar >expect &&
13 git config browser.custom.cmd echo &&
14 git web--browse --browser=custom \
15 http://example.com/foo\&bar >actual &&
16 test_cmp expect actual
17'
18
19test_expect_success \
20 'URL with a semi-colon in it' '
21 echo http://example.com/foo\;bar >expect &&
22 git config browser.custom.cmd echo &&
23 git web--browse --browser=custom \
24 http://example.com/foo\;bar >actual &&
25 test_cmp expect actual
26'
27
28test_expect_success \
29 'URL with a hash in it' '
30 echo http://example.com/foo#bar >expect &&
31 git config browser.custom.cmd echo &&
32 git web--browse --browser=custom \
33 http://example.com/foo#bar >actual &&
34 test_cmp expect actual
35'
36
37test_expect_success \
38 'browser paths are properly quoted' '
39 echo fake: http://example.com/foo >expect &&
40 cat >"fake browser" <<-\EOF &&
41 #!/bin/sh
42 echo fake: "$@"
43 EOF
44 chmod +x "fake browser" &&
45 git config browser.w3m.path "`pwd`/fake browser" &&
46 git web--browse --browser=w3m \
47 http://example.com/foo >actual &&
48 test_cmp expect actual
49'
50
51test_expect_success \
52 'browser command allows arbitrary shell code' '
53 echo "arg: http://example.com/foo" >expect &&
54 git config browser.custom.cmd "
55 f() {
56 for i in \"\$@\"; do
57 echo arg: \$i
58 done
59 }
60 f" &&
61 git web--browse --browser=custom \
62 http://example.com/foo >actual &&
63 test_cmp expect actual
64'
65
66test_done