mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Use consistent syntax for Bash function declarations
This commit is contained in:
parent
bc2402e76f
commit
7ccdbd5b08
@ -35,7 +35,7 @@ then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function preparedGrep()
|
function preparedGrep
|
||||||
{
|
{
|
||||||
git grep -nIE "$1" -- '*.h' '*.cpp' | grep -v "${EXCLUDE_FILES_JOINED}"
|
git grep -nIE "$1" -- '*.h' '*.cpp' | grep -v "${EXCLUDE_FILES_JOINED}"
|
||||||
return $?
|
return $?
|
||||||
|
@ -5,7 +5,7 @@ ROOTDIR="/root/project"
|
|||||||
BUILDDIR="${ROOTDIR}/build"
|
BUILDDIR="${ROOTDIR}/build"
|
||||||
mkdir -p "${BUILDDIR}" && mkdir -p "$BUILDDIR/deps"
|
mkdir -p "${BUILDDIR}" && mkdir -p "$BUILDDIR/deps"
|
||||||
|
|
||||||
generate_protobuf_bindings()
|
function generate_protobuf_bindings
|
||||||
{
|
{
|
||||||
cd "${ROOTDIR}"/test/tools/ossfuzz
|
cd "${ROOTDIR}"/test/tools/ossfuzz
|
||||||
# Generate protobuf C++ bindings
|
# Generate protobuf C++ bindings
|
||||||
@ -15,7 +15,7 @@ generate_protobuf_bindings()
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
build_fuzzers()
|
function build_fuzzers
|
||||||
{
|
{
|
||||||
cd "${BUILDDIR}"
|
cd "${BUILDDIR}"
|
||||||
cmake .. -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-Release}" \
|
cmake .. -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-Release}" \
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
function error() {
|
function error
|
||||||
|
{
|
||||||
echo >&2 "ERROR: ${1} Aborting." && false
|
echo >&2 "ERROR: ${1} Aborting." && false
|
||||||
}
|
}
|
||||||
|
|
||||||
function warning() {
|
function warning
|
||||||
|
{
|
||||||
echo >&2 "WARNING: ${1}"
|
echo >&2 "WARNING: ${1}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,15 +29,15 @@ _initial_work_dir=$(pwd)
|
|||||||
if [ "$CIRCLECI" ]
|
if [ "$CIRCLECI" ]
|
||||||
then
|
then
|
||||||
export TERM="${TERM:-xterm}"
|
export TERM="${TERM:-xterm}"
|
||||||
function printTask() { echo "$(tput bold)$(tput setaf 2)$1$(tput setaf 7)"; }
|
function printTask { echo "$(tput bold)$(tput setaf 2)$1$(tput setaf 7)"; }
|
||||||
function printError() { >&2 echo "$(tput setaf 1)$1$(tput setaf 7)"; }
|
function printError { >&2 echo "$(tput setaf 1)$1$(tput setaf 7)"; }
|
||||||
function printWarning() { >&2 echo "$(tput setaf 11)$1$(tput setaf 7)"; }
|
function printWarning { >&2 echo "$(tput setaf 11)$1$(tput setaf 7)"; }
|
||||||
function printLog() { echo "$(tput setaf 3)$1$(tput setaf 7)"; }
|
function printLog { echo "$(tput setaf 3)$1$(tput setaf 7)"; }
|
||||||
else
|
else
|
||||||
function printTask() { echo "$(tput bold)$(tput setaf 2)$1$(tput sgr0)"; }
|
function printTask { echo "$(tput bold)$(tput setaf 2)$1$(tput sgr0)"; }
|
||||||
function printError() { >&2 echo "$(tput setaf 1)$1$(tput sgr0)"; }
|
function printError { >&2 echo "$(tput setaf 1)$1$(tput sgr0)"; }
|
||||||
function printWarning() { >&2 echo "$(tput setaf 11)$1$(tput sgr0)"; }
|
function printWarning { >&2 echo "$(tput setaf 11)$1$(tput sgr0)"; }
|
||||||
function printLog() { echo "$(tput setaf 3)$1$(tput sgr0)"; }
|
function printLog { echo "$(tput setaf 3)$1$(tput sgr0)"; }
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function printStackTrace
|
function printStackTrace
|
||||||
@ -78,7 +78,7 @@ function printStackTrace
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function fail()
|
function fail
|
||||||
{
|
{
|
||||||
printError "$@"
|
printError "$@"
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ function fail()
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
function assertFail()
|
function assertFail
|
||||||
{
|
{
|
||||||
printError ""
|
printError ""
|
||||||
(( $# == 0 )) && printError "Assertion failed."
|
(( $# == 0 )) && printError "Assertion failed."
|
||||||
@ -97,7 +97,7 @@ function assertFail()
|
|||||||
exit 2
|
exit 2
|
||||||
}
|
}
|
||||||
|
|
||||||
function msg_on_error()
|
function msg_on_error
|
||||||
{
|
{
|
||||||
local error_message
|
local error_message
|
||||||
local no_stdout=false
|
local no_stdout=false
|
||||||
@ -171,7 +171,7 @@ function msg_on_error()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
safe_kill()
|
function safe_kill
|
||||||
{
|
{
|
||||||
local PID=${1}
|
local PID=${1}
|
||||||
local NAME=${2:-${1}}
|
local NAME=${2:-${1}}
|
||||||
|
@ -22,7 +22,8 @@
|
|||||||
YULARGS=(--strict-assembly)
|
YULARGS=(--strict-assembly)
|
||||||
FULLARGS=(--optimize --combined-json "abi,asm,ast,bin,bin-runtime,devdoc,hashes,metadata,opcodes,srcmap,srcmap-runtime,userdoc")
|
FULLARGS=(--optimize --combined-json "abi,asm,ast,bin,bin-runtime,devdoc,hashes,metadata,opcodes,srcmap,srcmap-runtime,userdoc")
|
||||||
OLDARGS=(--optimize --combined-json "abi,asm,ast,bin,bin-runtime,devdoc,interface,metadata,opcodes,srcmap,srcmap-runtime,userdoc")
|
OLDARGS=(--optimize --combined-json "abi,asm,ast,bin,bin-runtime,devdoc,interface,metadata,opcodes,srcmap,srcmap-runtime,userdoc")
|
||||||
function compileFull()
|
|
||||||
|
function compileFull
|
||||||
{
|
{
|
||||||
local expected_exit_code=0
|
local expected_exit_code=0
|
||||||
local expect_output='none'
|
local expect_output='none'
|
||||||
|
@ -28,7 +28,7 @@ else
|
|||||||
date -u +"nightly.%Y.%-m.%-d" > prerelease.txt
|
date -u +"nightly.%Y.%-m.%-d" > prerelease.txt
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tag_and_push()
|
function tag_and_push
|
||||||
{
|
{
|
||||||
docker tag "$image:$1" "$image:$2"
|
docker tag "$image:$1" "$image:$2"
|
||||||
docker push "$image:$2"
|
docker push "$image:$2"
|
||||||
|
@ -36,7 +36,7 @@ source "${REPO_ROOT}/scripts/common_cmdline.sh"
|
|||||||
|
|
||||||
developmentVersion=$("$REPO_ROOT/scripts/get_version.sh")
|
developmentVersion=$("$REPO_ROOT/scripts/get_version.sh")
|
||||||
|
|
||||||
function versionGreater()
|
function versionGreater
|
||||||
{
|
{
|
||||||
v1=$1
|
v1=$1
|
||||||
v2=$2
|
v2=$2
|
||||||
@ -58,7 +58,7 @@ function versionGreater()
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
function versionEqual()
|
function versionEqual
|
||||||
{
|
{
|
||||||
if [[ "$1" == "$2" ]]
|
if [[ "$1" == "$2" ]]
|
||||||
then
|
then
|
||||||
@ -67,7 +67,7 @@ function versionEqual()
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAllAvailableVersions()
|
function getAllAvailableVersions
|
||||||
{
|
{
|
||||||
allVersions=()
|
allVersions=()
|
||||||
local allListedVersions
|
local allListedVersions
|
||||||
@ -85,7 +85,7 @@ function getAllAvailableVersions()
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function findMinimalVersion()
|
function findMinimalVersion
|
||||||
{
|
{
|
||||||
local f=$1
|
local f=$1
|
||||||
local greater=false
|
local greater=false
|
||||||
|
@ -50,14 +50,14 @@
|
|||||||
# FIXME: Can't use set -u because the old Bash on macOS treats empty arrays as unbound variables
|
# FIXME: Can't use set -u because the old Bash on macOS treats empty arrays as unbound variables
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
|
|
||||||
die()
|
function die
|
||||||
{
|
{
|
||||||
# shellcheck disable=SC2059
|
# shellcheck disable=SC2059
|
||||||
>&2 printf "ERROR: $1\n" "${@:2}"
|
>&2 printf "ERROR: $1\n" "${@:2}"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
get_reported_solc_version()
|
function get_reported_solc_version
|
||||||
{
|
{
|
||||||
local solc_binary="$1"
|
local solc_binary="$1"
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ get_reported_solc_version()
|
|||||||
echo "$version_banner" | tail -n 1 | sed -n -E 's/^Version: (.*)$/\1/p'
|
echo "$version_banner" | tail -n 1 | sed -n -E 's/^Version: (.*)$/\1/p'
|
||||||
}
|
}
|
||||||
|
|
||||||
validate_reported_version()
|
function validate_reported_version
|
||||||
{
|
{
|
||||||
local reported_version="$1"
|
local reported_version="$1"
|
||||||
local expected_version_and_commit="$2"
|
local expected_version_and_commit="$2"
|
||||||
|
@ -8,7 +8,8 @@ BOOST_OPTIONS=()
|
|||||||
SOLTEST_OPTIONS=()
|
SOLTEST_OPTIONS=()
|
||||||
SOLIDITY_BUILD_DIR=${SOLIDITY_BUILD_DIR:-${REPO_ROOT}/build}
|
SOLIDITY_BUILD_DIR=${SOLIDITY_BUILD_DIR:-${REPO_ROOT}/build}
|
||||||
|
|
||||||
usage() {
|
function usage
|
||||||
|
{
|
||||||
echo 2>&1 "
|
echo 2>&1 "
|
||||||
Usage: $0 [options] [soltest-options]
|
Usage: $0 [options] [soltest-options]
|
||||||
Runs BOOST C++ unit test program, soltest.
|
Runs BOOST C++ unit test program, soltest.
|
||||||
|
@ -20,7 +20,7 @@ SGR_BLUE="\033[34m"
|
|||||||
vt_cursor_up() { echo -ne "\033[A"; }
|
vt_cursor_up() { echo -ne "\033[A"; }
|
||||||
vt_cursor_begin_of_line() { echo -ne "\r"; }
|
vt_cursor_begin_of_line() { echo -ne "\r"; }
|
||||||
|
|
||||||
download_antlr4()
|
function download_antlr4
|
||||||
{
|
{
|
||||||
if [[ ! -e "$ANTLR_JAR" ]]
|
if [[ ! -e "$ANTLR_JAR" ]]
|
||||||
then
|
then
|
||||||
@ -28,7 +28,7 @@ download_antlr4()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare_workdir()
|
function prepare_workdir
|
||||||
{
|
{
|
||||||
mkdir -p "${ROOT_DIR}/build/deps"
|
mkdir -p "${ROOT_DIR}/build/deps"
|
||||||
mkdir -p "${WORKDIR}"
|
mkdir -p "${WORKDIR}"
|
||||||
@ -51,7 +51,7 @@ javac -classpath "${ANTLR_JAR}" "${WORKDIR}/src/"*.java -d "${WORKDIR}/target/"
|
|||||||
|
|
||||||
# Run tests
|
# Run tests
|
||||||
failed_count=0
|
failed_count=0
|
||||||
test_file()
|
function test_file
|
||||||
{
|
{
|
||||||
local SOL_FILE
|
local SOL_FILE
|
||||||
SOL_FILE="$(${READLINK} -m "${1}")"
|
SOL_FILE="$(${READLINK} -m "${1}")"
|
||||||
|
@ -38,7 +38,8 @@ source "${REPO_ROOT}/scripts/common.sh"
|
|||||||
WORKDIR=$(mktemp -d)
|
WORKDIR=$(mktemp -d)
|
||||||
CMDLINE_PID=
|
CMDLINE_PID=
|
||||||
|
|
||||||
cleanup() {
|
function cleanup
|
||||||
|
{
|
||||||
# ensure failing commands don't cause termination during cleanup (especially within safe_kill)
|
# ensure failing commands don't cause termination during cleanup (especially within safe_kill)
|
||||||
set +e
|
set +e
|
||||||
|
|
||||||
|
@ -38,7 +38,8 @@ ORANGE='\033[0;33m'
|
|||||||
CYAN='\033[0;36m'
|
CYAN='\033[0;36m'
|
||||||
RESET='\033[0m'
|
RESET='\033[0m'
|
||||||
|
|
||||||
function generate_bytecode_report() {
|
function generate_bytecode_report
|
||||||
|
{
|
||||||
rm -rf /tmp/report.txt
|
rm -rf /tmp/report.txt
|
||||||
|
|
||||||
local EXIT_STATUS
|
local EXIT_STATUS
|
||||||
@ -74,7 +75,8 @@ function generate_bytecode_report() {
|
|||||||
echo -e "${RED}FAILURE${RESET}"
|
echo -e "${RED}FAILURE${RESET}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
function clean_git_checkout() {
|
function clean_git_checkout
|
||||||
|
{
|
||||||
git submodule deinit --all -q
|
git submodule deinit --all -q
|
||||||
git reset --hard HEAD --quiet
|
git reset --hard HEAD --quiet
|
||||||
git clean -f -d -x --quiet
|
git clean -f -d -x --quiet
|
||||||
@ -82,7 +84,8 @@ function clean_git_checkout() {
|
|||||||
git submodule init -q
|
git submodule init -q
|
||||||
git submodule update -q
|
git submodule update -q
|
||||||
}
|
}
|
||||||
function process_tag() {
|
function process_tag
|
||||||
|
{
|
||||||
local TAG=$1
|
local TAG=$1
|
||||||
cd /src
|
cd /src
|
||||||
# Checkout the historic commit instead of the tag directly.
|
# Checkout the historic commit instead of the tag directly.
|
||||||
|
@ -83,7 +83,8 @@ for arg in "$@"; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
show_output_if() {
|
function show_output_if
|
||||||
|
{
|
||||||
local VAR=${1}
|
local VAR=${1}
|
||||||
if [ -n "${VAR}" ]; then
|
if [ -n "${VAR}" ]; then
|
||||||
echo "${SOL_FILE}"
|
echo "${SOL_FILE}"
|
||||||
@ -102,7 +103,8 @@ if [ ! -f "${SOLC}" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
test_file() {
|
function test_file
|
||||||
|
{
|
||||||
local SOL_FILE
|
local SOL_FILE
|
||||||
local OUTPUT
|
local OUTPUT
|
||||||
SOL_FILE=${1}
|
SOL_FILE=${1}
|
||||||
|
@ -154,7 +154,7 @@ function ask_expectation_update
|
|||||||
|
|
||||||
# General helper function for testing SOLC behaviour, based on file name, compile opts, exit code, stdout and stderr.
|
# General helper function for testing SOLC behaviour, based on file name, compile opts, exit code, stdout and stderr.
|
||||||
# An failure is expected.
|
# An failure is expected.
|
||||||
function test_solc_behaviour()
|
function test_solc_behaviour
|
||||||
{
|
{
|
||||||
local filename="${1}"
|
local filename="${1}"
|
||||||
local solc_args
|
local solc_args
|
||||||
@ -288,7 +288,7 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function test_solc_assembly_output()
|
function test_solc_assembly_output
|
||||||
{
|
{
|
||||||
local input="${1}"
|
local input="${1}"
|
||||||
local expected="${2}"
|
local expected="${2}"
|
||||||
|
@ -10,11 +10,11 @@ REPO_ROOT=$(cd "$(dirname "$0")/.." && pwd)
|
|||||||
|
|
||||||
if [ "$CIRCLECI" ]
|
if [ "$CIRCLECI" ]
|
||||||
then
|
then
|
||||||
function printTask() { echo "$(tput bold)$(tput setaf 2)$1$(tput setaf 7)"; }
|
function printTask { echo "$(tput bold)$(tput setaf 2)$1$(tput setaf 7)"; }
|
||||||
function printError() { echo "$(tput setaf 1)$1$(tput setaf 7)"; }
|
function printError { echo "$(tput setaf 1)$1$(tput setaf 7)"; }
|
||||||
else
|
else
|
||||||
function printTask() { echo "$(tput bold)$(tput setaf 2)$1$(tput sgr0)"; }
|
function printTask { echo "$(tput bold)$(tput setaf 2)$1$(tput sgr0)"; }
|
||||||
function printError() { echo "$(tput setaf 1)$1$(tput sgr0)"; }
|
function printError { echo "$(tput setaf 1)$1$(tput sgr0)"; }
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printTask "Checking docs examples style"
|
printTask "Checking docs examples style"
|
||||||
|
@ -187,7 +187,8 @@ function run_test
|
|||||||
$test_fn
|
$test_fn
|
||||||
}
|
}
|
||||||
|
|
||||||
function optimizer_settings_for_level {
|
function optimizer_settings_for_level
|
||||||
|
{
|
||||||
local level="$1"
|
local level="$1"
|
||||||
|
|
||||||
case "$level" in
|
case "$level" in
|
||||||
@ -201,7 +202,8 @@ function optimizer_settings_for_level {
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
function truffle_compiler_settings {
|
function truffle_compiler_settings
|
||||||
|
{
|
||||||
local solc_path="$1"
|
local solc_path="$1"
|
||||||
local level="$2"
|
local level="$2"
|
||||||
local evm_version="$3"
|
local evm_version="$3"
|
||||||
|
@ -15,7 +15,7 @@ FILETMP=$(mktemp -d)
|
|||||||
cd "$FILETMP" || exit 1
|
cd "$FILETMP" || exit 1
|
||||||
|
|
||||||
|
|
||||||
function testFile()
|
function testFile
|
||||||
{
|
{
|
||||||
set +e
|
set +e
|
||||||
ALLOUTPUT=$($SOLC --combined-json ast --pretty-json "$@" --stop-after parsing 2>&1)
|
ALLOUTPUT=$($SOLC --combined-json ast --pretty-json "$@" --stop-after parsing 2>&1)
|
||||||
|
Loading…
Reference in New Issue
Block a user