]>
Commit | Line | Data |
---|---|---|
480f062c CP |
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 | ||
3e3b9321 | 8 | TEST_PASSES_SANITIZE_LEAK=true |
480f062c CP |
9 | . ./test-lib.sh |
10 | ||
f64943d2 PT |
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 | ||
480f062c CP |
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 && | |
f64943d2 | 22 | test_web_browse custom http://example.com/foo\&bar |
480f062c CP |
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 && | |
f64943d2 | 29 | test_web_browse custom http://example.com/foo\;bar |
480f062c CP |
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 && | |
f64943d2 | 36 | test_web_browse custom http://example.com/foo#bar |
480f062c CP |
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" && | |
ec1b763d | 47 | git config browser.w3m.path "$(pwd)/fake browser" && |
f64943d2 | 48 | test_web_browse w3m http://example.com/foo |
480f062c CP |
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" && | |
f64943d2 | 61 | test_web_browse custom http://example.com/foo |
480f062c CP |
62 | ' |
63 | ||
64 | test_done |