summaryrefslogtreecommitdiff
path: root/test/tests/find-python-executable.bash
blob: 561b88216ec7eb2a42d8b7b7603c062398833df5 (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
test_description='can find python executable with different names'
. '../test-lib.bash'

# the test machine needs to have a binary named `python`
test_expect_success 'setup' '
mkdir ~/tmp_bin &&
(
    IFS=:
    for p in $PATH; do
        if [ -d $p ]; then
            find $p -maxdepth 1 -mindepth 1 -exec sh -c \
            '"'"'ln -sf {} $HOME/tmp_bin/$(basename {})'"'"' \;
        fi
    done
) &&
rm -f ~/tmp_bin/python &&
rm -f ~/tmp_bin/python2 &&
rm -f ~/tmp_bin/python3
'

test_expect_failure 'run' '
PATH="$HOME/tmp_bin" run_dotbot <<EOF
[]
EOF
'

test_expect_success 'setup 2' '
touch ~/tmp_bin/python &&
chmod +x ~/tmp_bin/python &&
cat >> ~/tmp_bin/python <<EOF
#!$HOME/tmp_bin/bash
exec $(command -v python)
EOF
'

test_expect_success 'run 2' '
PATH="$HOME/tmp_bin" run_dotbot <<EOF
[]
EOF
'

test_expect_success 'setup 3' '
mv ~/tmp_bin/python ~/tmp_bin/python2
'

test_expect_success 'run 3' '
PATH="$HOME/tmp_bin" run_dotbot <<EOF
[]
EOF
'

test_expect_success 'setup 4' '
mv ~/tmp_bin/python2 ~/tmp_bin/python3
'

test_expect_success 'run 4' '
PATH="$HOME/tmp_bin" run_dotbot <<EOF
[]
EOF
'