@@ -186,25 +186,25 @@ function test_solc_behaviour
186
186
exitCode=$?
187
187
set -e
188
188
189
- if [[ " ${solc_args[*]} " == * " --standard-json " * ]]
189
+ if [[ " ${solc_args[*]} " == * " --standard-json " * ]] && [[ -s $stdout_path ]]
190
190
then
191
191
python3 - << EOF
192
192
import re, sys
193
193
json = open("$stdout_path ", "r").read()
194
194
json = re.sub(r"{[^{}]*Warning: This is a pre-release compiler version[^{}]*},?", "", json)
195
- json = re.sub(r"\"errors\":\s*\[\s*\],?\s* ","" ,json) # Remove "errors" array if it's not empty
196
- json = re.sub("\n\\ s+ \n", "\n\n ", json) # Remove trailing whitespace
197
- json = re.sub(r"},(\n{0,1})\n*(\s*]) ", r"}\1\2", json) # },] -> }]
195
+ json = re.sub(r"\"errors\":\s*\[\s*\],?","\n" if json[1] == " " else "" ,json) # Remove "errors" array if it's not empty
196
+ json = re.sub("\n\\ s* \n", "\n", json) # Remove trailing whitespace
197
+ json = re.sub(r"},(\n{0,1})\n*(\s*(]|})) ", r"}\1\2", json) # Remove trailing comma
198
198
open("$stdout_path ", "w").write(json)
199
199
EOF
200
200
sed -i.bak -E -e ' s/ Consider adding \\"pragma solidity \^[0-9.]*;\\"//g' " $stdout_path "
201
- sed -i.bak -E -e ' s/\"opcodes\":\"[^"]+\"/\"opcodes\":\"<OPCODES REMOVED>\"/g' " $stdout_path "
202
- sed -i.bak -E -e ' s/\"sourceMap\":\"[0-9:;-]+\"/\"sourceMap\":\"<SOURCEMAP REMOVED>\"/g' " $stdout_path "
201
+ sed -i.bak -E -e ' s/\"opcodes\":[[:space:]]* \"[^"]+\"/\"opcodes\":\"<OPCODES REMOVED>\"/g' " $stdout_path "
202
+ sed -i.bak -E -e ' s/\"sourceMap\":[[:space:]]* \"[0-9:;-]+\"/\"sourceMap\":\"<SOURCEMAP REMOVED>\"/g' " $stdout_path "
203
203
204
204
# Remove bytecode (but not linker references).
205
- sed -i.bak -E -e ' s/(\"object\":\")[0-9a-f]+([^"]*\")/\1<BYTECODE REMOVED>\2/g' " $stdout_path "
205
+ sed -i.bak -E -e ' s/(\"object\":[[:space:]]* \")[0-9a-f]+([^"]*\")/\1<BYTECODE REMOVED>\2/g' " $stdout_path "
206
206
# shellcheck disable=SC2016
207
- sed -i.bak -E -e ' s/(\"object\":\"[^"]+\$__)[0-9a-f]+(\")/\1<BYTECODE REMOVED>\2/g' " $stdout_path "
207
+ sed -i.bak -E -e ' s/(\"object\":[[:space:]]* \"[^"]+\$__)[0-9a-f]+(\")/\1<BYTECODE REMOVED>\2/g' " $stdout_path "
208
208
# shellcheck disable=SC2016
209
209
sed -i.bak -E -e ' s/([0-9a-f]{34}\$__)[0-9a-f]+(__\$[0-9a-f]{17})/\1<BYTECODE REMOVED>\2/g' " $stdout_path "
210
210
# Remove metadata in assembly output (see below about the magic numbers)
215
215
# Replace escaped newlines by actual newlines for readability
216
216
# shellcheck disable=SC1003
217
217
sed -i.bak -E -e ' s/\\n/\' $' \n /g' " $stdout_path "
218
- sed -i.bak -e ' s/\(^[ ]*auxdata: \)0x[0-9a-f]*$/\1<AUXDATA REMOVED>/' " $stdout_path "
218
+ sed -i.bak -e ' s/\(^[ ]*auxdata:[[:space:]] \)0x[0-9a-f]*$/\1<AUXDATA REMOVED>/' " $stdout_path "
219
219
rm " $stdout_path .bak"
220
220
else
221
221
sed -i.bak -e ' /^Warning: This is a pre-release compiler version, please do not use it in production./d' " $stderr_path "
@@ -458,7 +458,13 @@ printTask "Running general commandline tests..."
458
458
inputFile=" "
459
459
stdout=" $( cat " ${tdir} /output.json" 2> /dev/null || true) "
460
460
stdoutExpectationFile=" ${tdir} /output.json"
461
- command_args=" --standard-json " $( cat " ${tdir} /args" 2> /dev/null || true)
461
+ prettyPrintFlags=" "
462
+ if [[ ! -f " ${tdir} /no-pretty-print" ]]
463
+ then
464
+ prettyPrintFlags=" --pretty-json --json-indent 4"
465
+ fi
466
+
467
+ command_args=" --standard-json ${prettyPrintFlags} " $( cat " ${tdir} /args" 2> /dev/null || true)
462
468
else
463
469
if [ -e " ${tdir} /stdin" ]
464
470
then
0 commit comments