diff --git a/.travis.yml b/.travis.yml index 51b1170b..5a95eac9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,10 +7,11 @@ language: python python: - 3.5 - 3.6 + - pypy3.5 + - pypy3.6 install: - - pip install coveralls + - pip install coveralls # It also installs coverage.py. - pip install -e . -script: scripts/travis.sh - +script: scripts/travis.sh \ No newline at end of file diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index db1d5742..e3a2a70f 100755 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -1,11 +1,17 @@ #!/usr/bin/env bash -# See the file CONTRIBUTING.md under the root folder of the ands package to know -# more about this script. +# Script to run tests in a virtual environment during the development phase. +# +# You need to call this script from inside the folder "scripts" under the root +# folder of this project. # # Run all tests with: ./run_tests.sh # # Run specific test: ./run_tests.sh -st [folder_path_inside_tests] test_name.py +# Example: ./run_tests.sh -st algorithms/numerical/test_gradient_descent.py +# +# See the file CONTRIBUTING.md under the root folder of the ands package to know +# more about this script. export ALREADY_SOURCED_RUN_TESTS @@ -80,20 +86,21 @@ then # coverage statistics. coverage run -m unittest "$2" -v - # In case an error occurs while running coverage. - # An error that occurred to me was that a unit test module was not found. - # So we just proceed if we have actually run the tests and created the file .coverage. + # In case an error occurs while running coverage. An error that occurred + # to me was that a unit test module was not found. So, we just proceed + # if we have actually run the tests and created the file .coverage. if [ $? -ne 0 ] then printf "%sUnit test(s) did NOT run successfully.%s\n" "${RED}" "${NORMAL}" exit 1 fi - # We need to go back at least twice in order to be in the root folder of the project. + # We need to go back at least twice in order to be in the root folder of + # the project. cd ../../ - # This to ensure we're in the root folder of the project, - # since the specific test could have been executed in a depth greater than 2. + # This to ensure we're in the root folder of the project, since the + # specific test could have been executed in a depth greater than 2. cd_back_n_times "$(count_occurrences "/" "$1")" # Move the file '.coverage' to the root folder of the project. @@ -113,7 +120,8 @@ then install_dependencies_in_virtual_environment coveralls "-e ." - # If we have 3 parameters, then probably the user wants to execute a specific test. + # If we have 3 parameters, then probably the user wants to execute a + # specific test. if [ "$#" = "3" ] then # First parameter must be -st @@ -161,7 +169,8 @@ then _source_script scripts asserts _source_script scripts virtual_environment - # "$@" expands all command-line parameters separated by spaces which are passed to the run function + # "$@" expands all command-line parameters separated by spaces which are + # passed to the run function. _main "$@" ALREADY_SOURCED_RUN_TESTS="true" diff --git a/scripts/travis.sh b/scripts/travis.sh index e778345d..342c8550 100755 --- a/scripts/travis.sh +++ b/scripts/travis.sh @@ -2,8 +2,7 @@ # Script called by Travis CI to report the code coverage. -cd tests/ -coverage run -m unittest discover . -v -mv .coverage ../.coverage -cd ../ -coveralls \ No newline at end of file +python -m unittest discover -s tests/ +coverage run --source=. -m unittest discover -s tests/ +coverage report -m +coveralls