From e73f003d33bfa05ff8d0d03ac9898d1a6b80c900 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Wed, 19 Oct 2022 13:13:48 -0400 Subject: [PATCH] skip some skippable tests (#3102) * tests: consolidate redundant, duplicated helper code These functions currently exist in a sourced shell library, but there is an identical copy of them in a single test file. Get rid of this duplicate definition. * tests: mark some tests as skipped if bc is not installed `exit 77` is the GNU exitcode protocol for tests that cannot be run because their prerequisites are not available. If `bc` is not installed, and it often isn't, the test can be short-circuited instead of failing; meson will report them in "warning yellow". * tests: mark some tests as skipped if support is not compiled Not all test cases can be cleanly marked as skipped -- sometimes, multiple things are checked, and having one be unavailable should not mean skipping all tests. But in a couple cases, a test file only tests one thing, and that may be skipped. In such cases, it can be semantically indicated in the test harness report collection, that a skip occurred. --- test/test_cli.sh | 26 -------------------------- test/test_connections.sh | 2 ++ test/test_stall.sh | 2 ++ test/variables.sh.in | 5 +++++ 4 files changed, 9 insertions(+), 26 deletions(-) diff --git a/test/test_cli.sh b/test/test_cli.sh index 6aa2636b..1a593e9b 100755 --- a/test/test_cli.sh +++ b/test/test_cli.sh @@ -7,32 +7,6 @@ . ./variables.sh -# is a difference beyond a threshold? return 0 (meaning all ok) or 1 (meaning -# error, or outside threshold) -# -# use bc since bash does not support fp math -break_threshold() { - diff=$1 - threshold=$2 - return $(echo "$diff <= $threshold" | bc -l) -} - -# subtract, look for max difference less than a threshold -test_difference() { - before=$1 - after=$2 - threshold=$3 - - $vips subtract $before $after $tmp/difference.v - $vips abs $tmp/difference.v $tmp/abs.v - dif=$($vips max $tmp/abs.v) - - if break_threshold $dif $threshold; then - echo "difference is $dif" - exit 1 - fi -} - test_rotate() { im=$1 inter=$2 diff --git a/test/test_connections.sh b/test/test_connections.sh index de59c9a1..6fd13ed8 100755 --- a/test/test_connections.sh +++ b/test/test_connections.sh @@ -12,4 +12,6 @@ if test_supported jpegload_source; then # test max difference < 10 test_difference $image $tmp/x.png 10 +else + exit 77 fi diff --git a/test/test_stall.sh b/test/test_stall.sh index c1050c3c..3959a258 100755 --- a/test/test_stall.sh +++ b/test/test_stall.sh @@ -14,4 +14,6 @@ if test_supported tiffload; then -1 -1 -1 EOF VIPS_STALL=1 $vips conv $tmp/x.tif $tmp/x2.tif $tmp/mask.con +else + exit 77 fi diff --git a/test/variables.sh.in b/test/variables.sh.in index 6ea2dfd7..1af7b47c 100644 --- a/test/variables.sh.in +++ b/test/variables.sh.in @@ -32,9 +32,14 @@ test_supported() { # is a difference beyond a threshold? return 0 (meaning all ok) or 1 (meaning # error, or outside threshold) +# +# use bc since bash does not support fp math break_threshold() { diff=$1 threshold=$2 + if ! command -v bc >/dev/null; then + exit 77 + fi return $(echo "$diff <= $threshold" | bc -l) }