mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Test that documentation does not contain any warnings.
This commit is contained in:
parent
8f0c2a46db
commit
f873389c62
@ -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
|
||||
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user