mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
prepare_report: Unify error/missing data handling between JS and Python versions
This commit is contained in:
parent
a036cbea19
commit
9f58f77b50
@ -23,24 +23,27 @@ for (const optimize of [false, true])
|
|||||||
}
|
}
|
||||||
|
|
||||||
const result = JSON.parse(compiler.compile(JSON.stringify(input)))
|
const result = JSON.parse(compiler.compile(JSON.stringify(input)))
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!('contracts' in result) ||
|
!('contracts' in result) ||
|
||||||
Object.keys(result['contracts']).length === 0 ||
|
Object.keys(result['contracts']).length === 0 ||
|
||||||
!result['contracts'][filename] ||
|
Object.keys(result['contracts']).every(file => Object.keys(result['contracts'][file]).length === 0)
|
||||||
Object.keys(result['contracts'][filename]).length === 0
|
|
||||||
)
|
)
|
||||||
// NOTE: do not exit here because this may be run on source which cannot be compiled
|
// NOTE: do not exit here because this may be run on source which cannot be compiled
|
||||||
console.log(filename + ': ERROR')
|
console.log(filename + ': ERROR')
|
||||||
else
|
else
|
||||||
for (const contractName in result['contracts'][filename])
|
for (const contractFile in result['contracts'])
|
||||||
{
|
for (const contractName in result['contracts'][contractFile])
|
||||||
const contractData = result['contracts'][filename][contractName];
|
{
|
||||||
if (contractData.evm !== undefined && contractData.evm.bytecode !== undefined)
|
const contractResults = result['contracts'][contractFile][contractName]
|
||||||
console.log(filename + ':' + contractName + ' ' + contractData.evm.bytecode.object)
|
|
||||||
else
|
let bytecode = 'NO BYTECODE'
|
||||||
console.log(filename + ':' + contractName + ' NO BYTECODE')
|
if ('evm' in contractResults && 'bytecode' in contractResults['evm'] && 'object' in contractResults['evm']['bytecode'])
|
||||||
console.log(filename + ':' + contractName + ' ' + contractData.metadata)
|
bytecode = contractResults.evm.bytecode.object
|
||||||
}
|
|
||||||
|
console.log(filename + ':' + contractName + ' ' + bytecode)
|
||||||
|
console.log(filename + ':' + contractName + ' ' + contractResults['metadata'])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,16 +28,19 @@ for optimize in [False, True]:
|
|||||||
args += ['--optimize']
|
args += ['--optimize']
|
||||||
proc = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
proc = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
(out, err) = proc.communicate(json.dumps(input_json).encode('utf-8'))
|
(out, err) = proc.communicate(json.dumps(input_json).encode('utf-8'))
|
||||||
try:
|
|
||||||
result = json.loads(out.decode('utf-8').strip())
|
result = json.loads(out.decode('utf-8').strip())
|
||||||
|
if (
|
||||||
|
'contracts' not in result or
|
||||||
|
len(result['contracts']) == 0 or
|
||||||
|
all(len(file_results) == 0 for file_name, file_results in result['contracts'].items())
|
||||||
|
):
|
||||||
|
REPORT_FILE.write(f + ": ERROR\n")
|
||||||
|
else:
|
||||||
for filename in sorted(result['contracts'].keys()):
|
for filename in sorted(result['contracts'].keys()):
|
||||||
for contractName in sorted(result['contracts'][filename].keys()):
|
for contractName in sorted(result['contracts'][filename].keys()):
|
||||||
contractData = result['contracts'][filename][contractName]
|
bytecode = result['contracts'][filename][contractName].get('evm', {}).get('bytecode', {}).get('object', 'NO BYTECODE')
|
||||||
if 'evm' in contractData and 'bytecode' in contractData['evm']:
|
metadata = result['contracts'][filename][contractName]['metadata']
|
||||||
REPORT_FILE.write(filename + ':' + contractName + ' ' +
|
|
||||||
contractData['evm']['bytecode']['object'] + '\n')
|
REPORT_FILE.write(filename + ':' + contractName + ' ' + bytecode + '\n')
|
||||||
else:
|
REPORT_FILE.write(filename + ':' + contractName + ' ' + metadata + '\n')
|
||||||
REPORT_FILE.write(filename + ':' + contractName + ' NO BYTECODE\n')
|
|
||||||
REPORT_FILE.write(filename + ':' + contractName + ' ' + contractData['metadata'] + '\n')
|
|
||||||
except KeyError:
|
|
||||||
REPORT_FILE.write(f + ": ERROR\n")
|
|
||||||
|
Loading…
Reference in New Issue
Block a user