Skip to content

Commit

Permalink
Fix advocat giving false positives for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rdvdev2 committed Dec 3, 2021
1 parent 4234c45 commit d69ec30
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions advocat.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

AV_VERSION="1.2"
AV_VERSION="1.3"
AV_COMPILER="p1++"
AV_DIR="${HOME}/.advocat"

Expand All @@ -15,8 +15,8 @@ AV_NC='\033[0m' # No Color
_advocat_run_test () {
local INDEX=$1
local BINARY=$2
local INPUTS=$3
local OUTPUTS=$4
local INPUT=$3
local EXPECT_OUTPUT=$4
local SKIP=$5

if [ "${INDEX}" -lt 0 ]; then
Expand All @@ -29,17 +29,18 @@ _advocat_run_test () {
echo -e "${AV_CYAN}SKIP ✘${AV_NC}"
return 0
else
${BINARY} < "${INPUTS}" > "${INPUTS%.*}.out"
if cmp -s "${OUTPUTS}" "${INPUTS%.*}.out"
local EXEC_OUTPUT="${INPUT%.*}.out"
${BINARY} < "${INPUT}" > "${EXEC_OUTPUT}"
if cmp -s "${EXPECT_OUTPUT}" "${EXEC_OUTPUT}"
then
echo -e "${AV_GREEN}PASS ✓${AV_NC}"
return 1
else
echo -e "${AV_RED}FAIL ✘${AV_NC}"
echo -e "${AV_PURPLE}==> Program output:"
cat "${TEST_INPUT%.*}.out"
cat "${EXEC_OUTPUT}"
echo -e "==> Expected output:"
cat "${TEST_INPUT%.*}.cor"
cat "${EXPECT_OUTPUT}"
echo -e -n "${AV_NC}"
return 0
fi
Expand Down Expand Up @@ -185,7 +186,7 @@ advocat () {
for TEST_INPUT in ${SAMPLES}
do
TEST_COUNT=$((TEST_COUNT + 1))
_advocat_run_test "$TEST_COUNT" "${BINARY}" "${TEST_INPUT}" "${TEST_INPUT%.*}.out" "${SKIP_TESTS}"
_advocat_run_test "$TEST_COUNT" "${BINARY}" "${TEST_INPUT}" "${TEST_INPUT%.*}.cor" "${SKIP_TESTS}"
PASS_COUNT=$((PASS_COUNT + $?))
done
echo
Expand Down

0 comments on commit d69ec30

Please sign in to comment.