aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-08-14 22:33:39 +0800
committerGitHub <noreply@github.com>2018-08-14 22:33:39 +0800
commit414559bd0746424484d8fd1111cd9ee440eb5306 (patch)
tree3aa839acb6030afe3b63aaa44e8a1923691934a1 /test
parentec7ccbdf866c108e96e3e9adeab60c3b00195f91 (diff)
parent8a06000a307e7f2a72f9bfdc114d84fab8ad2ebf (diff)
downloaddexon-solidity-414559bd0746424484d8fd1111cd9ee440eb5306.tar.gz
dexon-solidity-414559bd0746424484d8fd1111cd9ee440eb5306.tar.zst
dexon-solidity-414559bd0746424484d8fd1111cd9ee440eb5306.zip
Merge pull request #4788 from ethereum/noWarnDoc
Test that documentation does not contain any warnings.
Diffstat (limited to 'test')
-rwxr-xr-xtest/cmdlineTests.sh73
1 files changed, 49 insertions, 24 deletions
diff --git a/test/cmdlineTests.sh b/test/cmdlineTests.sh
index a260da34..c9acb99a 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
@@ -173,8 +181,25 @@ TMPDIR=$(mktemp -d)
"$REPO_ROOT"/scripts/isolate_tests.py "$REPO_ROOT"/docs/ docs
for f in *.sol
do
+ # The contributors guide uses syntax tests, but we cannot
+ # really handle them here.
+ if grep -E 'DeclarationError:|// ----' "$f" >/dev/null
+ then
+ continue
+ fi
echo "$f"
- compileFull "$TMPDIR/$f"
+ opts=''
+ # We expect errors if explicitly stated, or if imports
+ # are used (in the style guide)
+ if grep -E "This will not compile|import \"" "$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"