diff options
Diffstat (limited to 'run_tests.sh')
-rwxr-xr-x | run_tests.sh | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/run_tests.sh b/run_tests.sh index 09386dc..2a95a92 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -6,15 +6,15 @@ help(){ echo "Run gitlint's test suite(s) or some convience commands" echo " -h, --help Show this help output" echo " -c, --clean Clean the project of temporary files" - echo " -p, --pep8 Run pep8 checks" + echo " -f, --format Run format checks" echo " -l, --lint Run pylint checks" echo " -g, --git Run gitlint checks" echo " -i, --integration Run integration tests" echo " -b, --build Run build tests" - echo " -a, --all Run all tests and checks (unit, integration, pep8, git)" + echo " -a, --all Run all tests and checks (unit, integration, formatting, git)" echo " -e, --envs [ENV1],[ENV2] Run tests against specified python environments" echo " (envs: 36,37,38,39,pypy37)." - echo " Also works for integration, pep8 and lint tests." + echo " Also works for integration, formatting and lint tests." echo " -C, --container Run the specified command in the container for the --envs specified" echo " --all-env Run all tests against all python environments" echo " --install Install virtualenvs for the --envs specified" @@ -74,11 +74,11 @@ handle_test_result(){ echo -e "${NO_COLOR}" } -run_pep8_check(){ - # FLAKE 8 - target=${testargs:-"gitlint-core qa examples"} - echo -ne "Running flake8..." - RESULT=$(flake8 $target) +run_formatting_check(){ + # BLACK + target=${testargs:-"."} + echo -ne "Running black --check..." + RESULT=$(black --check --diff $target) local exit_code=$? handle_test_result $exit_code "$RESULT" return $exit_code @@ -89,11 +89,14 @@ run_unit_tests(){ # py.test -s => print standard output (i.e. show print statement output) # -rw => print warnings target=${testargs:-"gitlint-core"} - coverage run -m pytest -rw -s $target - TEST_RESULT=$? if [ $include_coverage -eq 1 ]; then + coverage run -m pytest -rw -s $target + TEST_RESULT=$? COVERAGE_REPORT=$(coverage report -m) echo "$COVERAGE_REPORT" + else + pytest -rw -s $target + TEST_RESULT=$? fi return $TEST_RESULT; @@ -144,7 +147,7 @@ run_build_test(){ # Copy gitlint to a new temp dir echo -n "Copying gitlint to $temp_dir..." mkdir "$temp_dir" - rsync -az --exclude ".vagrant" --exclude ".git" --exclude ".venv*" . "$temp_dir" + rsync -az --exclude ".git" --exclude ".venv*" . "$temp_dir" echo -e "${GREEN}DONE${NO_COLOR}" # Update the version to include a timestamp @@ -214,7 +217,7 @@ clean(){ echo -n "Cleaning the *.pyc, site/, build/, dist/ and all __pycache__ directories..." find gitlint-core qa -type d -name "__pycache__" -exec rm -rf {} \; 2> /dev/null find gitlint-core qa -iname "*.pyc" -exec rm -rf {} \; 2> /dev/null - rm -rf "site" "dist" "build" + rm -rf "site" "dist" "build" "gitlint-core/dist" "gitlint-core/build" echo -e "${GREEN}DONE${NO_COLOR}" } @@ -230,7 +233,7 @@ run_all(){ run_build_test exit_code=$((exit_code + $?)) subtitle "# STYLE CHECKS ($(python --version 2>&1), $(which python)) #" - run_pep8_check + run_formatting_check exit_code=$((exit_code + $?)) run_lint_check exit_code=$((exit_code + $?)) @@ -379,7 +382,7 @@ switch_env(){ export PATH=$(echo $PATH | tr ":" "\n" | grep -v "$VIRTUAL_ENV" | tr "\n" ":"); fi set -e # Let's error out if you try executing against a non-existing env - source "/vagrant/.venv${1}/bin/activate" + source ".venv${1}/bin/activate" set +e fi title "### PYTHON ($(python --version 2>&1), $(which python)) ###" @@ -401,7 +404,7 @@ run_in_container(){ # default behavior -just_pep8=0 +just_formatting=0 just_lint=0 just_git=0 just_integration_tests=0 @@ -424,7 +427,7 @@ while [ "$#" -gt 0 ]; do case "$1" in -h|--help) shift; help;; -c|--clean) shift; just_clean=1;; - -p|--pep8) shift; just_pep8=1;; + -f|--format) shift; just_formatting=1;; -l|--lint) shift; just_lint=1;; -g|--git) shift; just_git=1;; -b|--build) shift; just_build_tests=1;; @@ -465,9 +468,9 @@ for environment in $envs; do if [ $container_enabled -eq 1 ]; then run_in_container "$environment" "$original_envs" "$original_args" - elif [ $just_pep8 -eq 1 ]; then + elif [ $just_formatting -eq 1 ]; then switch_env "$environment" - run_pep8_check + run_formatting_check elif [ $just_stats -eq 1 ]; then switch_env "$environment" run_stats |