def compile(): """ Compile contracts. """ click.echo('Compiling!') contract_source_paths = utils.get_contract_files(os.getcwd()) compiled_sources = {} for source_path in contract_source_paths: try: compiler = utils.get_compiler_for_file(source_path) except ValueError: raise click.ClickException("No compiler available for {0}".format(source_path)) with open(source_path) as source_file: source_code = source_file.read() compiled_sources.update(utils._compile_rich(compiler, source_code)) utils.write_compiled_sources(os.getcwd(), compiled_sources)
def compile(): """ Compile contracts. """ click.echo('Compiling!') contract_source_paths = utils.get_contract_files(os.getcwd()) compiled_sources = {} for source_path in contract_source_paths: try: compiler = utils.get_compiler_for_file(source_path) except ValueError: raise click.ClickException( "No compiler available for {0}".format(source_path)) with open(source_path) as source_file: source_code = source_file.read() compiled_sources.update(utils._compile_rich(compiler, source_code)) utils.write_compiled_sources(os.getcwd(), compiled_sources)
def test_unknown_contract_extensions(filename): with pytest.raises(ValueError): get_compiler_for_file(filename)
def test_solidity_compiler_not_available(): with pytest.raises(ValueError): get_compiler_for_file('Example.sol')
def test_solidity_compiler(): compiler = get_compiler_for_file('Example.sol') assert compiler == get_solidity()