solidity/test/stopAfterParseTests.sh

75 lines
1.5 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
2020-07-08 20:08:50 +00:00
set -e
READLINK=readlink
if [[ "$OSTYPE" == "darwin"* ]]; then
READLINK=greadlink
fi
REPO_ROOT=$(${READLINK} -f "$(dirname "$0")"/..)
2020-07-08 20:08:50 +00:00
SOLIDITY_BUILD_DIR=${SOLIDITY_BUILD_DIR:-${REPO_ROOT}/build}
SOLC=${SOLIDITY_BUILD_DIR}/solc/solc
SPLITSOURCES=${REPO_ROOT}/scripts/splitSources.py
FILETMP=$(mktemp -d)
cd "$FILETMP" || exit 1
function testFile
2020-07-08 20:08:50 +00:00
{
set +e
ALLOUTPUT=$($SOLC --combined-json ast --pretty-json "$@" --stop-after parsing 2>&1)
local RESULT=$?
set -e
if test ${RESULT} -ne 0; then
2020-07-08 20:08:50 +00:00
# solc returned failure. Compilation errors and unimplemented features
# are okay, everything else is a failed test (segfault)
if ! echo "$ALLOUTPUT" | grep -e "Unimplemented feature:" -e "Error:" -q; then
echo -n "Test failed on "
2020-07-08 20:08:50 +00:00
echo "$@"
echo "$ALLOUTPUT"
return 1
2020-07-08 20:08:50 +00:00
fi
else
echo -n .
fi
return 0;
}
while read -r file; do
set +e
2020-07-08 20:08:50 +00:00
OUTPUT=$($SPLITSOURCES "$file")
RETURN_CODE=$?
set -e
2020-07-08 20:08:50 +00:00
FAILED=0
if [ $RETURN_CODE -eq 0 ]
then
# shellcheck disable=SC2086
testFile $OUTPUT
FAILED=$?
rm -r "${FILETMP:?}"/*
2020-07-08 20:08:50 +00:00
elif [ $RETURN_CODE -eq 1 ]
then
testFile "$file"
FAILED=$?
elif [ $RETURN_CODE -eq 2 ]
then
echo -n "<skipping utf8 error>"
else
echo "Received unexpected return code $RETURN_CODE while processing $file: "
echo "-----"
echo "$OUTPUT"
exit 3
fi
if [ $FAILED -eq 1 ]
then
echo -n "Failure on "
echo "$file"
exit 1
fi
done < <(find "${REPO_ROOT}/test" -iname "*.sol" -and -not -name "documentation.sol" -and -not -name "boost_filesystem_bug.sol")
2020-07-08 20:08:50 +00:00
echo