aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-08-09 20:58:28 +0800
committerchriseth <chris@ethereum.org>2018-08-14 21:50:46 +0800
commitf873389c6227d41dbba9ba4c23ed055f286ecb71 (patch)
tree03cd6596754f48ede98a93c9d05d248b410a58ba /test
parent8f0c2a46db787de166f7bcaed2180fcab9248d12 (diff)
downloaddexon-solidity-f873389c6227d41dbba9ba4c23ed055f286ecb71.tar.gz
dexon-solidity-f873389c6227d41dbba9ba4c23ed055f286ecb71.tar.zst
dexon-solidity-f873389c6227d41dbba9ba4c23ed055f286ecb71.zip
Test that documentation does not contain any warnings.
Diffstat (limited to 'test')
-rwxr-xr-xtest/cmdlineTests.sh65
1 files changed, 41 insertions, 24 deletions
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"