mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Simplify error handling
This commit is contained in:
parent
1a8683597f
commit
3bd071d4e4
@ -104,32 +104,14 @@ do
|
||||
FILETMP=$(mktemp -d)
|
||||
cd "$FILETMP"
|
||||
|
||||
set +e
|
||||
# NOTE: The command returns the name of the input file if it's not a multi-source file
|
||||
OUTPUT=$("$SPLITSOURCES" "$solfile")
|
||||
SPLITSOURCES_RC=$?
|
||||
set -e
|
||||
if [ ${SPLITSOURCES_RC} == 0 ]
|
||||
then
|
||||
# echo $OUTPUT
|
||||
NSOURCES=$((NSOURCES - 1))
|
||||
for i in $OUTPUT;
|
||||
do
|
||||
testImportExportEquivalence "$i" "$OUTPUT"
|
||||
NSOURCES=$((NSOURCES + 1))
|
||||
done
|
||||
elif [ ${SPLITSOURCES_RC} == 1 ]
|
||||
then
|
||||
testImportExportEquivalence "$solfile"
|
||||
else
|
||||
# All other return codes will be treated as critical errors. The script will exit.
|
||||
echo -e "\nGot unexpected return code ${SPLITSOURCES_RC} from ${SPLITSOURCES}. Aborting."
|
||||
|
||||
cd "$WORKINGDIR"
|
||||
# Delete temporary files
|
||||
rm -rf "$FILETMP"
|
||||
|
||||
exit 1
|
||||
fi
|
||||
NSOURCES=$((NSOURCES - 1))
|
||||
while IFS="" read -r current_file_name
|
||||
do
|
||||
testImportExportEquivalence "$current_file_name" "$OUTPUT"
|
||||
NSOURCES=$((NSOURCES + 1))
|
||||
done <<< "$OUTPUT"
|
||||
|
||||
cd "$WORKINGDIR"
|
||||
# Delete temporary files
|
||||
|
@ -17,14 +17,6 @@ hasMultipleSources = False
|
||||
createdSources = []
|
||||
|
||||
|
||||
def uncaught_exception_hook(exc_type, exc_value, exc_traceback):
|
||||
# The script `scripts/ASTImportTest.sh` will interpret return code 3
|
||||
# as a critical error (because of the uncaught exception) and will
|
||||
# terminate further execution.
|
||||
print("Unhandled exception: %s", "".join(traceback.format_exception(exc_type, exc_value, exc_traceback)), file=sys.stderr)
|
||||
sys.exit(3)
|
||||
|
||||
|
||||
def extractSourceName(line):
|
||||
if line.find("/") > -1:
|
||||
filePath = line[13: line.rindex("/")]
|
||||
@ -57,7 +49,6 @@ def writeSourceToFile(lines):
|
||||
|
||||
if __name__ == '__main__':
|
||||
filePath = sys.argv[1]
|
||||
sys.excepthook = uncaught_exception_hook
|
||||
|
||||
# decide if file has multiple sources
|
||||
with open(filePath, mode='rb', encoding='utf8', newline='') as f:
|
||||
@ -71,6 +62,5 @@ if __name__ == '__main__':
|
||||
for src in createdSources:
|
||||
srcString += src + ' '
|
||||
print(srcString)
|
||||
sys.exit(0)
|
||||
else:
|
||||
sys.exit(1)
|
||||
print(filePath)
|
||||
|
@ -38,27 +38,12 @@ function testFile
|
||||
}
|
||||
|
||||
while read -r file; do
|
||||
set +e
|
||||
OUTPUT=$($SPLITSOURCES "$file")
|
||||
RETURN_CODE=$?
|
||||
set -e
|
||||
FAILED=0
|
||||
# NOTE: The command returns the name of the input file if it's not a multi-source file
|
||||
OUTPUT="$($SPLITSOURCES "$file")"
|
||||
|
||||
if [ $RETURN_CODE -eq 0 ]
|
||||
then
|
||||
# shellcheck disable=SC2086
|
||||
testFile $OUTPUT
|
||||
FAILED=$?
|
||||
rm -r "${FILETMP:?}"/*
|
||||
elif [ $RETURN_CODE -eq 1 ]
|
||||
then
|
||||
testFile "$file"
|
||||
FAILED=$?
|
||||
else
|
||||
# NOTE: The split script is expected to print error details to stderr in this case.
|
||||
echo "$SPLITSOURCES exited with code $RETURN_CODE while processing $file."
|
||||
exit 3
|
||||
fi
|
||||
testFile "$OUTPUT"
|
||||
FAILED=$?
|
||||
rm -r "${FILETMP:?}"/* 2> /dev/null || true
|
||||
|
||||
if [ $FAILED -eq 1 ]
|
||||
then
|
||||
|
Loading…
Reference in New Issue
Block a user