aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-07-13 01:06:36 +0800
committerchriseth <chris@ethereum.org>2017-07-14 03:47:29 +0800
commita8d78bb7675f81dd992a588582501d7db6d578d2 (patch)
tree2e6468e73cc51830328f4f323b2d84b406b0399a
parentd3b447c20368dab68636e79b893547757fdab8df (diff)
downloaddexon-solidity-a8d78bb7675f81dd992a588582501d7db6d578d2.tar
dexon-solidity-a8d78bb7675f81dd992a588582501d7db6d578d2.tar.gz
dexon-solidity-a8d78bb7675f81dd992a588582501d7db6d578d2.tar.bz2
dexon-solidity-a8d78bb7675f81dd992a588582501d7db6d578d2.tar.lz
dexon-solidity-a8d78bb7675f81dd992a588582501d7db6d578d2.tar.xz
dexon-solidity-a8d78bb7675f81dd992a588582501d7db6d578d2.tar.zst
dexon-solidity-a8d78bb7675f81dd992a588582501d7db6d578d2.zip
Refactor compilation tests.
-rwxr-xr-xscripts/tests.sh21
-rwxr-xr-xtest/cmdlineTests.sh66
2 files changed, 51 insertions, 36 deletions
diff --git a/scripts/tests.sh b/scripts/tests.sh
index 64b4121f..5d7eb0e1 100755
--- a/scripts/tests.sh
+++ b/scripts/tests.sh
@@ -30,27 +30,6 @@ set -e
REPO_ROOT="$(dirname "$0")"/..
-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"
-
-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"
- ../../../build/solc/solc --optimize \
- --combined-json abi,asm,ast,bin,bin-runtime,clone-bin,compact-format,devdoc,hashes,interface,metadata,opcodes,srcmap,srcmap-runtime,userdoc \
- *.sol */*.sol > /dev/null 2>&1
- cd ..
- fi
-done
-)
-
echo "Running commandline tests..."
"$REPO_ROOT/test/cmdlineTests.sh"
diff --git a/test/cmdlineTests.sh b/test/cmdlineTests.sh
index 97823515..eb5c714d 100755
--- a/test/cmdlineTests.sh
+++ b/test/cmdlineTests.sh
@@ -28,25 +28,68 @@
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..."
@@ -59,15 +102,8 @@ TMPDIR=$(mktemp -d)
"$REPO_ROOT"/scripts/isolate_tests.py "$REPO_ROOT"/docs/ docs
for f in *.sol
do
- echo "trying $f"
- set +e
- output=$("$SOLC" "$f" 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 "$f"
+ compileFull "$TMPDIR/$f"
done
)
rm -rf "$TMPDIR"