]> git.ipfire.org Git - thirdparty/git.git/blob - t/t9901-git-web--browse.sh
Merge branch 'jk/clone-allow-bare-and-o-together'
[thirdparty/git.git] / t / t9901-git-web--browse.sh
1 #!/bin/sh
2 #
3
4 test_description='git web--browse basic tests
5
6 This test checks that git web--browse can handle various valid URLs.'
7
8 TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
10
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
16 }
17
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
23 '
24
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
30 '
31
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
37 '
38
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
49 '
50
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
59 }
60 f" &&
61 test_web_browse custom http://example.com/foo
62 '
63
64 test_done