Fix test/stopAfterParseTests.sh for macos.

This commit is contained in:
Alexander Arlt 2020-10-28 17:59:56 -05:00
parent f42280f5c9
commit ff7c47a1f3

View File

@ -1,6 +1,12 @@
#! /usr/bin/env bash
#!/usr/bin/env bash
REPO_ROOT=$(readlink -f "$(dirname "$0")"/..)
set -e
READLINK=readlink
if [[ "$OSTYPE" == "darwin"* ]]; then
READLINK=greadlink
fi
REPO_ROOT=$(${READLINK} -f "$(dirname "$0")"/..)
SOLIDITY_BUILD_DIR=${SOLIDITY_BUILD_DIR:-${REPO_ROOT}/build}
SOLC=${SOLIDITY_BUILD_DIR}/solc/solc
SPLITSOURCES=${REPO_ROOT}/scripts/splitSources.py
@ -11,15 +17,18 @@ cd "$FILETMP" || exit 1
function testFile()
{
set +e
ALLOUTPUT=$($SOLC --combined-json ast,compact-format --pretty-json "$@" --stop-after parsing 2>&1)
if test $? -ne 0; then
local RESULT=$?
set -e
if test ${RESULT} -ne 0; then
# 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 ";
echo -n "Test failed on "
echo "$@"
echo "$ALLOUTPUT"
return 1;
return 1
fi
else
echo -n .
@ -29,8 +38,10 @@ function testFile()
}
while read -r file; do
set +e
OUTPUT=$($SPLITSOURCES "$file")
RETURN_CODE=$?
set -e
FAILED=0
if [ $RETURN_CODE -eq 0 ]
@ -38,8 +49,7 @@ while read -r file; do
# shellcheck disable=SC2086
testFile $OUTPUT
FAILED=$?
rm "${FILETMP:?}/"* -r
rm -r "${FILETMP:?}"/*
elif [ $RETURN_CODE -eq 1 ]
then
testFile "$file"