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} SOLIDITY_BUILD_DIR=${SOLIDITY_BUILD_DIR:-${REPO_ROOT}/build}
SOLC=${SOLIDITY_BUILD_DIR}/solc/solc SOLC=${SOLIDITY_BUILD_DIR}/solc/solc
SPLITSOURCES=${REPO_ROOT}/scripts/splitSources.py SPLITSOURCES=${REPO_ROOT}/scripts/splitSources.py
@ -11,15 +17,18 @@ cd "$FILETMP" || exit 1
function testFile() function testFile()
{ {
set +e
ALLOUTPUT=$($SOLC --combined-json ast,compact-format --pretty-json "$@" --stop-after parsing 2>&1) 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 # solc returned failure. Compilation errors and unimplemented features
# are okay, everything else is a failed test (segfault) # are okay, everything else is a failed test (segfault)
if ! echo "$ALLOUTPUT" | grep -e "Unimplemented feature:" -e "Error:" -q; then if ! echo "$ALLOUTPUT" | grep -e "Unimplemented feature:" -e "Error:" -q; then
echo -n "Test failed on "; echo -n "Test failed on "
echo "$@" echo "$@"
echo "$ALLOUTPUT" echo "$ALLOUTPUT"
return 1; return 1
fi fi
else else
echo -n . echo -n .
@ -29,8 +38,10 @@ function testFile()
} }
while read -r file; do while read -r file; do
set +e
OUTPUT=$($SPLITSOURCES "$file") OUTPUT=$($SPLITSOURCES "$file")
RETURN_CODE=$? RETURN_CODE=$?
set -e
FAILED=0 FAILED=0
if [ $RETURN_CODE -eq 0 ] if [ $RETURN_CODE -eq 0 ]
@ -38,8 +49,7 @@ while read -r file; do
# shellcheck disable=SC2086 # shellcheck disable=SC2086
testFile $OUTPUT testFile $OUTPUT
FAILED=$? FAILED=$?
rm -r "${FILETMP:?}"/*
rm "${FILETMP:?}/"* -r
elif [ $RETURN_CODE -eq 1 ] elif [ $RETURN_CODE -eq 1 ]
then then
testFile "$file" testFile "$file"