Merge branch 'rs/diff-parseopts-cleanup'
[git/gitster.git] / t / t9901-git-web--browse.sh
blob19f56e5680f678c22fc80a63907c804448c4b445
1 #!/bin/sh
4 test_description='git web--browse basic tests
6 This test checks that git web--browse can handle various valid URLs.'
8 TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
11 test_web_browse () {
12 # browser=$1 url=$2
13 git web--browse --browser="$1" "$2" >actual &&
14 tr -d '\015' <actual >text &&
15 test_cmp expect text
18 test_expect_success \
19 'URL with an ampersand in it' '
20 echo http://example.com/foo\&bar >expect &&
21 git config browser.custom.cmd echo &&
22 test_web_browse custom http://example.com/foo\&bar
25 test_expect_success \
26 'URL with a semi-colon in it' '
27 echo http://example.com/foo\;bar >expect &&
28 git config browser.custom.cmd echo &&
29 test_web_browse custom http://example.com/foo\;bar
32 test_expect_success \
33 'URL with a hash in it' '
34 echo http://example.com/foo#bar >expect &&
35 git config browser.custom.cmd echo &&
36 test_web_browse custom http://example.com/foo#bar
39 test_expect_success \
40 'browser paths are properly quoted' '
41 echo fake: http://example.com/foo >expect &&
42 cat >"fake browser" <<-\EOF &&
43 #!/bin/sh
44 echo fake: "$@"
45 EOF
46 chmod +x "fake browser" &&
47 git config browser.w3m.path "$(pwd)/fake browser" &&
48 test_web_browse w3m http://example.com/foo
51 test_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
60 f" &&
61 test_web_browse custom http://example.com/foo
64 test_done