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_gets_correct_files(): project_dir = "tests/utility/projects/test-01/" file_names = get_contract_files(project_dir) should_match = { 'MutanContract.mu', 'SerpentContract.se', 'LLLContract.lll', 'SolidityContract.sol', } should_not_match = { 'BackedUpContract.sol.bak', 'Swapfile.sol.swp', 'not-contract.txt', } for file_name in file_names: assert os.path.exists(file_name) assert os.path.basename(file_name) in should_match assert os.path.basename(file_name) not in should_not_match