Skip to content

Commit 44e8ada

Browse files
Merge pull request #13549 from miles170/develop
Fix stripping in CLI tests does not produce correct JSON formatting
2 parents b12b845 + dad1a56 commit 44e8ada

File tree

5 files changed

+51
-5
lines changed

5 files changed

+51
-5
lines changed

test/cmdlineTests.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,9 @@ function test_solc_behaviour
192192
import re, sys
193193
json = open("$stdout_path", "r").read()
194194
json = re.sub(r"{[^{}]*Warning: This is a pre-release compiler version[^{}]*},?", "", json)
195-
json = re.sub(r"},\s*]", "}]", json) # },] -> }]
196-
json = re.sub(r"\"errors\":\s*\[\s*\],?\s*","",json) # Remove "errors" array if it's not empty
197-
json = re.sub("\n\\s+\n", "\n\n", json) # Remove any leftover trailing whitespace
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) # },] -> }]
198198
open("$stdout_path", "w").write(json)
199199
EOF
200200
sed -i.bak -E -e 's/ Consider adding \\"pragma solidity \^[0-9.]*;\\"//g' "$stdout_path"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--pretty-json --json-indent 4
Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,19 @@
1-
{"errors":[{"component":"general","formattedMessage":"Cannot import url (\"standard_urls_existing_and_missing/non-existent-contract-1.sol\"): File not found. Searched the following locations: \"\".","message":"Cannot import url (\"standard_urls_existing_and_missing/non-existent-contract-1.sol\"): File not found. Searched the following locations: \"\".","severity":"warning","type":"Warning"}],"sources":{"url_not_found.sol":{"id":0}}}
1+
{
2+
"errors":
3+
[
4+
{
5+
"component": "general",
6+
"formattedMessage": "Cannot import url (\"standard_urls_existing_and_missing/non-existent-contract-1.sol\"): File not found. Searched the following locations: \"\".",
7+
"message": "Cannot import url (\"standard_urls_existing_and_missing/non-existent-contract-1.sol\"): File not found. Searched the following locations: \"\".",
8+
"severity": "warning",
9+
"type": "Warning"
10+
}
11+
],
12+
"sources":
13+
{
14+
"url_not_found.sol":
15+
{
16+
"id": 0
17+
}
18+
}
19+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--pretty-json --json-indent 4
Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,27 @@
1-
{"errors":[{"component":"general","formattedMessage":"Cannot import url (\"standard_urls_missing/non-existent-contract-1.sol\"): File not found. Searched the following locations: \"\".","message":"Cannot import url (\"standard_urls_missing/non-existent-contract-1.sol\"): File not found. Searched the following locations: \"\".","severity":"error","type":"IOError"},{"component":"general","formattedMessage":"Cannot import url (\"standard_urls_missing/non-existent-contract.sol\"): File not found. Searched the following locations: \"\".","message":"Cannot import url (\"standard_urls_missing/non-existent-contract.sol\"): File not found. Searched the following locations: \"\".","severity":"error","type":"IOError"},{"component":"general","formattedMessage":"Cannot import url (\"standard_urls_missing/non-existent-contract-2.sol\"): File not found. Searched the following locations: \"\".","message":"Cannot import url (\"standard_urls_missing/non-existent-contract-2.sol\"): File not found. Searched the following locations: \"\".","severity":"error","type":"IOError"}],"sources":{}}
1+
{
2+
"errors":
3+
[
4+
{
5+
"component": "general",
6+
"formattedMessage": "Cannot import url (\"standard_urls_missing/non-existent-contract-1.sol\"): File not found. Searched the following locations: \"\".",
7+
"message": "Cannot import url (\"standard_urls_missing/non-existent-contract-1.sol\"): File not found. Searched the following locations: \"\".",
8+
"severity": "error",
9+
"type": "IOError"
10+
},
11+
{
12+
"component": "general",
13+
"formattedMessage": "Cannot import url (\"standard_urls_missing/non-existent-contract.sol\"): File not found. Searched the following locations: \"\".",
14+
"message": "Cannot import url (\"standard_urls_missing/non-existent-contract.sol\"): File not found. Searched the following locations: \"\".",
15+
"severity": "error",
16+
"type": "IOError"
17+
},
18+
{
19+
"component": "general",
20+
"formattedMessage": "Cannot import url (\"standard_urls_missing/non-existent-contract-2.sol\"): File not found. Searched the following locations: \"\".",
21+
"message": "Cannot import url (\"standard_urls_missing/non-existent-contract-2.sol\"): File not found. Searched the following locations: \"\".",
22+
"severity": "error",
23+
"type": "IOError"
24+
}
25+
],
26+
"sources": {}
27+
}

0 commit comments

Comments
 (0)