-
Notifications
You must be signed in to change notification settings - Fork 2
/
run
executable file
·84 lines (74 loc) · 2.49 KB
/
run
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
#!/bin/bash
versions="3.5 3.6 3.7 3.8 3.9 3.10 3.11"
function run_version_tests {
if [ "--build" = $2 ]
then
args="--inplace --force"
LAZYCSV_INCLUDE_NUMPY=1 LAZYCSV_INDEX_DTYPE=uint8_t \
python setup.py build_ext $args &> /dev/null
fi
python -m pytest
}
function run_benchmarks {
python ./tests/benchmark_lazy.py
}
function print_help {
echo "bash commands:"
echo "- bench: run benchmarks"
echo "- test: run test suite"
echo "- testrunner: spin up docker container for testing purposes"
echo "- tox: run tox"
}
function run_testrunner {
if [ -z $(command -v docker) ]
then
echo "environment tests requires docker executable"
exit 1
fi
container=lazycsv_testrunner
if [[ -z $(docker ps -a --format {{.Names}} | grep $container) ]]
then
docker run \
-v $(pwd):/code \
--name $container \
-e LAZYCSV_INCLUDE_NUMPY=1 \
-e PYENV_ROOT="/root/.pyenv" \
-e PATH="/root/.pyenv/shims:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" \
-dit debian:bookworm
docker exec $container bash \
-c "apt-get update && apt-get install git wget tar make gcc build-essential gdb lcov pkg-config libbz2-dev libffi-dev libgdbm-dev libgdbm-compat-dev liblzma-dev libncurses5-dev libreadline6-dev libsqlite3-dev libssl-dev lzma lzma-dev tk-dev uuid-dev zlib1g-dev -y"
docker exec $container bash \
-c "cd /root && git clone --depth=1 https://github.com/pyenv/pyenv.git .pyenv"
docker exec $container bash -c "pyenv install $versions"
docker exec $container bash -c "pyenv local $versions"
for version in $versions
do
docker exec $container bash \
-c "python$version -m pip install numpy pytest"
done
docker exec $container bash \
-c "python3.11 -m pip install tox"
else
docker start $container > /dev/null
fi
docker exec -it $container bash
}
function run_tox {
python3.11 -m tox
}
function run_debug {
LAZYCSV_INCLUDE_NUMPY=1 \
LAZYCSV_INDEX_DTYPE="uint8_t" \
LAZYCSV_DEBUG=1 \
CFLAGS="-O0" \
python setup.py build_ext --inplace --force \
&& gdb --args python -m pytest ${@:2}
}
case $1 in
testrunner) run_testrunner $@ ;;
test) run_version_tests $@ ;;
bench) run_benchmarks $@ ;;
debug) run_debug $@ ;;
tox) run_tox $@ ;;
*) print_help $@ ;;
esac