diff options
author | chriseth <chris@ethereum.org> | 2017-07-14 04:16:49 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-14 04:16:49 +0800 |
commit | 63bf0f68e6d232eccf6d64ca2bba5b39e108ea41 (patch) | |
tree | 2e6468e73cc51830328f4f323b2d84b406b0399a /test | |
parent | b5da5f6e42c9d60206d5045ace471c7b5839ed30 (diff) | |
parent | a8d78bb7675f81dd992a588582501d7db6d578d2 (diff) | |
download | dexon-solidity-63bf0f68e6d232eccf6d64ca2bba5b39e108ea41.tar dexon-solidity-63bf0f68e6d232eccf6d64ca2bba5b39e108ea41.tar.gz dexon-solidity-63bf0f68e6d232eccf6d64ca2bba5b39e108ea41.tar.bz2 dexon-solidity-63bf0f68e6d232eccf6d64ca2bba5b39e108ea41.tar.lz dexon-solidity-63bf0f68e6d232eccf6d64ca2bba5b39e108ea41.tar.xz dexon-solidity-63bf0f68e6d232eccf6d64ca2bba5b39e108ea41.tar.zst dexon-solidity-63bf0f68e6d232eccf6d64ca2bba5b39e108ea41.zip |
Merge pull request #2553 from ethereum/extract-docs-tests
Extract examples from documentation and run tests on it
Diffstat (limited to 'test')
-rwxr-xr-x | test/cmdlineTests.sh | 73 |
1 files changed, 67 insertions, 6 deletions
diff --git a/test/cmdlineTests.sh b/test/cmdlineTests.sh index 4074ce55..eb5c714d 100755 --- a/test/cmdlineTests.sh +++ b/test/cmdlineTests.sh @@ -28,27 +28,87 @@ set -e -REPO_ROOT="$(dirname "$0")"/.. +REPO_ROOT=$(cd $(dirname "$0")/.. && pwd) +echo $REPO_ROOT SOLC="$REPO_ROOT/build/solc/solc" echo "Checking that the bug list is up to date..." "$REPO_ROOT"/scripts/update_bugs_by_version.py -echo "Compiling all files in std and examples..." +echo "Checking that StandardToken.sol, owned.sol and mortal.sol produce bytecode..." +output=$("$REPO_ROOT"/build/solc/solc --bin "$REPO_ROOT"/std/*.sol 2>/dev/null | grep "ffff" | wc -l) +test "${output//[[:blank:]]/}" = "3" -for f in "$REPO_ROOT"/std/*.sol -do - echo "Compiling $f..." +function compileFull() +{ + files="$*" + set +e + "$SOLC" --optimize \ + --combined-json abi,asm,ast,bin,bin-runtime,clone-bin,compact-format,devdoc,hashes,interface,metadata,opcodes,srcmap,srcmap-runtime,userdoc \ + $files >/dev/null 2>&1 + failed=$? + set -e + if [ $failed -ne 0 ] + then + echo "Compilation failed on:" + cat $files + false + fi +} + +function compileWithoutWarning() +{ + files="$*" set +e - output=$("$SOLC" "$f" 2>&1) + 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 +} + +echo "Compiling various other contracts and libraries..." +( +cd "$REPO_ROOT"/test/compilationTests/ +for dir in * +do + if [ "$dir" != "README.md" ] + then + echo " - $dir" + cd "$dir" + compileFull *.sol */*.sol + cd .. + fi +done +) + +echo "Compiling all files in std and examples..." + +for f in "$REPO_ROOT"/std/*.sol +do + echo "$f" + compileWithoutWarning "$f" done +echo "Compiling all examples from the documentation..." +TMPDIR=$(mktemp -d) +( + set -e + cd "$REPO_ROOT" + REPO_ROOT=$(pwd) # make it absolute + cd "$TMPDIR" + "$REPO_ROOT"/scripts/isolate_tests.py "$REPO_ROOT"/docs/ docs + for f in *.sol + do + echo "$f" + compileFull "$TMPDIR/$f" + done +) +rm -rf "$TMPDIR" +echo "Done." + echo "Testing library checksum..." echo '' | "$SOLC" --link --libraries a:0x90f20564390eAe531E810af625A22f51385Cd222 ! echo '' | "$SOLC" --link --libraries a:0x80f20564390eAe531E810af625A22f51385Cd222 2>/dev/null @@ -77,6 +137,7 @@ TMPDIR=$(mktemp -d) REPO_ROOT=$(pwd) # make it absolute cd "$TMPDIR" "$REPO_ROOT"/scripts/isolate_tests.py "$REPO_ROOT"/test/ + "$REPO_ROOT"/scripts/isolate_tests.py "$REPO_ROOT"/docs/ docs for f in *.sol do set +e |