Skip to content

Instantly share code, notes, and snippets.

@lyarwood
Created January 17, 2022 12:06
Show Gist options
  • Save lyarwood/6ab836105e109c4e5e28fc10c0ab8466 to your computer and use it in GitHub Desktop.
Save lyarwood/6ab836105e109c4e5e28fc10c0ab8466 to your computer and use it in GitHub Desktop.
bash functions to run recently changed unit and functional tests in openstack/nova
function _unit_staged(){
touched_tests=$(git diff --cached --name-only | grep tests\/unit)
tests=""
for test in $touched_tests; do t=$(echo $test | sed 's/\//\./g' | sed 's/\.py//g'); tests+=" ${t}"; done
tox -e py27 $tests
}
function _unit_last(){
touched_tests=$(git diff-tree --no-commit-id --name-only -r HEAD | grep tests\/unit)
tests=""
for test in $touched_tests; do t=$(echo $test | sed 's/\//\./g' | sed 's/\.py//g'); tests+=" ${t}"; done
tox -e py37 $tests
}
function _unit_last27(){
touched_tests=$(git diff-tree --no-commit-id --name-only -r HEAD | grep tests\/unit)
tests=""
for test in $touched_tests; do t=$(echo $test | sed 's/\//\./g' | sed 's/\.py//g'); tests+=" ${t}"; done
tox -e py27 $tests
}
function _func_last(){
touched_tests=$(git diff-tree --no-commit-id --name-only -r HEAD | grep tests\/functional)
tests=""
for test in $touched_tests; do t=$(echo $test | sed 's/\//\./g' | sed 's/\.py//g'); tests+=" ${t}"; done
tox -e functional $tests
}
function _func36_last(){
touched_tests=$(git diff-tree --no-commit-id --name-only -r HEAD | grep tests\/functional)
tests=""
for test in $touched_tests; do t=$(echo $test | sed 's/\//\./g' | sed 's/\.py//g'); tests+=" ${t}"; done
tox -e functional-py36 $tests
}
function _test_last(){
_func_last && _unit_last
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment