mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Do not include empty JSON objects in output.
This commit is contained in:
parent
1bf396af78
commit
4c7151e57f
@ -764,14 +764,18 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input)
|
||||
m_compilerStack.runtimeSourceMapping(contractName)
|
||||
);
|
||||
|
||||
contractData["evm"] = evmData;
|
||||
if (!evmData.empty())
|
||||
contractData["evm"] = evmData;
|
||||
|
||||
if (!contractsOutput.isMember(file))
|
||||
contractsOutput[file] = Json::objectValue;
|
||||
|
||||
contractsOutput[file][name] = contractData;
|
||||
if (!contractData.empty())
|
||||
{
|
||||
if (!contractsOutput.isMember(file))
|
||||
contractsOutput[file] = Json::objectValue;
|
||||
contractsOutput[file][name] = contractData;
|
||||
}
|
||||
}
|
||||
output["contracts"] = contractsOutput;
|
||||
if (!contractsOutput.empty())
|
||||
output["contracts"] = contractsOutput;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ test_solc_behaviour() {
|
||||
|
||||
if [[ "$solc_args" == *"--standard-json"* ]]; then
|
||||
sed -i -e 's/{[^{]*Warning: This is a pre-release compiler version[^}]*},\{0,1\}//' "$stdout_path"
|
||||
sed -i -e 's/,"errors":\[\]//' "$stdout_path"
|
||||
sed -i -e 's/"errors":\[\],\{0,1\}//' "$stdout_path"
|
||||
else
|
||||
sed -i -e '/^Warning: This is a pre-release compiler version, please do not use it in production./d' "$stderr_path"
|
||||
sed -i -e 's/ Consider adding "pragma .*$//' "$stderr_path"
|
||||
|
@ -1 +1 @@
|
||||
{"contracts":{"A":{"C":{"evm":{}}}},"sources":{"A":{"id":0}}}
|
||||
{"sources":{"A":{"id":0}}}
|
||||
|
@ -1 +1 @@
|
||||
{"contracts":{"A":{"C":{"evm":{}}}},"sources":{"A":{"ast":{"absolutePath":"A","exportedSymbols":{"C":[6]},"id":7,"nodeType":"SourceUnit","nodes":[{"id":1,"literals":["solidity",">=","0.0"],"nodeType":"PragmaDirective","src":"0:22:0"},{"baseContracts":[],"contractDependencies":[],"contractKind":"contract","documentation":null,"fullyImplemented":true,"id":6,"linearizedBaseContracts":[6],"name":"C","nodeType":"ContractDefinition","nodes":[{"body":{"id":4,"nodeType":"Block","src":"61:2:0","statements":[]},"documentation":null,"id":5,"implemented":true,"kind":"function","modifiers":[],"name":"f","nodeType":"FunctionDefinition","parameters":{"id":2,"nodeType":"ParameterList","parameters":[],"src":"46:2:0"},"returnParameters":{"id":3,"nodeType":"ParameterList","parameters":[],"src":"61:0:0"},"scope":6,"src":"36:27:0","stateMutability":"pure","superFunction":null,"visibility":"public"}],"scope":7,"src":"23:42:0"}],"src":"0:65:0"},"id":0}}}
|
||||
{"sources":{"A":{"ast":{"absolutePath":"A","exportedSymbols":{"C":[6]},"id":7,"nodeType":"SourceUnit","nodes":[{"id":1,"literals":["solidity",">=","0.0"],"nodeType":"PragmaDirective","src":"0:22:0"},{"baseContracts":[],"contractDependencies":[],"contractKind":"contract","documentation":null,"fullyImplemented":true,"id":6,"linearizedBaseContracts":[6],"name":"C","nodeType":"ContractDefinition","nodes":[{"body":{"id":4,"nodeType":"Block","src":"61:2:0","statements":[]},"documentation":null,"id":5,"implemented":true,"kind":"function","modifiers":[],"name":"f","nodeType":"FunctionDefinition","parameters":{"id":2,"nodeType":"ParameterList","parameters":[],"src":"46:2:0"},"returnParameters":{"id":3,"nodeType":"ParameterList","parameters":[],"src":"61:0:0"},"scope":6,"src":"36:27:0","stateMutability":"pure","superFunction":null,"visibility":"public"}],"scope":7,"src":"23:42:0"}],"src":"0:65:0"},"id":0}}}
|
||||
|
@ -81,7 +81,9 @@ BOOST_AUTO_TEST_CASE(standard_compilation)
|
||||
|
||||
// Only tests some assumptions. The StandardCompiler is tested properly in another suite.
|
||||
BOOST_CHECK(result.isMember("sources"));
|
||||
BOOST_CHECK(result.isMember("contracts"));
|
||||
// This used to test that it is a member, but we did not actually request any output,
|
||||
// so there should not be a contract member.
|
||||
BOOST_CHECK(!result.isMember("contracts"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
Loading…
Reference in New Issue
Block a user