summaryrefslogtreecommitdiff
path: root/test/unit/compgen.exp
blob: 8c33c414fe39e7c4f21cab4fae113902f66df455 (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
proc setup {} {
    save_env
}; # setup()


proc teardown {} {
    assert_env_unmodified {/OLDPWD/d}
}; # teardown()


setup


if {[lindex $::BASH_VERSINFO 0] <= 3} {
    set test {compgen -f a\\\\\\\'b/ on bash-3 should return a\'b/c};
    set cmd {compgen -f a\\\\\\\'b/}
} else {
    set test {compgen -f a\\\'b/ on bash-4 should return a\'b/c};
    set cmd {compgen -f a\\\'b/}
}; # if
set dir fixtures/compgen
set prompt "/$dir/@"
assert_bash_exec "cd $dir" "" $prompt
send "$cmd\r"
expect -ex "$cmd\r\n"
expect {
    -re {a\\\'b/c} {
        # On bash-3.2, compgen returns inconsequent output
        if {
            [lindex $::BASH_VERSINFO 0] >= 4 || (
                [lindex $::BASH_VERSINFO 0] == 3 &&
                [lindex $::BASH_VERSINFO 1] == 2
            )
        } {pass $test} else {fail $test}
    }
    -re {a'b/c} {
        if {[lindex $::BASH_VERSINFO 0] <= 3 } \
            {pass $test} else {fail $test}
    }
    -re $prompt { pass "$test" }
    -re eof { unresolved "eof" }
}; # expect
sync_after_int $prompt
assert_bash_exec "cd \$TESTDIR"

#assert_bash_list_dir {a\\\'b/c} $cmd fixtures/compgen


sync_after_int


teardown