aboutsummaryrefslogtreecommitdiffstats
path: root/test/externalTests.sh
blob: 1cc0af19e47c539debef8613b145b13ec88d7bb4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/env bash

#------------------------------------------------------------------------------
# Bash script to run external Solidity tests.
#
# Argument: Path to soljson.js to test.
#
# Requires npm, networking access and git to download the tests.
#
# ------------------------------------------------------------------------------
# This file is part of solidity.
#
# solidity is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# solidity is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with solidity.  If not, see <http://www.gnu.org/licenses/>
#
# (c) 2016 solidity contributors.
#------------------------------------------------------------------------------

set -e

if [ ! -f "$1" ]
then
  echo "Usage: $0 <path to soljson.js>"
  exit 1
fi

SOLJSON="$1"

DIR=$(mktemp -d)
(
    echo "Running Zeppelin tests..."
    git clone --depth 1 https://github.com/OpenZeppelin/zeppelin-solidity.git "$DIR"
    cd "$DIR"
    npm install
    find . -name soljson.js -exec cp "$SOLJSON" {} \;

    # This is a patch that lets truffle ignore the pre-release compiler warning
    cat > truffle.patch <<EOF
--- node_modules/truffle/build/cli.bundled.js   2017-11-27 16:56:47.114830112 +0100
+++ /tmp/patched    2017-11-27 16:52:31.887064115 +0100
@@ -313846,9 +313846,12 @@
     });
 
     output = JSON.parse(output);
+   var errors = output.errors.filter(function(solidity_error) {
+       return solidity_error.formattedMessage.indexOf("pre-release compiler") < 0;
+    });
 
-    if (output.errors) {
-      throw new CompileError(output.errors[0].formattedMessage);
+    if (errors) {
+      throw new CompileError(errors[0].formattedMessage);
     }
 
     return {
@@ -313901,9 +313904,13 @@
       return {error: importErrorKey};
     });
 
-    output = JSON.parse(output);
+   output = JSON.parse(output);
+   
+   var errors = output.errors.filter(function(solidity_error) {
+       return solidity_error.formattedMessage.indexOf("pre-release compiler") < 0;
+    });
 
-    var nonImportErrors = output.errors.filter(function(solidity_error) {
+    var nonImportErrors = errors.filter(function(solidity_error) {
       // If the import error key is not found, we must not have an import error.
       // This means we have a *different* parsing error which we should show to the user.
       // Note: solc can return multiple parsing errors at once.
@@ -313917,7 +313924,7 @@
 
     // Now, all errors must be import errors.
     // Filter out our forced import, then get the import paths of the rest.
-    var imports = output.errors.filter(function(solidity_error) {
+    var imports = errors.filter(function(solidity_error) {
       return solidity_error.message.indexOf(failingImportFileName) < 0;
     }).map(function(solidity_error) {
       var matches = solidity_error.formattedMessage.match(/import[^'"]+("|')([^'"]+)("|');/);
EOF

    patch node_modules/truffle/build/cli.bundled.js ./truffle.patch
    npm run test
)
rm -rf "$DIR"