diff --git a/scripts/common_cmdline.sh b/scripts/common_cmdline.sh index 7b452d857..59c334a4b 100644 --- a/scripts/common_cmdline.sh +++ b/scripts/common_cmdline.sh @@ -25,20 +25,24 @@ OLDARGS=(--optimize --combined-json "abi,asm,ast,bin,bin-runtime,devdoc,interfac function compileFull() { local expected_exit_code=0 - local expect_output=0 - if [[ $1 = '-e' ]]; then - expected_exit_code=1 - expect_output=1 - shift; - fi - if [[ $1 = '-w' ]]; then - expect_output=1 - shift; - fi - if [[ $1 = '-o' ]]; then - expect_output=2 - shift; - fi + local expect_output='none' + + case "$1" in + '--expect-errors') + expected_exit_code=1 + expect_output='warnings-or-errors' + shift; + ;; + '--expect-warnings') + expect_output='warnings-or-errors' + shift; + ;; + '--ignore-warnings') + expect_output='any' + shift; + ;; + esac + local args=("${FULLARGS[@]}") if [[ $1 = '-v' ]]; then if (echo "$2" | grep -Po '(?<=0.4.)\d+' >/dev/null); then @@ -71,20 +75,31 @@ function compileFull() set -e rm "$stderr_path" - if [[ \ - ("$exit_code" -ne "$expected_exit_code" || \ - ( $expect_output -eq 0 && -n "$errors" ) || \ - ( $expect_output -ne 0 && $expected_exit_code -eq 0 && $expect_output -ne 2 && -z "$errors" )) + if [[ + $exit_code != "$expected_exit_code" || + $errors != "" && $expect_output == 'none' || + $errors == "" && $expect_output != 'none' && $expect_output != 'any' && $expected_exit_code == 0 ]] then - printError "Unexpected compilation result:" - printError "Expected failure: $expected_exit_code - Expected warning / error output: $expect_output" - printError "Was failure: $exit_code" + printError "TEST FAILURE" + printError "Actual exit code: $exit_code" + printError "Expected exit code: $expected_exit_code" + printError "==== Output ====" echo "$errors" + printError "== Output end ==" + printError "" + case "$expect_output" in + 'none') printError "No output was expected." ;; + 'warnings-or-errors') printError "Expected warnings or errors." ;; + esac + + printError "" printError "While calling:" - echo "\"$SOLC\" ${args[*]} ${files[*]}" + echo "\"$SOLC\" ${args[*]} ${files[*]}" printError "Inside directory:" - pwd + echo " $(pwd)" + printError "Input was:" + cat -- "${files[@]}" false fi } diff --git a/scripts/docs_version_pragma_check.sh b/scripts/docs_version_pragma_check.sh index d7ca3f2ad..d16645da8 100755 --- a/scripts/docs_version_pragma_check.sh +++ b/scripts/docs_version_pragma_check.sh @@ -156,11 +156,11 @@ SOLTMPDIR=$(mktemp -d) if ( ! grep -E "This will not compile after" "$f" >/dev/null && \ grep -E "This will not compile|import \"" "$f" >/dev/null ) then - opts=(-e) + opts=(--expect-errors) fi # ignore warnings in this case - opts+=(-o) + opts+=(--ignore-warnings) findMinimalVersion "$f" if [[ "$version" == "" ]] diff --git a/test/cmdlineTests.sh b/test/cmdlineTests.sh index 37a538328..582a7acde 100755 --- a/test/cmdlineTests.sh +++ b/test/cmdlineTests.sh @@ -369,7 +369,7 @@ printTask "Compiling various other contracts and libraries..." do echo " - $dir" cd "$dir" - compileFull -w ./*.sol ./*/*.sol + compileFull --expect-warnings ./*.sol ./*/*.sol cd .. done ) @@ -397,15 +397,15 @@ SOLTMPDIR=$(mktemp -d) # are used (in the style guide) if grep -E "This will not compile|import \"" "$f" >/dev/null then - opts=(-e) + opts=(--expect-errors) fi if grep "This will report a warning" "$f" >/dev/null then - opts+=(-w) + opts+=(--expect-warnings) fi if grep "This may report a warning" "$f" >/dev/null then - opts+=(-o) + opts+=(--ignore-warnings) fi # Disable the version pragma in code snippets that only work with the current development version.