-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_tests.sh
executable file
·79 lines (63 loc) · 1.81 KB
/
run_tests.sh
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
#!/usr/bin/env bash
set -xeuo pipefail
# Profiling file (no profiling if empty)
profile_file=
profile_prefix=''
if [ $# -gt 0 ] && [ "$1" == "--profile" ]; then
profile_prefix='profile_file'
fi
# Using the Docker image developed for ALE
docker_image=w0rp/ale
docker_image_id=67896c9c2c0f
docker images -q "${docker_image}" | grep "^${docker_image_id}" > /dev/null \
|| docker pull "${docker_image}"
vim_binaries=$(docker run --rm "${docker_image}" ls /vim-build/bin \
| grep -E '^(neo)?vim-v(8\.1|0\.3)' )
set +e
exit_status=0
# Run tests
for vim in ${vim_binaries}; do
# Collect profiling data if an output file name is provided
if [ "${profile_prefix}" != '' ]; then
profile_file="${profile_prefix}_${vim}"
fi
find test -name '*.swp' -delete
# Run tests with mocked Python
#
# Add the test folder to the beginning of PATH to replace
# python with the mock script there.
docker run \
--rm \
-a stderr \
-e VADER_OUTPUT_FILE=/dev/stderr \
-e VIM_PROFILE_FILE="${profile_file}" \
-v "$PWD:/testplugin" \
-v "$PWD/test:/home"\
-w /testplugin \
"${docker_image}" \
bash -c "export PATH=\$(pwd)/test:\$PATH; /vim-build/bin/${vim} -u test/vimrc '+Vader! ./test/*.vader'" 2>&1
# shellcheck disable=SC2181
if [ "$?" -ne 0 ]; then
exit_status=1
fi
done
# Run vint
docker run \
--rm \
-a stdout \
-v "$PWD:/testplugin" \
-v "$PWD/test:/home"\
-w /testplugin \
"${docker_image}" \
find . -type f -name '*.vim' -exec vint -s '{}' + 2>&1
# shellcheck disable=SC2181
if [ "$?" -ne 0 ]; then
exit_status=1
fi
# Run flake8
find . -type f -name '*.py' -exec python -m flake8 '{}' +
# shellcheck disable=SC2181
if [ "$?" -ne 0 ]; then
exit_status=1
fi
exit ${exit_status}