mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
cmdlineTests: Remove unnecessary subshells
- Whitespace-only change, separated out to make it easy to diff.
This commit is contained in:
parent
6b061ba696
commit
c1df8ed563
@ -25,22 +25,20 @@ function test_solc_assembly_output
|
|||||||
}
|
}
|
||||||
|
|
||||||
printTask "Testing assemble, yul, strict-assembly and optimize..."
|
printTask "Testing assemble, yul, strict-assembly and optimize..."
|
||||||
(
|
echo '{}' | msg_on_error --silent "$SOLC" - --assemble
|
||||||
echo '{}' | msg_on_error --silent "$SOLC" - --assemble
|
echo '{}' | msg_on_error --silent "$SOLC" - --yul
|
||||||
echo '{}' | msg_on_error --silent "$SOLC" - --yul
|
echo '{}' | msg_on_error --silent "$SOLC" - --strict-assembly
|
||||||
echo '{}' | msg_on_error --silent "$SOLC" - --strict-assembly
|
|
||||||
|
|
||||||
# Test options above in conjunction with --optimize.
|
# Test options above in conjunction with --optimize.
|
||||||
# Using both, --assemble and --optimize should fail.
|
# Using both, --assemble and --optimize should fail.
|
||||||
echo '{}' | "$SOLC" - --assemble --optimize &>/dev/null && fail "solc --assemble --optimize did not fail as expected."
|
echo '{}' | "$SOLC" - --assemble --optimize &>/dev/null && fail "solc --assemble --optimize did not fail as expected."
|
||||||
echo '{}' | "$SOLC" - --yul --optimize &>/dev/null && fail "solc --yul --optimize did not fail as expected."
|
echo '{}' | "$SOLC" - --yul --optimize &>/dev/null && fail "solc --yul --optimize did not fail as expected."
|
||||||
|
|
||||||
# Test yul and strict assembly output
|
# Test yul and strict assembly output
|
||||||
# Non-empty code results in non-empty binary representation with optimizations turned off,
|
# Non-empty code results in non-empty binary representation with optimizations turned off,
|
||||||
# while it results in empty binary representation with optimizations turned on.
|
# while it results in empty binary representation with optimizations turned on.
|
||||||
test_solc_assembly_output "{ let x:u256 := 0:u256 }" "{ let x := 0 }" "--yul"
|
test_solc_assembly_output "{ let x:u256 := 0:u256 }" "{ let x := 0 }" "--yul"
|
||||||
test_solc_assembly_output "{ let x:u256 := bitnot(7:u256) }" "{ let x := bitnot(7) }" "--yul"
|
test_solc_assembly_output "{ let x:u256 := bitnot(7:u256) }" "{ let x := bitnot(7) }" "--yul"
|
||||||
test_solc_assembly_output "{ let t:bool := not(true) }" "{ let t:bool := not(true) }" "--yul"
|
test_solc_assembly_output "{ let t:bool := not(true) }" "{ let t:bool := not(true) }" "--yul"
|
||||||
test_solc_assembly_output "{ let x := 0 }" "{ let x := 0 }" "--strict-assembly"
|
test_solc_assembly_output "{ let x := 0 }" "{ let x := 0 }" "--strict-assembly"
|
||||||
test_solc_assembly_output "{ let x := 0 }" "{ { } }" "--strict-assembly --optimize"
|
test_solc_assembly_output "{ let x := 0 }" "{ { } }" "--strict-assembly --optimize"
|
||||||
)
|
|
||||||
|
@ -6,12 +6,10 @@ source "${REPO_ROOT}/scripts/common.sh"
|
|||||||
|
|
||||||
printTask "Testing AST import/export..."
|
printTask "Testing AST import/export..."
|
||||||
SOLTMPDIR=$(mktemp -d)
|
SOLTMPDIR=$(mktemp -d)
|
||||||
(
|
cd "$SOLTMPDIR"
|
||||||
cd "$SOLTMPDIR"
|
if ! "$REPO_ROOT/scripts/ASTImportTest.sh" ast
|
||||||
if ! "$REPO_ROOT/scripts/ASTImportTest.sh" ast
|
then
|
||||||
then
|
|
||||||
rm -r "$SOLTMPDIR"
|
rm -r "$SOLTMPDIR"
|
||||||
fail
|
fail
|
||||||
fi
|
fi
|
||||||
)
|
|
||||||
rm -r "$SOLTMPDIR"
|
rm -r "$SOLTMPDIR"
|
||||||
|
@ -7,14 +7,12 @@ source "${REPO_ROOT}/scripts/common.sh"
|
|||||||
source "${REPO_ROOT}/scripts/common_cmdline.sh"
|
source "${REPO_ROOT}/scripts/common_cmdline.sh"
|
||||||
|
|
||||||
printTask "Compiling various other contracts and libraries..."
|
printTask "Compiling various other contracts and libraries..."
|
||||||
(
|
cd "$REPO_ROOT"/test/compilationTests/
|
||||||
cd "$REPO_ROOT"/test/compilationTests/
|
for dir in */
|
||||||
for dir in */
|
do
|
||||||
do
|
|
||||||
echo " - $dir"
|
echo " - $dir"
|
||||||
cd "$dir"
|
cd "$dir"
|
||||||
# shellcheck disable=SC2046 # These file names are not supposed to contain spaces.
|
# shellcheck disable=SC2046 # These file names are not supposed to contain spaces.
|
||||||
compileFull --expect-warnings $(find . -name '*.sol')
|
compileFull --expect-warnings $(find . -name '*.sol')
|
||||||
cd ..
|
cd ..
|
||||||
done
|
done
|
||||||
)
|
|
||||||
|
@ -8,14 +8,16 @@ source "${REPO_ROOT}/scripts/common_cmdline.sh"
|
|||||||
|
|
||||||
printTask "Compiling all examples from the documentation..."
|
printTask "Compiling all examples from the documentation..."
|
||||||
SOLTMPDIR=$(mktemp -d)
|
SOLTMPDIR=$(mktemp -d)
|
||||||
(
|
|
||||||
set -e
|
|
||||||
cd "$SOLTMPDIR"
|
|
||||||
"$REPO_ROOT"/scripts/isolate_tests.py "$REPO_ROOT"/docs/
|
|
||||||
developmentVersion=$("$REPO_ROOT/scripts/get_version.sh")
|
|
||||||
|
|
||||||
for f in *.yul *.sol
|
set -e
|
||||||
do
|
cd "$SOLTMPDIR"
|
||||||
|
|
||||||
|
"$REPO_ROOT"/scripts/isolate_tests.py "$REPO_ROOT"/docs/
|
||||||
|
|
||||||
|
developmentVersion=$("$REPO_ROOT/scripts/get_version.sh")
|
||||||
|
|
||||||
|
for f in *.yul *.sol
|
||||||
|
do
|
||||||
# The contributors guide uses syntax tests, but we cannot
|
# The contributors guide uses syntax tests, but we cannot
|
||||||
# really handle them here.
|
# really handle them here.
|
||||||
if grep -E 'DeclarationError:|// ----' "$f" >/dev/null
|
if grep -E 'DeclarationError:|// ----' "$f" >/dev/null
|
||||||
@ -45,7 +47,6 @@ SOLTMPDIR=$(mktemp -d)
|
|||||||
# It's necessary because x.y.z won't match `^x.y.z` or `>=x.y.z` pragmas until it's officially released.
|
# It's necessary because x.y.z won't match `^x.y.z` or `>=x.y.z` pragmas until it's officially released.
|
||||||
sed -i.bak -E -e 's/pragma[[:space:]]+solidity[[:space:]]*(\^|>=)[[:space:]]*'"$developmentVersion"'/pragma solidity >0.0.1/' "$f"
|
sed -i.bak -E -e 's/pragma[[:space:]]+solidity[[:space:]]*(\^|>=)[[:space:]]*'"$developmentVersion"'/pragma solidity >0.0.1/' "$f"
|
||||||
compileFull "${opts[@]}" "$SOLTMPDIR/$f"
|
compileFull "${opts[@]}" "$SOLTMPDIR/$f"
|
||||||
done
|
done
|
||||||
)
|
|
||||||
rm -r "$SOLTMPDIR"
|
rm -r "$SOLTMPDIR"
|
||||||
echo "Done."
|
echo "Done."
|
||||||
|
@ -6,17 +6,21 @@ source "${REPO_ROOT}/scripts/common.sh"
|
|||||||
|
|
||||||
printTask "Testing linking itself..."
|
printTask "Testing linking itself..."
|
||||||
SOLTMPDIR=$(mktemp -d)
|
SOLTMPDIR=$(mktemp -d)
|
||||||
(
|
cd "$SOLTMPDIR"
|
||||||
cd "$SOLTMPDIR"
|
|
||||||
echo 'library L { function f() public pure {} } contract C { function f() public pure { L.f(); } }' > x.sol
|
echo 'library L { function f() public pure {} } contract C { function f() public pure { L.f(); } }' > x.sol
|
||||||
msg_on_error --no-stderr "$SOLC" --bin -o . x.sol
|
msg_on_error --no-stderr "$SOLC" --bin -o . x.sol
|
||||||
# Explanation and placeholder should be there
|
|
||||||
grep -q '//' C.bin && grep -q '__' C.bin
|
# Explanation and placeholder should be there
|
||||||
# But not in library file.
|
grep -q '//' C.bin && grep -q '__' C.bin
|
||||||
grep -q -v '[/_]' L.bin
|
|
||||||
# Now link
|
# But not in library file.
|
||||||
msg_on_error "$SOLC" --link --libraries x.sol:L=0x90f20564390eAe531E810af625A22f51385Cd222 C.bin
|
grep -q -v '[/_]' L.bin
|
||||||
# Now the placeholder and explanation should be gone.
|
|
||||||
grep -q -v '[/_]' C.bin
|
# Now link
|
||||||
)
|
msg_on_error "$SOLC" --link --libraries x.sol:L=0x90f20564390eAe531E810af625A22f51385Cd222 C.bin
|
||||||
|
|
||||||
|
# Now the placeholder and explanation should be gone.
|
||||||
|
grep -q -v '[/_]' C.bin
|
||||||
|
|
||||||
rm -r "$SOLTMPDIR"
|
rm -r "$SOLTMPDIR"
|
||||||
|
@ -6,13 +6,15 @@ source "${REPO_ROOT}/scripts/common.sh"
|
|||||||
|
|
||||||
printTask "Testing overwriting files..."
|
printTask "Testing overwriting files..."
|
||||||
SOLTMPDIR=$(mktemp -d)
|
SOLTMPDIR=$(mktemp -d)
|
||||||
(
|
|
||||||
# First time it works
|
# First time it works
|
||||||
echo 'contract C {}' | msg_on_error --no-stderr "$SOLC" - --bin -o "$SOLTMPDIR/non-existing-stuff-to-create"
|
echo 'contract C {}' | msg_on_error --no-stderr "$SOLC" - --bin -o "$SOLTMPDIR/non-existing-stuff-to-create"
|
||||||
# Second time it fails
|
|
||||||
echo 'contract C {}' | "$SOLC" - --bin -o "$SOLTMPDIR/non-existing-stuff-to-create" 2>/dev/null && \
|
# Second time it fails
|
||||||
|
echo 'contract C {}' | "$SOLC" - --bin -o "$SOLTMPDIR/non-existing-stuff-to-create" 2>/dev/null && \
|
||||||
fail "solc did not refuse to overwrite $SOLTMPDIR/non-existing-stuff-to-create."
|
fail "solc did not refuse to overwrite $SOLTMPDIR/non-existing-stuff-to-create."
|
||||||
# Unless we force
|
|
||||||
echo 'contract C {}' | msg_on_error --no-stderr "$SOLC" - --overwrite --bin -o "$SOLTMPDIR/non-existing-stuff-to-create"
|
# Unless we force
|
||||||
)
|
echo 'contract C {}' | msg_on_error --no-stderr "$SOLC" - --overwrite --bin -o "$SOLTMPDIR/non-existing-stuff-to-create"
|
||||||
|
|
||||||
rm -r "$SOLTMPDIR"
|
rm -r "$SOLTMPDIR"
|
||||||
|
@ -6,13 +6,14 @@ source "${REPO_ROOT}/scripts/common.sh"
|
|||||||
|
|
||||||
printTask "Testing soljson via the fuzzer..."
|
printTask "Testing soljson via the fuzzer..."
|
||||||
SOLTMPDIR=$(mktemp -d)
|
SOLTMPDIR=$(mktemp -d)
|
||||||
(
|
|
||||||
set -e
|
|
||||||
cd "$SOLTMPDIR"
|
|
||||||
"$REPO_ROOT"/scripts/isolate_tests.py "$REPO_ROOT"/test/
|
|
||||||
"$REPO_ROOT"/scripts/isolate_tests.py "$REPO_ROOT"/docs/
|
|
||||||
|
|
||||||
echo ./*.sol | xargs -P 4 -n 50 "${SOLIDITY_BUILD_DIR}/test/tools/solfuzzer" --quiet --input-files
|
set -e
|
||||||
echo ./*.sol | xargs -P 4 -n 50 "${SOLIDITY_BUILD_DIR}/test/tools/solfuzzer" --without-optimizer --quiet --input-files
|
cd "$SOLTMPDIR"
|
||||||
)
|
|
||||||
|
"$REPO_ROOT"/scripts/isolate_tests.py "$REPO_ROOT"/test/
|
||||||
|
"$REPO_ROOT"/scripts/isolate_tests.py "$REPO_ROOT"/docs/
|
||||||
|
|
||||||
|
echo ./*.sol | xargs -P 4 -n 50 "${SOLIDITY_BUILD_DIR}/test/tools/solfuzzer" --quiet --input-files
|
||||||
|
echo ./*.sol | xargs -P 4 -n 50 "${SOLIDITY_BUILD_DIR}/test/tools/solfuzzer" --without-optimizer --quiet --input-files
|
||||||
|
|
||||||
rm -r "$SOLTMPDIR"
|
rm -r "$SOLTMPDIR"
|
||||||
|
@ -6,26 +6,24 @@ source "${REPO_ROOT}/scripts/common.sh"
|
|||||||
|
|
||||||
printTask "Testing standard input..."
|
printTask "Testing standard input..."
|
||||||
SOLTMPDIR=$(mktemp -d)
|
SOLTMPDIR=$(mktemp -d)
|
||||||
(
|
set +e
|
||||||
set +e
|
output=$("$SOLC" --bin 2>&1)
|
||||||
output=$("$SOLC" --bin 2>&1)
|
result=$?
|
||||||
result=$?
|
set -e
|
||||||
set -e
|
|
||||||
|
|
||||||
# This should fail
|
# This should fail
|
||||||
if [[ ! ("$output" =~ "No input files given") || ($result == 0) ]]
|
if [[ ! ("$output" =~ "No input files given") || ($result == 0) ]]
|
||||||
then
|
then
|
||||||
fail "Incorrect response to empty input arg list: $output"
|
fail "Incorrect response to empty input arg list: $output"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# The contract should be compiled
|
# The contract should be compiled
|
||||||
if ! echo 'contract C {}' | msg_on_error --no-stderr "$SOLC" - --bin | grep -q "<stdin>:C"
|
if ! echo 'contract C {}' | msg_on_error --no-stderr "$SOLC" - --bin | grep -q "<stdin>:C"
|
||||||
then
|
then
|
||||||
fail "Failed to compile a simple contract from standard input"
|
fail "Failed to compile a simple contract from standard input"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# This should not fail
|
# This should not fail
|
||||||
echo '' | msg_on_error --silent --msg "Incorrect response to --ast-compact-json option with empty stdin" \
|
echo '' | msg_on_error --silent --msg "Incorrect response to --ast-compact-json option with empty stdin" \
|
||||||
"$SOLC" --ast-compact-json -
|
"$SOLC" --ast-compact-json -
|
||||||
)
|
|
||||||
rm -r "$SOLTMPDIR"
|
rm -r "$SOLTMPDIR"
|
||||||
|
@ -5,16 +5,14 @@ set -euo pipefail
|
|||||||
source "${REPO_ROOT}/scripts/common.sh"
|
source "${REPO_ROOT}/scripts/common.sh"
|
||||||
|
|
||||||
printTask "Testing unknown options..."
|
printTask "Testing unknown options..."
|
||||||
(
|
set +e
|
||||||
set +e
|
output=$("$SOLC" --allow=test 2>&1)
|
||||||
output=$("$SOLC" --allow=test 2>&1)
|
failed=$?
|
||||||
failed=$?
|
set -e
|
||||||
set -e
|
|
||||||
|
|
||||||
if [ "$output" == "unrecognised option '--allow=test'" ] && [ $failed -ne 0 ]
|
if [ "$output" == "unrecognised option '--allow=test'" ] && [ $failed -ne 0 ]
|
||||||
then
|
then
|
||||||
echo "Passed"
|
echo "Passed"
|
||||||
else
|
else
|
||||||
fail "Incorrect response to unknown options: $output"
|
fail "Incorrect response to unknown options: $output"
|
||||||
fi
|
fi
|
||||||
)
|
|
||||||
|
@ -6,8 +6,11 @@ source "${REPO_ROOT}/scripts/common.sh"
|
|||||||
|
|
||||||
SOLTMPDIR=$(mktemp -d)
|
SOLTMPDIR=$(mktemp -d)
|
||||||
printTask "Checking that the bug list is up to date..."
|
printTask "Checking that the bug list is up to date..."
|
||||||
|
|
||||||
cp "${REPO_ROOT}/docs/bugs_by_version.json" "${SOLTMPDIR}/original_bugs_by_version.json"
|
cp "${REPO_ROOT}/docs/bugs_by_version.json" "${SOLTMPDIR}/original_bugs_by_version.json"
|
||||||
"${REPO_ROOT}/scripts/update_bugs_by_version.py"
|
"${REPO_ROOT}/scripts/update_bugs_by_version.py"
|
||||||
|
|
||||||
diff --unified "${SOLTMPDIR}/original_bugs_by_version.json" "${REPO_ROOT}/docs/bugs_by_version.json" || \
|
diff --unified "${SOLTMPDIR}/original_bugs_by_version.json" "${REPO_ROOT}/docs/bugs_by_version.json" || \
|
||||||
fail "The bug list in bugs_by_version.json was out of date and has been updated. Please investigate and submit a bugfix if necessary."
|
fail "The bug list in bugs_by_version.json was out of date and has been updated. Please investigate and submit a bugfix if necessary."
|
||||||
|
|
||||||
rm -r "$SOLTMPDIR"
|
rm -r "$SOLTMPDIR"
|
||||||
|
@ -66,8 +66,7 @@ function test_via_ir_equivalence()
|
|||||||
}
|
}
|
||||||
|
|
||||||
printTask "Testing the eqivalence of --via-ir and a two-stage compilation..."
|
printTask "Testing the eqivalence of --via-ir and a two-stage compilation..."
|
||||||
(
|
externalContracts=(
|
||||||
externalContracts=(
|
|
||||||
externalTests/solc-js/DAO/TokenCreation.sol
|
externalTests/solc-js/DAO/TokenCreation.sol
|
||||||
libsolidity/semanticTests/externalContracts/_prbmath/PRBMathSD59x18.sol
|
libsolidity/semanticTests/externalContracts/_prbmath/PRBMathSD59x18.sol
|
||||||
libsolidity/semanticTests/externalContracts/_prbmath/PRBMathUD60x18.sol
|
libsolidity/semanticTests/externalContracts/_prbmath/PRBMathUD60x18.sol
|
||||||
@ -75,17 +74,17 @@ printTask "Testing the eqivalence of --via-ir and a two-stage compilation..."
|
|||||||
libsolidity/semanticTests/externalContracts/deposit_contract.sol
|
libsolidity/semanticTests/externalContracts/deposit_contract.sol
|
||||||
libsolidity/semanticTests/externalContracts/FixedFeeRegistrar.sol
|
libsolidity/semanticTests/externalContracts/FixedFeeRegistrar.sol
|
||||||
libsolidity/semanticTests/externalContracts/snark.sol
|
libsolidity/semanticTests/externalContracts/snark.sol
|
||||||
)
|
)
|
||||||
|
|
||||||
requiresOptimizer=(
|
requiresOptimizer=(
|
||||||
externalTests/solc-js/DAO/TokenCreation.sol
|
externalTests/solc-js/DAO/TokenCreation.sol
|
||||||
libsolidity/semanticTests/externalContracts/deposit_contract.sol
|
libsolidity/semanticTests/externalContracts/deposit_contract.sol
|
||||||
libsolidity/semanticTests/externalContracts/FixedFeeRegistrar.sol
|
libsolidity/semanticTests/externalContracts/FixedFeeRegistrar.sol
|
||||||
libsolidity/semanticTests/externalContracts/snark.sol
|
libsolidity/semanticTests/externalContracts/snark.sol
|
||||||
)
|
)
|
||||||
|
|
||||||
for contractFile in "${externalContracts[@]}"
|
for contractFile in "${externalContracts[@]}"
|
||||||
do
|
do
|
||||||
if ! [[ "${requiresOptimizer[*]}" =~ $contractFile ]]
|
if ! [[ "${requiresOptimizer[*]}" =~ $contractFile ]]
|
||||||
then
|
then
|
||||||
printTask " - ${contractFile}"
|
printTask " - ${contractFile}"
|
||||||
@ -94,5 +93,4 @@ printTask "Testing the eqivalence of --via-ir and a two-stage compilation..."
|
|||||||
|
|
||||||
printTask " - ${contractFile} (optimized)"
|
printTask " - ${contractFile} (optimized)"
|
||||||
test_via_ir_equivalence "${REPO_ROOT}/test/${contractFile}" --optimize
|
test_via_ir_equivalence "${REPO_ROOT}/test/${contractFile}" --optimize
|
||||||
done
|
done
|
||||||
)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user