Skip to content

Commit

Permalink
Merge pull request #483 from Backblaze/run_custom_integration_tests
Browse files Browse the repository at this point in the history
Let devs pick a pre-commit integration test set
  • Loading branch information
bwbeach committed Aug 4, 2018
2 parents 7c69fd4 + 9dda123 commit 46f0ce8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
22 changes: 18 additions & 4 deletions pre-commit.sh
@@ -1,9 +1,23 @@
#!/bin/bash -u

#
# USAGE: ./pre-commit.sh [remote_name] [branch_name] [remote_branch_name] [testname...]
# if the first test name to execute is "quick", then integration tests are skipped completely
#
# for example: ./pre-commit.sh origin master master basic account download
#


base_remote="${1:-origin}"
base_branch="${2:-master}"
base_remote_branch="${3:-master}"

# get a list of tests to run into $*
shift
shift
shift


function header
{
echo
Expand Down Expand Up @@ -105,7 +119,7 @@ else
exit 1
fi
if [[ $# -ne 0 && "${4:-}" == quick ]]
if [[ $# -ne 0 && "${1:-}" == quick ]]
then
header QUICK
echo Skipping integration tests in quick mode.
Expand All @@ -117,7 +131,7 @@ header Integration Tests
function run_integration_tests
{
if time python test_b2_command_line.py $(head -n 1 ~/.b2_auth) $(tail -n 1 ~/.b2_auth)
if time python test_b2_command_line.py "$(head -n 1 ~/.b2_auth)" "$(tail -n 1 ~/.b2_auth)" $*
then
echo "integration tests passed"
else
Expand All @@ -131,14 +145,14 @@ function run_integration_tests
# http://stackoverflow.com/a/16753536/95920
if [[ -z "${PYTHON_VIRTUAL_ENVS:-}" ]]
then
run_integration_tests
run_integration_tests $*
else
for virtual_env in $PYTHON_VIRTUAL_ENVS
do
header "Integration tests in: $virtual_env"
set +u # if PS1 is not set and -u is set, $virtual_env/bin/active crashes
source "$virtual_env/bin/activate"
set -u
run_integration_tests
run_integration_tests $*
done
fi
2 changes: 1 addition & 1 deletion test_b2_command_line.py
Expand Up @@ -765,7 +765,7 @@ def main():
tests_to_run = sys.argv[3:]
for test_name in tests_to_run:
if test_name not in test_map:
error_and_exit('unknown test: ' + test_name)
error_and_exit('unknown test: "%s"' % (test_name,))
else:
tests_to_run = sorted(six.iterkeys(test_map))

Expand Down

0 comments on commit 46f0ce8

Please sign in to comment.