diff options
author | chriseth <chris@ethereum.org> | 2018-08-09 20:58:28 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-08-14 21:50:46 +0800 |
commit | f873389c6227d41dbba9ba4c23ed055f286ecb71 (patch) | |
tree | 03cd6596754f48ede98a93c9d05d248b410a58ba | |
parent | 8f0c2a46db787de166f7bcaed2180fcab9248d12 (diff) | |
download | dexon-solidity-f873389c6227d41dbba9ba4c23ed055f286ecb71.tar dexon-solidity-f873389c6227d41dbba9ba4c23ed055f286ecb71.tar.gz dexon-solidity-f873389c6227d41dbba9ba4c23ed055f286ecb71.tar.bz2 dexon-solidity-f873389c6227d41dbba9ba4c23ed055f286ecb71.tar.lz dexon-solidity-f873389c6227d41dbba9ba4c23ed055f286ecb71.tar.xz dexon-solidity-f873389c6227d41dbba9ba4c23ed055f286ecb71.tar.zst dexon-solidity-f873389c6227d41dbba9ba4c23ed055f286ecb71.zip |
Test that documentation does not contain any warnings.
-rwxr-xr-x | scripts/isolate_tests.py | 16 | ||||
-rwxr-xr-x | test/cmdlineTests.sh | 65 |
2 files changed, 44 insertions, 37 deletions
diff --git a/scripts/isolate_tests.py b/scripts/isolate_tests.py index 1f913504..57fc7ff0 100755 --- a/scripts/isolate_tests.py +++ b/scripts/isolate_tests.py @@ -56,20 +56,10 @@ def extract_docs_cases(path): else: tests[-1] += l + '\n' else: - m = re.search(r'^ // This will not compile', l) + m = re.search(r'^ pragma solidity .*[0-9]+\.[0-9]+\.[0-9]+;$', l) if m: - ignore = True - - if ignore: - # Abort if indentation is missing - m = re.search(r'^[^ ]+', l) - if m: - ignore = False - else: - m = re.search(r'^ pragma solidity .*[0-9]+\.[0-9]+\.[0-9]+;$', l) - if m: - inside = True - tests += [l] + inside = True + tests += [l] return tests diff --git a/test/cmdlineTests.sh b/test/cmdlineTests.sh index a260da34..e0ef4461 100755 --- a/test/cmdlineTests.sh +++ b/test/cmdlineTests.sh @@ -43,18 +43,42 @@ function printError() { echo "$(tput setaf 1)$1$(tput sgr0)"; } 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 + local files="$*" - local output failed + local output + + local stderr_path=$(mktemp) set +e - output=$( ("$SOLC" $FULLARGS $files) 2>&1 ) - failed=$? + "$SOLC" $FULLARGS $files >/dev/null 2>"$stderr_path" + local exit_code=$? + local errors=$(grep -v -E 'Warning: This is a pre-release compiler version|Warning: Experimental features are turned on|pragma experimental ABIEncoderV2|\^-------------------------------\^' < "$stderr_path") set -e + rm "$stderr_path" - if [ $failed -ne 0 ] + if [[ \ + "$exit_code" -ne "$expected_exit_code" || \ + ( $expect_output -eq 0 && -n "$errors" ) || \ + ( $expect_output -ne 0 && -z "$errors" ) \ + ]] then - printError "Compilation failed on:" - echo "$output" + printError "Unexpected compilation result:" + printError "Expected failure: $expected_exit_code - Expected warning / error output: $expect_output" + printError "Was failure: $exit_code" + echo "$errors" printError "While calling:" echo "\"$SOLC\" $FULLARGS $files" printError "Inside directory:" @@ -63,22 +87,6 @@ function compileFull() fi } -function compileWithoutWarning() -{ - local files="$*" - local output failed - - set +e - output=$("$SOLC" $files 2>&1) - failed=$? - # Remove the pre-release warning from the compiler output - output=$(echo "$output" | grep -v 'pre-release') - echo "$output" - set -e - - test -z "$output" -a "$failed" -eq 0 -} - printTask "Testing unknown options..." ( set +e @@ -157,7 +165,7 @@ do then echo " - $dir" cd "$dir" - compileFull *.sol */*.sol + compileFull -w *.sol */*.sol cd .. fi done @@ -174,7 +182,16 @@ TMPDIR=$(mktemp -d) for f in *.sol do echo "$f" - compileFull "$TMPDIR/$f" + opts='' + if grep "This will not compile" "$f" >/dev/null + then + opts="-e" + fi + if grep "This will report a warning" "$f" >/dev/null + then + opts="$opts -w" + fi + compileFull $opts "$TMPDIR/$f" done ) rm -rf "$TMPDIR" |