Skip to content

Commit

Permalink
Merge branch 'master' into feat/solc_use_latest_patch
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdefinitelyahuman authored Jan 17, 2022
2 parents 7c66871 + 202c43d commit ffec657
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Force files to be opened as UTF-8
- Added a new solidity compiler setting `use_latest_patch` in brownie-config.yaml to use the latest patch version of a compiler based on the pragma version of the contract.
- Add cli flag `-r` for raising exceptions to the caller instead of doing a system exit.

## [1.17.2](https://github.com/eth-brownie/brownie/tree/v1.17.2) - 2021-12-04
### Changed
Expand Down
5 changes: 4 additions & 1 deletion brownie/_cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,7 @@ def main():
notify("ERROR", "Brownie environment has not been initiated for this folder.")
sys.exit("Type 'brownie init' to create the file structure.")
except Exception as e:
sys.exit(color.format_tb(e))
if "-r" in sys.argv:
raise e
else:
sys.exit(color.format_tb(e))
5 changes: 5 additions & 0 deletions brownie/_cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
--network [name] Use a specific network (default {CONFIG.settings['networks']['default']})
--silent Suppress console output for transactions
--interactive -I Open an interactive console when the script completes or raises
--raise -r Raise exceptions occured in the script to the caller
--gas -g Display gas profile for function calls
--tb -t Show entire python traceback on exceptions
--help -h Display this message
Expand Down Expand Up @@ -55,7 +56,11 @@ def main():
)
exit_code = 0
except Exception as e:
if args["--raise"]:
raise e

print(color.format_tb(e))

frame = next(
(i.frame for i in inspect.trace()[::-1] if Path(i.filename).as_posix() == path_str),
None,
Expand Down
14 changes: 14 additions & 0 deletions brownie/data/network-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,20 @@ live:
host: https://api.harmony.one
id: harmony-main
multicall2: "0x3E01dD8a5E1fb3481F0F589056b428Fc308AF0Fb"
- name: Optimistic Ethereum
networks:
- name: Mainnet
chainid: 10
id: optimism-main
host: https://mainnet.optimism.io
explorer: https://api-optimistic.etherscan.io/api
multicall2: "0x2DC0E2aa608532Da689e89e237dF582B783E552C"
- name: Kovan
chainid: 69
id: optimism-test
host: https://kovan.optimism.io
explorer: https://api-kovan-optimistic.etherscan.io/api
multicall2: "0x2DC0E2aa608532Da689e89e237dF582B783E552C"
- name: Polygon
networks:
- name: Mainnet (Infura)
Expand Down
14 changes: 14 additions & 0 deletions tests/cli/test_cli_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,20 @@ def test_cli_run_with_missing_file(cli_tester):
assert cli_tester.mock_subroutines.call_count == 1


def test_cli_run_with_raise_flag(cli_tester):
cli_tester.monkeypatch.setattr("brownie.run", cli_tester.mock_subroutines)

subtargets = ("brownie.network.connect",)
for target in subtargets:
cli_tester.monkeypatch.setattr(target, cli_tester.mock_subroutines)

with pytest.raises(FileNotFoundError):
cli_tester.run_and_test_parameters("run testfile -r", parameters=None)

assert cli_tester.mock_subroutines.called is True
assert cli_tester.mock_subroutines.call_count == 1


def test_cli_ethpm(cli_tester, testproject):
cli_tester.monkeypatch.setattr("brownie._cli.ethpm._list", cli_tester.mock_subroutines)

Expand Down

0 comments on commit ffec657

Please sign in to comment.