diff options
author | Anish Athalye <me@anishathalye.com> | 2015-10-22 21:46:28 -0400 |
---|---|---|
committer | Anish Athalye <me@anishathalye.com> | 2015-10-22 22:08:35 -0400 |
commit | 5babc8f562f9ba1ad3e78b5ec6906aa33d17c0a9 (patch) | |
tree | 617b861f7533956783737b3a9e30393f57c8f048 /test | |
parent | 30dc7d57887ced68fa2109db214c94598449e2da (diff) |
Add ability to test with specific Python versions
Diffstat (limited to 'test')
-rw-r--r-- | test/README.md | 3 | ||||
-rw-r--r-- | test/Vagrantfile | 16 | ||||
-rw-r--r-- | test/driver-lib.bash | 9 | ||||
-rwxr-xr-x | test/test | 21 |
4 files changed, 47 insertions, 2 deletions
diff --git a/test/README.md b/test/README.md index 824dbca..c4abddc 100644 --- a/test/README.md +++ b/test/README.md @@ -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`. diff --git a/test/Vagrantfile b/test/Vagrantfile index 4463f99..37e2da0 100644 --- a/test/Vagrantfile +++ b/test/Vagrantfile @@ -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 diff --git a/test/driver-lib.bash b/test/driver-lib.bash index f7b25ba..56a0740 100644 --- a/test/driver-lib.bash +++ b/test/driver-lib.bash @@ -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 @@ -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 |