Skip to content

Commit

Permalink
Merge pull request #127 from skellet0r/fix/invalid-default-compiler-o…
Browse files Browse the repository at this point in the history
…utputs

Fix/invalid default compiler outputs
  • Loading branch information
skellet0r authored Oct 12, 2021
2 parents 47899f8 + 86fc816 commit 13879e0
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 14 deletions.
5 changes: 3 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ bumpversion==0.5.3
flake8==3.8.3
isort==5.4.2
mypy==0.782
pytest>=6.0.0,<7.0.0
pytest-cov==2.10.1
pytest-mock==3.6.1
pytest>=6.0.0,<7.0.0
requests>=2.19.0,<3
semantic_version>=2.8.1,<3
sphinx==3.2.1
sphinx_rtd_theme==0.5.0
tox==3.19.0
tqdm>=4.48.0,<5.0.0
twine==3.2.0
requests>=2.19.0,<3
wheel==0.35.1
27 changes: 15 additions & 12 deletions solcx/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,11 @@ def compile_files(
)


def _get_combined_json_outputs() -> str:
help_str = wrapper.solc_wrapper(help=True)[0].split("\n")
def _get_combined_json_outputs(solc_binary: Union[Path, str] = None) -> str:
if solc_binary is None:
solc_binary = get_executable()

help_str = wrapper.solc_wrapper(solc_binary=solc_binary, help=True)[0].split("\n")
combined_json_args = next(i for i in help_str if i.startswith(" --combined-json"))
return combined_json_args.split(" ")[-1]

Expand All @@ -258,23 +261,23 @@ def _parse_compiler_output(stdoutdata: str) -> Dict:


def _compile_combined_json(
output_values: Optional[List],
solc_binary: Union[str, Path, None],
solc_version: Optional[Version],
output_dir: Union[str, Path, None],
overwrite: Optional[bool],
allow_empty: Optional[bool],
output_values: Optional[List] = None,
solc_binary: Union[str, Path, None] = None,
solc_version: Optional[Version] = None,
output_dir: Union[str, Path, None] = None,
overwrite: Optional[bool] = False,
allow_empty: Optional[bool] = False,
**kwargs: Any,
) -> Dict:

if solc_binary is None:
solc_binary = get_executable(solc_version)

if output_values is None:
combined_json = _get_combined_json_outputs()
combined_json = _get_combined_json_outputs(solc_binary)
else:
combined_json = ",".join(output_values)

if solc_binary is None:
solc_binary = get_executable(solc_version)

if output_dir:
output_dir = Path(output_dir)
if output_dir.is_file():
Expand Down
14 changes: 14 additions & 0 deletions tests/main/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import solcx
import solcx.main


def test_get_combined_json_outputs_defaults(mocker, foo_source):
# verify we get the correct combined json outputs for different
# compiler versions
spy = mocker.spy(solcx.main, "_get_combined_json_outputs")

solcx.compile_source(foo_source, solc_version="0.4.12")
assert "function-debug" not in spy.spy_return

solcx.compile_source(foo_source, solc_version="0.8.9")
assert "function-debug" in spy.spy_return

0 comments on commit 13879e0

Please sign in to comment.