3 # SPDX-License-Identifier: BSD-2-Clause
5 # Copyright (c) 2018-2021 Gavin D. Howard and contributors.
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions are met:
10 # * Redistributions of source code must retain the above copyright notice, this
11 # list of conditions and the following disclaimer.
13 # * Redistributions in binary form must reproduce the above copyright notice,
14 # this list of conditions and the following disclaimer in the documentation
15 # and/or other materials provided with the distribution.
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 # POSSIBILITY OF SUCH DAMAGE.
33 testdir=$(dirname "$script")
35 . "$testdir/../scripts/functions.sh"
37 # Command-line processing.
38 if [ "$#" -ge 1 ]; then
42 err_exit "usage: $script dir [run_extra_tests] [run_stack_tests] [gen_tests] [time_tests] [exec args...]" 1
45 if [ "$#" -lt 1 ]; then
52 if [ "$#" -lt 1 ]; then
59 if [ "$#" -lt 1 ]; then
66 if [ "$#" -lt 1 ]; then
73 if [ "$#" -lt 1 ]; then
74 exe="$testdir/../bin/$d"
80 stars="***********************************************************************"
81 printf '%s\n' "$stars"
83 # Set stuff for the correct calculator.
84 if [ "$d" = "bc" ]; then
90 # I use these, so unset them to make the tests work.
96 # Get the list of tests that require extra math.
97 extra_required=$(cat "$testdir/extra_required.txt")
99 printf '\nRunning %s tests...\n\n' "$d"
101 # Run the tests one at a time.
104 # If it requires extra, then skip if we don't have it.
105 if [ "$extra" -eq 0 ]; then
106 if [ -z "${extra_required##*$t*}" ]; then
107 printf 'Skipping %s %s\n' "$d" "$t"
112 sh "$testdir/test.sh" "$d" "$t" "$generate_tests" "$time_tests" "$exe" "$@"
114 done < "$testdir/$d/all.txt"
117 sh "$testdir/stdin.sh" "$d" "$exe" "$@"
120 sh "$testdir/scripts.sh" "$d" "$extra" "$run_stack_tests" "$generate_tests" \
121 "$time_tests" "$exe" "$@"
124 sh "$testdir/read.sh" "$d" "$exe" "$@"
127 sh "$testdir/errors.sh" "$d" "$exe" "$@"
130 sh "$testdir/other.sh" "$d" "$extra" "$exe" "$@"
133 sh "$testdir/history.sh" "$d" -a
135 printf '\nAll %s tests passed.\n' "$d"
137 printf '\n%s\n' "$stars"