Skip to content

Instantly share code, notes, and snippets.

@dims
Created July 13, 2015 17:32
Show Gist options
  • Select an option

  • Save dims/eeb0b882f58e44acf96f to your computer and use it in GitHub Desktop.

Select an option

Save dims/eeb0b882f58e44acf96f to your computer and use it in GitHub Desktop.
Handy script from Dan Smith
#!/bin/bash
PROJ="$1"
OLIB="$2"
function usage() {
echo 'Usage: test_oslo_with.sh PROJECT OSLO_LIBRARY'
echo
echo 'Example:'
echo ' test_oslo_with.sh openstack/nova oslo.versionedobjects'
}
if [ -z "$PROJ" ]; then
usage
exit 1;
fi
if [ -z "$OLIB" ]; then
usage
exit 1;
fi
function get_project() {
local proj="$1"
local tmp="$2"
git clone http://github.org/$proj $tmp/$(basename $proj)
}
function init_tox() {
local dir="$1"
# This will generate .tox/py27 and not run tests.
# Surely there is a better way to do this?
(cd $dir && tox -epy27 -- nosuchthing)
}
function install_lib() {
local lib="$1"
local proj="$2"
local tmp="$3"
local projdir="${tmp}/"$(basename $proj)
local libdir="${tmp}/$lib"
local pip="${projdir}/.tox/py27/bin/pip"
local python="${projdir}/.tox/py27/bin/python"
$pip uninstall -y $lib
(cd $libdir && $python setup.py install)
}
function run_tests() {
local projdir="$1"
(cd $projdir && tox -epy27)
}
function main() {
#local tmp=$(mktemp -d)
local tmp='/tmp/withtest'
mkdir $tmp
get_project $PROJ $tmp
get_project openstack/$OLIB $tmp
init_tox "${tmp}/"$(basename $PROJ)
install_lib $OLIB $PROJ $tmp
run_tests "${tmp}/"$(basename $PROJ)
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment