mirror of
1
0
Fork 0

Add ability to test with specific Python versions

This commit is contained in:
Anish Athalye 2015-10-22 21:46:28 -04:00
parent 30dc7d5788
commit 5babc8f562
4 changed files with 47 additions and 2 deletions

View File

@ -17,6 +17,9 @@ started by running `vagrant up`.
The test suite can be run by running `./test`. Selected tests can be run by
passing paths to the tests as arguments to `./test`.
Tests can be run with a specific Python version by running `./test --version
<version>` - for example, `./test --version 3.4.3`.
When finished with testing, it is good to shut down the virtual machine by
running `vagrant halt`.

16
test/Vagrantfile vendored
View File

@ -7,4 +7,20 @@ Vagrant.configure(2) do |config|
# disable default synced folder
config.vm.synced_folder ".", "/vagrant", disabled: true
# install packages
config.vm.provision "shell", inline: <<-EOS
apt-get -y update
apt-get install -y git make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
libncurses5-dev
EOS
# install pyenv
config.vm.provision "shell", privileged: false, inline: <<-EOS
rm -rf ~/.pyenv
git clone git://github.com/yyuu/pyenv.git ~/.pyenv
echo 'export PATH="$HOME/.pyenv/bin:$PATH"\neval "$(pyenv init -)"' \
> ~/.bashrc
EOS
end

View File

@ -65,6 +65,14 @@ rollback() {
initialize() {
echo "initializing."
vagrant sandbox on >/dev/null 2>&1
if ! vagrant ssh -c "pyenv local ${2}" >/dev/null 2>&1; then
wait_for_vagrant && vagrant sandbox rollback >/dev/null 2>&1
wait_for_vagrant
if ! vagrant ssh -c "pyenv install -s ${2} && pyenv local ${2}" >/dev/null 2>&1; then
die "could not install python ${2}"
fi
vagrant sandbox commit >/dev/null 2>&1
fi
tests_run=0
tests_passed=0
tests_failed=0
@ -89,6 +97,7 @@ run_test() {
tests_run=$((tests_run + 1))
printf '[%d/%d] (%s)\n' "${tests_run}" "${tests_total}" "${1}"
rollback || die "unable to rollback vm." # start with a clean slate
vagrant ssh -c "pyenv local ${2}" >/dev/null 2>&1
if vagrant ssh -c "cd /dotbot/test/tests && bash ${1}" 2>/dev/null; then
pass
else

View File

@ -9,6 +9,23 @@ start="$(date +%s)"
check_prereqs || die "prerequisites unsatsfied."
# command line options
while [[ $# > 1 ]]
do
key="${1}"
case $key in
-v|--version)
VERSION="${2}"
shift && shift
;;
*)
# unknown option
break
;;
esac
done
VERSION="${VERSION:-2.7.9}"
declare -a tests=()
if [ $# -eq 0 ]; then
@ -19,10 +36,10 @@ else
tests=("$@")
fi
initialize "${#tests[@]}"
initialize "${#tests[@]}" "${VERSION}"
for file in "${tests[@]}"; do
run_test "$(basename "${file}")"
run_test "$(basename "${file}")" "${VERSION}"
done
if report; then