From f101eb2940470fcd32c77d9506c039f87f3bc735 Mon Sep 17 00:00:00 2001 From: Pantelis Antoniou Date: Fri, 27 Sep 2024 12:05:32 +0300 Subject: [PATCH] test: Rework skip and xfails (addressing a fail with latest jq) Rework the testsuite using bash mappings, making things simpler and faster. Also fix a failing test due to jq changes. Signed-off-by: Pantelis Antoniou --- test/testsuite-evstream.test | 28 +++++++++++++--------------- test/testsuite-json.test | 31 +++++++++++++++---------------- test/testsuite-resolution.test | 31 +++++++++++++++---------------- 3 files changed, 43 insertions(+), 47 deletions(-) diff --git a/test/testsuite-evstream.test b/test/testsuite-evstream.test index f248534a..6105eac1 100755 --- a/test/testsuite-evstream.test +++ b/test/testsuite-evstream.test @@ -18,8 +18,10 @@ done # output plan echo 1..$count -skiplist="2JQS" -xfaillist="" +declare -A skips=( + [2JQS]="duplicate keys in testcase; cannot load as document" +) +declare -A xfails=() i=0 for basetst in test-suite-data/[A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9]/; do @@ -50,15 +52,13 @@ for basetst in test-suite-data/[A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9]/; do t=`mktemp` directive="" - for skip in $skiplist; do - if [ "$test_subtest_id" == "$skip" ]; then - directive=" # skip: duplicate keys in testcase; cannot load as document" - break - fi - done + skip_reason="${skips[$test_subtest_id]}" + if [ "x$skip_reason" != "x" ]; then + directive=" # SKIP: ${skip_reason}" + fi res="ok" - if [ "x$directive" == "x" ]; then + if [ "x$skip_reason" == "x" ]; then res="not ok" # run the test using document-event-stream ${TOP_BUILDDIR}/src/fy-tool --testsuite --document-event-stream "$tst/in.yaml" >"$t" @@ -75,12 +75,10 @@ for basetst in test-suite-data/[A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9]/; do rm -f "$t" - for xfail in $xfaillist; do - if [ "$test_subtest_id" == "$xfail" ]; then - directive=" # TODO: known failure." - break - fi - done + xfail_reason="${xfails[$test_subtest_id]}" + if [ "x$xfail_reason" != "x" ]; then + directive=" # TODO: ${xfail_reason}" + fi fi echo "$res $i $test_subtest_id - $desctxt$directive" diff --git a/test/testsuite-json.test b/test/testsuite-json.test index 4612c0cd..f5435a56 100755 --- a/test/testsuite-json.test +++ b/test/testsuite-json.test @@ -22,8 +22,12 @@ done # output plan echo 1..$count -skiplist="C4HZ" -xfaillist="" +declare -A skips=( + [UGM3]="Later jq versions rewrite numbers like 12.00 -> 12 which breaks diff" +) +declare -A xfails=( + [C4HZ]="requires schema support which libfyaml does not support yet." +) i=0 for basetst in test-suite-data/[A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9]/; do @@ -51,16 +55,13 @@ for basetst in test-suite-data/[A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9]/; do desctxt=`cat 2>/dev/null "$tst/==="` directive="" - for skip in $skiplist; do - if [ "$test_subtest_id" == "$skip" ]; then - directive="# SKIP: does not apply to libfyaml" - break - fi - done + skip_reason="${skips[$test_subtest_id]}" + if [ "x$skip_reason" != "x" ]; then + directive=" # SKIP: ${skip_reason}" + fi res="ok" - - if [ "x$directive" == "x" ]; then + if [ "x$skip_reason" == "x" ]; then t1=`mktemp` t2=`mktemp` @@ -79,12 +80,10 @@ for basetst in test-suite-data/[A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9]/; do rm -f "$t1" "$t2" - for xfail in $xfaillist; do - if [ "$test_subtest_id" == "$xfail" ]; then - directive=" # TODO: known failure." - break - fi - done + xfail_reason="${xfails[$test_subtest_id]}" + if [ "x$xfail_reason" != "x" ]; then + directive=" # TODO: ${xfail_reason}" + fi fi echo "$res $i $test_subtest_id - $desctxt (JSON)$directive" diff --git a/test/testsuite-resolution.test b/test/testsuite-resolution.test index 8b6675f3..d33f4a12 100755 --- a/test/testsuite-resolution.test +++ b/test/testsuite-resolution.test @@ -23,9 +23,12 @@ done # output plan echo 1..$count -# X38W has duplicate keys after resolution -skiplist="2JQS X38W" -xfaillist="" +declare -A skips=( + [2JQS]="duplicate keys in testcase; cannot load as document" + [X38W]="duplicate keys after resolution" +) +declare -A xfails=( +) i=0 for basetst in test-suite-data/[A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9]/; do @@ -63,15 +66,13 @@ for basetst in test-suite-data/[A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9]/; do t2=`mktemp` directive="" - for skip in $skiplist; do - if [ "$test_subtest_id" == "$skip" ]; then - directive=" # skip: duplicate keys in testcase; cannot load as document" - break - fi - done + skip_reason="${skips[$test_subtest_id]}" + if [ "x$skip_reason" != "x" ]; then + directive=" # SKIP: ${skip_reason}" + fi res="ok" - if [ "x$directive" == "x" ]; then + if [ "x$skip_reason" == "x" ]; then res="not ok" ${TOP_BUILDDIR}/src/fy-tool --dump --resolve "$tst/in.yaml" | ${TOP_BUILDDIR}/src/fy-tool --testsuite --disable-flow-markers - >"$t1" @@ -86,12 +87,10 @@ for basetst in test-suite-data/[A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9]/; do rm -f "$t1" "$t2" - for xfail in $xfaillist; do - if [ "$test_subtest_id" == "$xfail" ]; then - directive=" # TODO: known failure." - break - fi - done + xfail_reason="${xfails[$test_subtest_id]}" + if [ "x$xfail_reason" != "x" ]; then + directive=" # TODO: ${xfail_reason}" + fi fi echo "$res $i $test_subtest_id - $desctxt$directive"