From 4635aa0bc8d10df5dc005d6f165a5fd148cfd2fa Mon Sep 17 00:00:00 2001 From: alpharush <0xalpharush@protonmail.com> Date: Fri, 22 Mar 2024 14:38:04 -0500 Subject: [PATCH] fix: normalize windows path to handle solc >=0.8.8 filename lookup --- .github/workflows/pytest.yml | 2 +- crytic_compile/utils/naming.py | 9 +++++---- tests/call_to_variable-all.sol-0.5.8-legacy.zip | Bin 0 -> 1913 bytes 3 files changed, 6 insertions(+), 5 deletions(-) create mode 100644 tests/call_to_variable-all.sol-0.5.8-legacy.zip diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 92549ce8..6cedd199 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -40,4 +40,4 @@ jobs: pip install solc-select - name: Run Tests run: | - pytest tests/test_metadata.py + pytest tests diff --git a/crytic_compile/utils/naming.py b/crytic_compile/utils/naming.py index 7f5d1398..b062dd35 100644 --- a/crytic_compile/utils/naming.py +++ b/crytic_compile/utils/naming.py @@ -146,7 +146,7 @@ def convert_filename( if elements[0] == "/" or elements[0] == "\\": elements = elements[1:] # remove '/' elements[0] = elements[0] + ":/" # add :/ - filename = Path(*elements) + filename = Path(*elements).as_posix_path() else: filename = Path(filename_txt) @@ -188,10 +188,11 @@ def convert_filename( short = relative short = relative_to_short(short) - + # Starting with v0.8.8 (https://github.com/ethereum/solidity/pull/11545), solc normalizes the paths to not include the drive on Windows, + # so it's important we use posix path here to avoid issues with the path comparison. return Filename( - absolute=str(absolute), + absolute=absolute.as_posix(), relative=relative.as_posix(), short=short.as_posix(), - used=str(used_filename), + used=Path(used_filename).as_posix(), ) diff --git a/tests/call_to_variable-all.sol-0.5.8-legacy.zip b/tests/call_to_variable-all.sol-0.5.8-legacy.zip new file mode 100644 index 0000000000000000000000000000000000000000..fd360787259f0e33f74974fdc7bc512bc711b844 GIT binary patch literal 1913 zcmb7_`9IT-1IORaa-Ym+0xxZee@r<#;ENHDwNi^)zvV~tT5A5%uaSoD zt{A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