2020-10-28 22:59:56 +00:00
|
|
|
#!/usr/bin/env bash
|
2020-07-08 20:08:50 +00:00
|
|
|
|
2020-10-28 22:59:56 +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
|
|
|
|
|
|
|
|
|
2021-10-28 09:58:47 +00:00
|
|
|
function testFile
|
2020-07-08 20:08:50 +00:00
|
|
|
{
|
2020-10-28 22:59:56 +00:00
|
|
|
set +e
|
2021-09-30 14:17:36 +00:00
|
|
|
ALLOUTPUT=$($SOLC --combined-json ast --pretty-json "$@" --stop-after parsing 2>&1)
|
2020-10-28 22:59:56 +00:00
|
|
|
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
|
2020-10-28 22:59:56 +00:00
|
|
|
echo -n "Test failed on "
|
2020-07-08 20:08:50 +00:00
|
|
|
echo "$@"
|
|
|
|
echo "$ALLOUTPUT"
|
2020-10-28 22:59:56 +00:00
|
|
|
return 1
|
2020-07-08 20:08:50 +00:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo -n .
|
|
|
|
fi
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
while read -r file; do
|
2020-10-28 22:59:56 +00:00
|
|
|
set +e
|
2020-07-08 20:08:50 +00:00
|
|
|
OUTPUT=$($SPLITSOURCES "$file")
|
|
|
|
RETURN_CODE=$?
|
2020-10-28 22:59:56 +00:00
|
|
|
set -e
|
2020-07-08 20:08:50 +00:00
|
|
|
FAILED=0
|
|
|
|
|
|
|
|
if [ $RETURN_CODE -eq 0 ]
|
|
|
|
then
|
|
|
|
# shellcheck disable=SC2086
|
|
|
|
testFile $OUTPUT
|
|
|
|
FAILED=$?
|
2020-10-28 22:59:56 +00:00
|
|
|
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
|
2021-02-03 14:54:45 +00:00
|
|
|
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
|