From 061b50ae19b0f8b9dcffc8dab5f08c4e26e884fb Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 2 Nov 2016 12:32:55 +0100 Subject: [PATCH 1/2] Add tests for the std files. --- scripts/tests.sh | 17 +++++++++++++++-- std/StandardToken.sol | 2 ++ std/Token.sol | 2 ++ std/mortal.sol | 2 ++ std/owned.sol | 2 ++ std/std.sol | 2 ++ 6 files changed, 25 insertions(+), 2 deletions(-) diff --git a/scripts/tests.sh b/scripts/tests.sh index 93afd2d20..5fa75d4d1 100755 --- a/scripts/tests.sh +++ b/scripts/tests.sh @@ -28,8 +28,21 @@ set -e -# There is an implicit assumption here that we HAVE to run from root directory. -REPO_ROOT=$(pwd) +REPO_ROOT="$(dirname "$0")"/.. + + # Compile all files in std and examples. + +for f in "$REPO_ROOT"/std/*.sol +do + echo "Compiling $f..." + set +e + output=$("$REPO_ROOT"/build/solc/solc "$f" 2>&1) + failed=$? + output=$(echo "$output" | grep -v 'pre-release') + echo "$output" + set -e + test -z "$output" -a "$failed" -eq 0 +done # This conditional is only needed because we don't have a working Homebrew # install for `eth` at the time of writing, so we unzip the ZIP file locally diff --git a/std/StandardToken.sol b/std/StandardToken.sol index 41f2d709a..4ff1b8f92 100644 --- a/std/StandardToken.sol +++ b/std/StandardToken.sol @@ -1,3 +1,5 @@ +pragma solidity ^0.4.0; + import "./Token.sol"; contract StandardToken is Token { diff --git a/std/Token.sol b/std/Token.sol index 396dbf9e5..59566f26f 100644 --- a/std/Token.sol +++ b/std/Token.sol @@ -1,3 +1,5 @@ +pragma solidity ^0.4.0; + contract Token { event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); diff --git a/std/mortal.sol b/std/mortal.sol index 8de019abb..f0a6f4ce0 100644 --- a/std/mortal.sol +++ b/std/mortal.sol @@ -1,3 +1,5 @@ +pragma solidity ^0.4.0; + import "./owned.sol"; contract mortal is owned { diff --git a/std/owned.sol b/std/owned.sol index 3d7674f58..bbb8d957d 100644 --- a/std/owned.sol +++ b/std/owned.sol @@ -1,3 +1,5 @@ +pragma solidity ^0.4.0; + contract owned { address owner; diff --git a/std/std.sol b/std/std.sol index c3f66b1b7..4d65bef2a 100644 --- a/std/std.sol +++ b/std/std.sol @@ -1,3 +1,5 @@ +pragma solidity ^0.4.0; + import "./owned.sol"; import "./mortal.sol"; import "./Token.sol"; From 3dbf2830ca96922a3aec954ea9d7251f2bc02eed Mon Sep 17 00:00:00 2001 From: chriseth Date: Mon, 14 Nov 2016 23:04:43 +0100 Subject: [PATCH 2/2] Update tests.sh --- scripts/tests.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/tests.sh b/scripts/tests.sh index 5fa75d4d1..5da427d44 100755 --- a/scripts/tests.sh +++ b/scripts/tests.sh @@ -38,6 +38,7 @@ do set +e output=$("$REPO_ROOT"/build/solc/solc "$f" 2>&1) failed=$? + # Remove the pre-release warning from the compiler output output=$(echo "$output" | grep -v 'pre-release') echo "$output" set -e