| 1 | #!/bin/bash |
| 2 | # -*- coding: utf-8 -*- |
| 3 | # BSD 2-Clause License |
| 4 | # |
| 5 | # Apprise - Push Notification Library. |
| 6 | # Copyright (c) 2026, Chris Caron <[email protected]> |
| 7 | # |
| 8 | # Redistribution and use in source and binary forms, with or without |
| 9 | # modification, are permitted provided that the following conditions are met: |
| 10 | # |
| 11 | # 1. Redistributions of source code must retain the above copyright notice, |
| 12 | # this list of conditions and the following disclaimer. |
| 13 | # |
| 14 | # 2. Redistributions in binary form must reproduce the above copyright notice, |
| 15 | # this list of conditions and the following disclaimer in the documentation |
| 16 | # and/or other materials provided with the distribution. |
| 17 | # |
| 18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 19 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 20 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 21 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 22 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 23 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 24 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 25 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 26 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 27 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 28 | # POSSIBILITY OF SUCH DAMAGE. |
| 29 | # |
| 30 | PYTEST=$(which py.test 2>/dev/null) |
| 31 | # Support different distributions |
| 32 | [ -z "$PYTEST" ] && PYTEST=$(which py.test-3 2>/dev/null) |
| 33 | # This script can basically be used to test individual tests that have |
| 34 | # been created. Just run the to run all tests: |
| 35 | # ./devel/test.sh |
| 36 | |
| 37 | # to key in on a specific test type: |
| 38 | # ./devel/test.sh <keyword> |
| 39 | |
| 40 | # Absolute path to this script, e.g. /home/user/bin/foo.sh |
| 41 | SCRIPT=$(readlink -f "$0") |
| 42 | |
| 43 | # Absolute path this script is in, thus /home/user/bin |
| 44 | SCRIPTPATH=$(dirname "$SCRIPT") |
| 45 | |
| 46 | PYTHONPATH="" |
| 47 | |
| 48 | if [ -f "$(dirname $SCRIPTPATH)/pyproject.toml" ]; then |
| 49 | PYTHONPATH="$(dirname $SCRIPTPATH)" |
| 50 | |
| 51 | elif [ -f "$SCRIPTPATH/pyproject.toml" ]; then |
| 52 | PYTHONPATH="$SCRIPTPATH" |
| 53 | |
| 54 | else |
| 55 | echo "Error: Could not locate apprise pyproject.toml file." |
| 56 | exit 1 |
| 57 | fi |
| 58 | |
| 59 | if [ ! -x $PYTEST ]; then |
| 60 | echo "Error: $PYTEST was not found; make sure it is installed: 'pip3 install pytest'" |
| 61 | exit 1 |
| 62 | fi |
| 63 | |
| 64 | pushd $PYTHONPATH &>/dev/null |
| 65 | if [ ! -z "$@" ]; then |
| 66 | LANG=C.UTF-8 PYTHONPATH=$PYTHONPATH $PYTEST -k "$@" |
| 67 | exit $? |
| 68 | |
| 69 | else |
| 70 | LANG=C.UTF-8 PYTHONPATH=$PYTHONPATH $PYTEST |
| 71 | exit $? |
| 72 | fi |