Merge pull request #11991 from ethereum/fix-handling-of-empty-dirs-and-empty-files-in-cmdline-tests

Fix handling of empty dirs and empty files in command-line tests
This commit is contained in:
chriseth 2021-09-27 14:40:37 +02:00 committed by GitHub
commit aab6b8a3d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 8 deletions

View File

@ -65,7 +65,7 @@ if __name__ == '__main__':
# decide if file has multiple sources # decide if file has multiple sources
with open(filePath, mode='r', encoding='utf8', newline='') as f: with open(filePath, mode='r', encoding='utf8', newline='') as f:
lines = f.read().splitlines() lines = f.read().splitlines()
if lines[0][:12] == "==== Source:": if len(lines) >= 1 and lines[0][:12] == "==== Source:":
hasMultipleSources = True hasMultipleSources = True
writeSourceToFile(lines) writeSourceToFile(lines)

View File

@ -56,7 +56,8 @@ do
*) *)
matching_tests=$(find . -mindepth 1 -maxdepth 1 -type d -name "$1" | cut --characters 3- | sort) matching_tests=$(find . -mindepth 1 -maxdepth 1 -type d -name "$1" | cut --characters 3- | sort)
if [[ $matching_tests == "" ]]; then if [[ $matching_tests == "" ]]
then
patterns_with_no_matches+=("$1") patterns_with_no_matches+=("$1")
printWarning "No tests matching pattern '$1' found." printWarning "No tests matching pattern '$1' found."
else else
@ -69,7 +70,8 @@ do
esac esac
done done
if (( ${#selected_tests[@]} == 0 && ${#patterns_with_no_matches[@]} == 0 )); then if (( ${#selected_tests[@]} == 0 && ${#patterns_with_no_matches[@]} == 0 ))
then
selected_tests=(*) selected_tests=(*)
fi fi
popd > /dev/null popd > /dev/null
@ -94,7 +96,8 @@ then
fi fi
# extend stack size in case we run via ASAN # extend stack size in case we run via ASAN
if [[ -n "${CIRCLECI}" ]] || [[ -n "$CI" ]]; then if [[ -n "${CIRCLECI}" ]] || [[ -n "$CI" ]]
then
ulimit -s 16384 ulimit -s 16384
ulimit -a ulimit -a
fi fi
@ -169,7 +172,10 @@ function test_solc_behaviour()
# shellcheck disable=SC2064 # shellcheck disable=SC2064
trap "rm -f $stdout_path $stderr_path" EXIT trap "rm -f $stdout_path $stderr_path" EXIT
if [[ "$exit_code_expected" = "" ]]; then exit_code_expected="0"; fi if [[ "$exit_code_expected" = "" ]]
then
exit_code_expected="0"
fi
[[ $filename == "" ]] || solc_args+=("$filename") [[ $filename == "" ]] || solc_args+=("$filename")
@ -338,19 +344,27 @@ printTask "Running general commandline tests..."
cd "$REPO_ROOT"/test/cmdlineTests/ cd "$REPO_ROOT"/test/cmdlineTests/
for tdir in "${selected_tests[@]}" for tdir in "${selected_tests[@]}"
do do
if ! [[ -d $tdir ]]; then if ! [[ -d $tdir ]]
then
printError "Test directory not found: $tdir" printError "Test directory not found: $tdir"
exit 1 exit 1
fi fi
printTask " - ${tdir}" printTask " - ${tdir}"
if [[ $(ls -A "$tdir") == "" ]]
then
printWarning " ---> skipped (test dir empty)"
continue
fi
# Strip trailing slash from $tdir. # Strip trailing slash from $tdir.
tdir=$(basename "${tdir}") tdir=$(basename "${tdir}")
if [[ $no_smt == true ]] if [[ $no_smt == true ]]
then then
if [[ $tdir =~ .*model_checker_.* ]]; then if [[ $tdir =~ .*model_checker_.* ]]
printWarning " --- > skipped" then
printWarning " ---> skipped (SMT test)"
continue continue
fi fi
fi fi