summaryrefslogtreecommitdiff
path: root/test/unit/_parse_help.exp
blob: 4beb28d2b12e517ae0e8e9c3751a7d372c1fe3d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# By Stephen Gildea, October 2010. 

proc setup {} {
    save_env
}

proc teardown {} {
    assert_env_unmodified {
        /declare -f fn/d
    }
}

setup


set cmd {fn() { printf '%s\n' ""; }; _parse_help fn}
assert_bash_list "" $cmd "empty"
sync_after_int

set cmd {fn() { printf '%s\n' "no dashes here"; }; _parse_help fn}
assert_bash_list "" $cmd "no dashes"
sync_after_int

set cmd {fn() { printf '%s\n' "internal-dash"; }; _parse_help fn}
assert_bash_list "" $cmd "internal dash 1"
sync_after_int

set cmd {fn() { printf '%s\n' "no -leading-dashes"; }; _parse_help fn}
assert_bash_list "" $cmd "no leading dash"
sync_after_int

set cmd {fn() { printf '%s\n' "-one dash"; }; _parse_help fn}
assert_bash_list "-one" $cmd "one dash"
sync_after_int

set cmd {fn() { printf '%s\n' " -space dash"; }; _parse_help fn}
assert_bash_list "-space" $cmd "one dash after space"
sync_after_int

set cmd {fn() { printf '%s\n' "-one -two dashes"; }; _parse_help fn}
assert_bash_list "-one\n-two" $cmd "two dashes, space-separated"
sync_after_int

set cmd {fn() { printf '%s\n' "-one,-t dashes"; }; _parse_help fn}
assert_bash_list "-one\n-t" $cmd "two dashes, comma-separated"
sync_after_int

set cmd {fn() { printf '%s\n' "-one dash-inside"; }; _parse_help fn}
assert_bash_list "-one" $cmd "internal dash 2"
sync_after_int

set cmd {fn() { printf '%s\n' "--long-arg=value"; }; _parse_help fn}
assert_bash_list "--long-arg" $cmd "value stripped"
sync_after_int

set cmd {fn() { printf '%s\n' "--long-arg=-value"; }; _parse_help fn}
assert_bash_list "--long-arg" $cmd "value not seen as option"
sync_after_int

set cmd {fn() { printf '%s\n' "--long-arg=-value,--opt2=val"; }; _parse_help fn}
assert_bash_list "--long-arg\n--opt2" $cmd "two options with values"
sync_after_int

set cmd {fn() { printf '%s\n' "-m,--mirror"; }; _parse_help fn}
assert_bash_list "-m\n--mirror" $cmd "short + long"
sync_after_int

set cmd {fn() { printf '%s\n' "-T/--upload-file"; }; _parse_help fn}
assert_bash_list "-T\n--upload-file" $cmd "short + long, slash separated"
sync_after_int


teardown