]>
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 | ||
8 | . ./test-lib.sh | |
9 | ||
f64943d2 PT |
10 | test_web_browse () { |
11 | # browser=$1 url=$2 | |
12 | git web--browse --browser="$1" "$2" >actual && | |
13 | tr -d '\015' <actual >text && | |
14 | test_cmp expect text | |
15 | } | |
16 | ||
480f062c CP |
17 | test_expect_success \ |
18 | 'URL with an ampersand in it' ' | |
19 | echo http://example.com/foo\&bar >expect && | |
20 | git config browser.custom.cmd echo && | |
f64943d2 | 21 | test_web_browse custom http://example.com/foo\&bar |
480f062c CP |
22 | ' |
23 | ||
24 | test_expect_success \ | |
25 | 'URL with a semi-colon in it' ' | |
26 | echo http://example.com/foo\;bar >expect && | |
27 | git config browser.custom.cmd echo && | |
f64943d2 | 28 | test_web_browse custom http://example.com/foo\;bar |
480f062c CP |
29 | ' |
30 | ||
31 | test_expect_success \ | |
32 | 'URL with a hash in it' ' | |
33 | echo http://example.com/foo#bar >expect && | |
34 | git config browser.custom.cmd echo && | |
f64943d2 | 35 | test_web_browse custom http://example.com/foo#bar |
480f062c CP |
36 | ' |
37 | ||
38 | test_expect_success \ | |
39 | 'browser paths are properly quoted' ' | |
40 | echo fake: http://example.com/foo >expect && | |
41 | cat >"fake browser" <<-\EOF && | |
42 | #!/bin/sh | |
43 | echo fake: "$@" | |
44 | EOF | |
45 | chmod +x "fake browser" && | |
ec1b763d | 46 | git config browser.w3m.path "$(pwd)/fake browser" && |
f64943d2 | 47 | test_web_browse w3m http://example.com/foo |
480f062c CP |
48 | ' |
49 | ||
50 | test_expect_success \ | |
51 | 'browser command allows arbitrary shell code' ' | |
52 | echo "arg: http://example.com/foo" >expect && | |
53 | git config browser.custom.cmd " | |
54 | f() { | |
55 | for i in \"\$@\"; do | |
56 | echo arg: \$i | |
57 | done | |
58 | } | |
59 | f" && | |
f64943d2 | 60 | test_web_browse custom http://example.com/foo |
480f062c CP |
61 | ' |
62 | ||
63 | test_done |