From 0dc49b58728578cf304fda8e578c85e7cf868bd0 Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Mon, 7 Oct 2019 11:36:09 -0700 Subject: [PATCH] Add support for expected test failures --- tests/decompyle_test.sh | 85 ++++++++++++++---- tests/tokenized/test_empty.txt | 0 .../test_empty.1.5.pyc} | Bin .../test_empty.2.2.pyc} | Bin .../test_empty.2.5.pyc} | Bin tests/xfail/test_empty.2.7.pyc | Bin 0 -> 109 bytes tests/xfail/test_empty.3.0.pyc | Bin 0 -> 113 bytes tests/xfail/test_empty.3.7.pyc | Bin 0 -> 109 bytes 8 files changed, 69 insertions(+), 16 deletions(-) create mode 100644 tests/tokenized/test_empty.txt rename tests/{15_test_empty.pyc => xfail/test_empty.1.5.pyc} (100%) rename tests/{22_test_empty.pyc => xfail/test_empty.2.2.pyc} (100%) rename tests/{25_test_empty.pyc => xfail/test_empty.2.5.pyc} (100%) create mode 100644 tests/xfail/test_empty.2.7.pyc create mode 100644 tests/xfail/test_empty.3.0.pyc create mode 100644 tests/xfail/test_empty.3.7.pyc diff --git a/tests/decompyle_test.sh b/tests/decompyle_test.sh index 5dbe947..cb115dc 100755 --- a/tests/decompyle_test.sh +++ b/tests/decompyle_test.sh @@ -16,10 +16,11 @@ fi shopt -s nullglob compfiles=( "$testdir/compiled/$testname".?.?.pyc ) +xfcfiles=( "$testdir/xfail/$testname".?.?.pyc ) shopt -u nullglob -if (( ${#compfiles[@]} == 0 )); then - echo "No compiled modules found for compiled/$testname.*.pyc" +if (( ${#compfiles[@]} + ${#xfcfiles[@]} == 0 )); then + echo "No compiled/xfail modules found for $testname.*.pyc" exit 1 fi @@ -28,48 +29,100 @@ mkdir -p "$outdir" echo -ne "\033[1m*** $testname:\033[0m " fails=0 +xfails=0 +upass=0 efiles=() errors=() -for pyc in "${compfiles[@]}"; do +upfiles=() +for pyc in "${compfiles[@]}" "${xfcfiles[@]}"; do base="$outdir/$(basename "$pyc")" ./pycdc "$pyc" 2>"$base.err" 1>"$base.src.py" if (( $? )) || [[ -s "$base.err" ]] then - let fails+=1 - efiles+=("$(basename "$pyc")") - errors+=("$(cat "$base.err")") + if [[ "$(dirname "$pyc")" =~ xfail ]] + then + let xfails+=1 + else + let fails+=1 + efiles+=("$(basename "$pyc")") + errors+=("$(cat "$base.err")") + fi continue fi "$srcdir"/scripts/token_dump "$base.src.py" 2>"$base.tok.err" 1>"$base.tok.txt" if (( $? )) || [[ -s "$base.tok.err" ]] then - let fails+=1 - efiles+=("$(basename "$pyc")") - errors+=("$(cat "$base.tok.err")") + if [[ "$(dirname "$pyc")" =~ xfail ]] + then + let xfails+=1 + else + let fails+=1 + efiles+=("$(basename "$pyc")") + errors+=("$(cat "$base.tok.err")") + fi continue fi diff -u "$testdir/tokenized/$testname.txt" "$base.tok.txt" >"$base.tok.diff" if (( $? )) then - let fails+=1 - efiles+=("$(basename "$pyc")") - errors+=("$base.tok.txt does not match $testdir/tokenized/$testname.txt:\n$(cat "$base.tok.diff")") - continue + if [[ "$(dirname "$pyc")" =~ xfail ]] + then + let xfails+=1 + else + let fails+=1 + efiles+=("$(basename "$pyc")") + errors+=("$base.tok.txt does not match $testdir/tokenized/$testname.txt:\n$(cat "$base.tok.diff")") + fi + else + if [[ "$(dirname "$pyc")" =~ xfail ]] + then + let upass+=1 + upfiles+=("$(basename "$pyc")") + fi fi done if (( $fails == 0 )) then - echo -e "\033[32mPASS (${#compfiles[@]})\033[m" + if (( $xfails != 0 )) + then + if (( ${#compfiles[@]} == 0 )) + then + echo -e "\033[33mXFAIL ($xfails)\033[0m" + else + echo -e "\033[32mPASS (${#compfiles[@]})\033[33m + XFAIL ($xfails)\033[0m" + fi + else + echo -e "\033[32mPASS (${#compfiles[@]})\033[0m" + fi else - echo -e "\033[31mFAIL ($fails of ${#compfiles[@]})\033[m" + if (( $xfails != 0 )) + then + echo -e "\033[31mFAIL ($fails of ${#compfiles[@]})\033[33m + XFAIL ($xfails)\033[0m" + else + echo -e "\033[31mFAIL ($fails of ${#compfiles[@]})\033[0m" + fi + for ((i=0; i<${#efiles[@]}; i++)) do - echo -e "\t\033[31m${efiles[i]}\033[m" + echo -e "\t\033[31m${efiles[i]}\033[0m" echo -e "${errors[i]}\n" done +fi + +if (( $upass != 0 )) +then + echo -e "\033[1;34mUnexpected passes:\033[0m" + for ((i=0; i<${#upfiles[@]}; i++)) + do + echo -e "\t\033[33m${upfiles[i]}\033[0m" + done +fi + +if (( $fails != 0 )) +then exit 1 fi diff --git a/tests/tokenized/test_empty.txt b/tests/tokenized/test_empty.txt new file mode 100644 index 0000000..e69de29 diff --git a/tests/15_test_empty.pyc b/tests/xfail/test_empty.1.5.pyc similarity index 100% rename from tests/15_test_empty.pyc rename to tests/xfail/test_empty.1.5.pyc diff --git a/tests/22_test_empty.pyc b/tests/xfail/test_empty.2.2.pyc similarity index 100% rename from tests/22_test_empty.pyc rename to tests/xfail/test_empty.2.2.pyc diff --git a/tests/25_test_empty.pyc b/tests/xfail/test_empty.2.5.pyc similarity index 100% rename from tests/25_test_empty.pyc rename to tests/xfail/test_empty.2.5.pyc diff --git a/tests/xfail/test_empty.2.7.pyc b/tests/xfail/test_empty.2.7.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d31bc15146a9546cc85dc046acaeda8e0ef078f3 GIT binary patch literal 109 zcmZSn%*&OzY=3rZ^W3MxxDfKoQO`6;D2sdgX(N`ROF0EMj*!vFvP literal 0 HcmV?d00001 diff --git a/tests/xfail/test_empty.3.0.pyc b/tests/xfail/test_empty.3.0.pyc new file mode 100644 index 0000000000000000000000000000000000000000..dfc1460669406ce2fa96e53bd26665d9e1144290 GIT binary patch literal 113 zcmcEK;pNI)Ha#|(0SPby*$zNl%mO4*7#M;zKq7t`K!O2{C=~;W>FMcb<`tBd=$E7x gm&B*$7L-)#6;zgT0Hthl^HWN5Qtdzn6az5>07sY-761SM literal 0 HcmV?d00001 diff --git a/tests/xfail/test_empty.3.7.pyc b/tests/xfail/test_empty.3.7.pyc new file mode 100644 index 0000000000000000000000000000000000000000..afe7375100d26c2bba1ca22ae6193b2c37ff9cfe GIT binary patch literal 109 zcmZ?b<>g`kg3M*pV?p#|5CH>>K!yVl7qb9~6oz01O-8?!3`HPe1o2BuPftHHub{L< iza+J|BtA8_prlf-pz;=nO>TZlX-=vgNd0FZW&i-0K^1EN literal 0 HcmV?d00001