summaryrefslogtreecommitdiff
path: root/run-tests
blob: 816dc0e7ddc55b7d21c99949991cbeed49c3d012 (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#!/bin/bash -eu

# Author: w0rp <devw0rp@gmail.com>
#
# This script runs tests for the ALE project. The following options are
# accepted:
#
#            -v  Enable verbose output
# --neovim-only  Run tests only for NeoVim
#    --vim-only  Run tests only for Vim

current_image_id=d5a1b5915b09
image=w0rp/ale
docker_flags=(--rm -v "$PWD:/testplugin" -v "$PWD/test:/home" -w /testplugin "$image")
exit_code=0

tests='test/*.vader test/*/*.vader test/*/*/*.vader test/*/*/*.vader'
# These flags are forwarded to the script for running Vader tests.
verbose_flag=''
quiet_flag=''
run_neovim_tests=1
run_vim_tests=1
run_vint=1
run_custom_checks=1

while [ $# -ne 0 ]; do
    case $1 in
    -v)
        verbose_flag='-v'
        shift
    ;;
    -q)
        quiet_flag='-q'
        shift
    ;;
    --neovim-only)
        run_vim_tests=0
        run_vint=0
        run_custom_checks=0
        shift
    ;;
    --vim-only)
        run_neovim_tests=0
        run_vint=0
        run_custom_checks=0
        shift
    ;;
    --no-vint)
        run_vint=0
        shift
    ;;
    --no-custom-checks)
        run_custom_checks=0
        shift
    ;;
    --custom-checks-only)
        run_vim_tests=0
        run_neovim_tests=0
        run_vint=0
        shift
    ;;
    --)
        shift
        break
    ;;
    -?*)
        echo "Invalid argument: $1" 1>&2
        exit 1
    ;;
    *)
        break
    ;;
    esac
done

# Allow tests to be passed as arguments.
if [ $# -ne 0 ]; then
    # This doesn't perfectly handle work splitting, but none of our files
    # have spaces in the names.
    tests="$*"
fi

# Delete .swp files in the test directory, which cause Vim 8 to hang.
find test -name '*.swp' -delete

docker images -q w0rp/ale | grep "^$current_image_id" > /dev/null \
    || docker pull "$image"

for vim in $(docker run --rm "$image" ls /vim-build/bin | grep '^neovim\|^vim' ); do
    if [[ $vim =~ ^neovim ]] && ((run_neovim_tests)); then
        test/script/run-vader-tests $quiet_flag $verbose_flag "$vim" "$tests"
    elif ((run_vim_tests)); then
        test/script/run-vader-tests $quiet_flag $verbose_flag "$vim" "$tests"
    fi
done

if ((run_vint)); then
    echo '========================================'
    echo 'Running Vint to lint our code'
    echo '========================================'
    echo 'Vint warnings/errors follow:'
    echo

    set -o pipefail
    docker run -a stdout "${docker_flags[@]}" vint -s . || exit_code=$?
    set +o pipefail
    echo
fi

if ((run_custom_checks)); then
    echo '========================================'
    echo 'Running custom checks'
    echo '========================================'
    echo 'Custom warnings/errors follow:'
    echo

    set -o pipefail
    docker run -a stdout "${docker_flags[@]}" test/script/custom-checks . || exit_code=$?
    set +o pipefail
    echo

    echo '========================================'
    echo 'Checking for duplicate tags'
    echo '========================================'
    echo 'Duplicate tags follow:'
    echo

    grep --exclude=tags -roh '\*.*\*$' doc | sort | uniq -d || exit_code=$?

    echo '========================================'
    echo 'Checking for invalid tag references'
    echo '========================================'
    echo 'Invalid tag references tags follow:'
    echo

    tag_regex='[gb]\?:\?\(ale\|ALE\)[a-zA-Z_\-]\+'

    # Grep for tags and references, and complain if we find a reference without
    # a tag for the reference. Only our tags will be included.
    diff -u \
        <(grep --exclude=tags -roh "\*$tag_regex\*" doc | sort -u | sed 's/*//g') \
        <(grep --exclude=tags -roh "|$tag_regex|" doc | sort -u | sed 's/|//g') \
        | grep '^+[^+]' && exit_code=1

    echo '========================================'
    echo 'diff README.md and doc/ale.txt tables'
    echo '========================================'
    echo 'Differences follow:'
    echo

    test/script/check-supported-tools-tables || exit_code=$?

    echo '========================================'
    echo 'Look for badly aligned doc tags'
    echo '========================================'
    echo 'Badly aligned tags follow:'
    echo

    # Documentation tags need to be aligned to the right margin, so look for
    # tags which aren't at the right margin.
    grep ' \*[^*]\+\*$' doc/ -r \
        | awk '{ sep = index($0, ":"); if (length(substr($0, sep + 1 )) < 79) { print } }' \
        | grep . && exit_code=1

    echo '========================================'
    echo 'Look for table of contents issues'
    echo '========================================'
    echo

    test/script/check-toc || exit_code=$?
fi

exit $exit_code