Skip to content

Commit

Permalink
The Travis CI build should now fail.
Browse files Browse the repository at this point in the history
  • Loading branch information
nbro committed Apr 2, 2018
1 parent e7c128f commit f517d3a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 18 deletions.
7 changes: 4 additions & 3 deletions .travis.yml
Expand Up @@ -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
29 changes: 19 additions & 10 deletions 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
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand Down
9 changes: 4 additions & 5 deletions scripts/travis.sh
Expand Up @@ -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
python -m unittest discover -s tests/
coverage run --source=. -m unittest discover -s tests/
coverage report -m
coveralls

0 comments on commit f517d3a

Please sign in to comment.