diff options
author | chriseth <chris@ethereum.org> | 2018-08-08 03:46:00 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-08 03:46:00 +0800 |
commit | 8e93b729a4fb50d1d0f21b86a7434ed91ae8826a (patch) | |
tree | 0eddc8f6219bb809a197888d2f115f76fbde4754 /test/cmdlineTests.sh | |
parent | 4f9d72aa831edc7492da5e44a0805f41220d2d55 (diff) | |
parent | 39ffd7500e68e1603cead1a8473c1fb990fbab8f (diff) | |
download | dexon-solidity-8e93b729a4fb50d1d0f21b86a7434ed91ae8826a.tar.gz dexon-solidity-8e93b729a4fb50d1d0f21b86a7434ed91ae8826a.tar.zst dexon-solidity-8e93b729a4fb50d1d0f21b86a7434ed91ae8826a.zip |
Merge pull request #4703 from ethereum/solc-fix-double-quoting-path-names
solc: Fixes double-quoting path names on stderr.
Diffstat (limited to 'test/cmdlineTests.sh')
-rwxr-xr-x | test/cmdlineTests.sh | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/test/cmdlineTests.sh b/test/cmdlineTests.sh index d0296515..7256386d 100755 --- a/test/cmdlineTests.sh +++ b/test/cmdlineTests.sh @@ -94,6 +94,56 @@ printTask "Testing unknown options..." fi ) +# General helper function for testing SOLC behaviour, based on file name, compile opts, exit code, stdout and stderr. +# An failure is expected. +test_solc_file_input_failures() { + local filename="${1}" + local solc_args="${2}" + local stdout_expected="${3}" + local stderr_expected="${4}" + local stdout_path=`mktemp` + local stderr_path=`mktemp` + + set +e + "$SOLC" "${filename}" ${solc_args} 1>$stdout_path 2>$stderr_path + exitCode=$? + set -e + + if [[ $exitCode -eq 0 ]]; then + printError "Incorrect exit code. Expected failure (non-zero) but got success (0)." + rm -f $stdout_path $stderr_path + exit 1 + fi + + if [[ "$(cat $stdout_path)" != "${stdout_expected}" ]]; then + printError "Incorrect output on stderr received. Expected:" + echo -e "${stdout_expected}" + + printError "But got:" + cat $stdout_path + rm -f $stdout_path $stderr_path + exit 1 + fi + + if [[ "$(cat $stderr_path)" != "${stderr_expected}" ]]; then + printError "Incorrect output on stderr received. Expected:" + echo -e "${stderr_expected}" + + printError "But got:" + cat $stderr_path + rm -f $stdout_path $stderr_path + exit 1 + fi + + rm -f $stdout_path $stderr_path +} + +printTask "Testing passing files that are not found..." +test_solc_file_input_failures "file_not_found.sol" "" "" "\"file_not_found.sol\" is not found." + +printTask "Testing passing files that are not files..." +test_solc_file_input_failures "." "" "" "\".\" is not a valid file." + printTask "Compiling various other contracts and libraries..." ( cd "$REPO_ROOT"/test/compilationTests/ |