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
@ -55,16 +55,6 @@ def extract_docs_cases(path):
|
|||||||
inside = False
|
inside = False
|
||||||
else:
|
else:
|
||||||
tests[-1] += l + '\n'
|
tests[-1] += l + '\n'
|
||||||
else:
|
|
||||||
m = re.search(r'^ // This will not compile', l)
|
|
||||||
if m:
|
|
||||||
ignore = True
|
|
||||||
|
|
||||||
if ignore:
|
|
||||||
# Abort if indentation is missing
|
|
||||||
m = re.search(r'^[^ ]+', l)
|
|
||||||
if m:
|
|
||||||
ignore = False
|
|
||||||
else:
|
else:
|
||||||
m = re.search(r'^ pragma solidity .*[0-9]+\.[0-9]+\.[0-9]+;$', l)
|
m = re.search(r'^ pragma solidity .*[0-9]+\.[0-9]+\.[0-9]+;$', l)
|
||||||
if m:
|
if m:
|
||||||
|
@ -43,18 +43,42 @@ function printError() { echo "$(tput setaf 1)$1$(tput sgr0)"; }
|
|||||||
|
|
||||||
function compileFull()
|
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 files="$*"
|
||||||
local output failed
|
local output
|
||||||
|
|
||||||
|
local stderr_path=$(mktemp)
|
||||||
|
|
||||||
set +e
|
set +e
|
||||||
output=$( ("$SOLC" $FULLARGS $files) 2>&1 )
|
"$SOLC" $FULLARGS $files >/dev/null 2>"$stderr_path"
|
||||||
failed=$?
|
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
|
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
|
then
|
||||||
printError "Compilation failed on:"
|
printError "Unexpected compilation result:"
|
||||||
echo "$output"
|
printError "Expected failure: $expected_exit_code - Expected warning / error output: $expect_output"
|
||||||
|
printError "Was failure: $exit_code"
|
||||||
|
echo "$errors"
|
||||||
printError "While calling:"
|
printError "While calling:"
|
||||||
echo "\"$SOLC\" $FULLARGS $files"
|
echo "\"$SOLC\" $FULLARGS $files"
|
||||||
printError "Inside directory:"
|
printError "Inside directory:"
|
||||||
@ -63,22 +87,6 @@ function compileFull()
|
|||||||
fi
|
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..."
|
printTask "Testing unknown options..."
|
||||||
(
|
(
|
||||||
set +e
|
set +e
|
||||||
@ -157,7 +165,7 @@ do
|
|||||||
then
|
then
|
||||||
echo " - $dir"
|
echo " - $dir"
|
||||||
cd "$dir"
|
cd "$dir"
|
||||||
compileFull *.sol */*.sol
|
compileFull -w *.sol */*.sol
|
||||||
cd ..
|
cd ..
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -174,7 +182,16 @@ TMPDIR=$(mktemp -d)
|
|||||||
for f in *.sol
|
for f in *.sol
|
||||||
do
|
do
|
||||||
echo "$f"
|
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
|
done
|
||||||
)
|
)
|
||||||
rm -rf "$TMPDIR"
|
rm -rf "$TMPDIR"
|
||||||
|
Loading…
Reference in New Issue
Block a user