Skip to content

Commit 87979d5

Browse files
authored
Add '|| exit' when loading cmd_test_common.sh (#2739)
Makes sure tests fail if cmd_test_common.sh fails to load. In some cases, add "set -eu" at the top of the file when there is other code before loading the common script.
1 parent e176f5b commit 87979d5

17 files changed

+21
-15
lines changed

tests/cmd_test_common.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# the test: source $(dirname "$0")/cmd_test_common.sh
1919

2020
# Very verbose but useful for debugging.
21-
set -ex
21+
set -eux
2222

2323
if [[ "$#" -ge 1 ]]; then
2424
# eval so that the passed in directory can contain variables.

tests/golden_test_common.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# The paths to avifenc and to the testdata dir will be passed as arguments.
1212
# See 'test_cmd_enc_boxes_golden.sh' for an example.
1313

14-
set -e
14+
set -eu
1515

1616
if [[ "$#" -ge 1 ]]; then
1717
# eval so that the passed in directory can contain variables.

tests/test_cmd.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@
1616
#
1717
# tests for command lines
1818

19-
source $(dirname "$0")/cmd_test_common.sh
19+
source $(dirname "$0")/cmd_test_common.sh || exit
2020

2121
# Basic calls.
2222
"${AVIFENC}" --version
2323
"${AVIFDEC}" --version
2424

2525
# Input file paths.
2626
INPUT_Y4M="${TESTDATA_DIR}/kodim03_yuv420_8bpc.y4m"
27+
INPUT_PNG="${TESTDATA_DIR}/circle-trns-after-plte.png"
2728
INPUT_UTF8_Y4M="🐾.y4m"
2829
# Output file names.
2930
ENCODED_FILE="avif_test_cmd_encoded.avif"

tests/test_cmd_animation.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# limitations under the License.
1515
# ------------------------------------------------------------------------------
1616

17-
source $(dirname "$0")/cmd_test_common.sh
17+
source $(dirname "$0")/cmd_test_common.sh || exit
1818

1919
# Input file paths.
2020
INPUT_Y4M_0="${TESTDATA_DIR}/kodim03_yuv420_8bpc.y4m"

tests/test_cmd_avifgainmaputil.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# tests for command lines (avifgainmaputil tool)
66

7-
source $(dirname "$0")/cmd_test_common.sh
7+
source $(dirname "$0")/cmd_test_common.sh || exit
88

99
AVIFGAINMAPUTIL="${BINARY_DIR}/avifgainmaputil"
1010

tests/test_cmd_avm.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#
1717
# tests for command lines
1818

19-
source $(dirname "$0")/cmd_test_common.sh
19+
source $(dirname "$0")/cmd_test_common.sh || exit
2020

2121
# Basic calls.
2222
"${AVIFENC}" --version

tests/test_cmd_avm_lossless.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#
1717
# tests for command lines (lossless)
1818

19-
source $(dirname "$0")/cmd_test_common.sh
19+
source $(dirname "$0")/cmd_test_common.sh || exit
2020

2121
# Input file paths.
2222
INPUT_PNG="${TESTDATA_DIR}/ArcTriomphe-cHRM-orig.png"

tests/test_cmd_enc_boxes_golden.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@
1212
# But most of the time you will be running this test with 'make test' or
1313
# 'ctest -V -R test_cmd_enc_boxes_golden'
1414

15+
set -eu
16+
1517
# ===================================
1618
# ========== Encode files ===========
1719
# ===================================
1820
# To add new test case, just add new encode commands to this function.
1921
# All .avif files created here will become test cases.
22+
2023
encode_test_files() {
2124
AVIFENC="$1"
2225
TESTDATA_DIR="$2"

tests/test_cmd_enc_gainmap_boxes_golden.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
# But most of the time you will be running this test with 'make test' or
1414
# 'ctest -V -R test_cmd_enc_gainmap_boxes_golden'
1515

16+
set -eu
17+
1618
# ===================================
1719
# ========== Encode files ===========
1820
# ===================================

tests/test_cmd_gainmap.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#
1717
# tests for command lines (gain maps)
1818

19-
source $(dirname "$0")/cmd_test_common.sh
19+
source $(dirname "$0")/cmd_test_common.sh || exit
2020

2121
# Input file paths.
2222
INPUT_JPEG_GAINMAP="${TESTDATA_DIR}/paris_exif_xmp_gainmap_bigendian.jpg"

0 commit comments

Comments
 (0)