Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

forge test/forge script: throw when ffi fails #2932

Closed
0xPhaze opened this issue Aug 25, 2022 · 4 comments · Fixed by #5660
Closed

forge test/forge script: throw when ffi fails #2932

0xPhaze opened this issue Aug 25, 2022 · 4 comments · Fixed by #5660
Labels
A-cheatcodes Area: cheatcodes T-feature Type: feature

Comments

@0xPhaze
Copy link

0xPhaze commented Aug 25, 2022

Component

Forge

Describe the feature you would like

I would expect the script to halt and throw when vm.ffi fails. Currently it (almost) silently continues and prints "Script ran successfully."

Additional context

No response

@0xPhaze 0xPhaze added the T-feature Type: feature label Aug 25, 2022
@gakonst gakonst moved this to Todo in Foundry Aug 25, 2022
@gakonst gakonst added this to Foundry Aug 25, 2022
@rkrasiuk rkrasiuk added the A-cheatcodes Area: cheatcodes label Aug 25, 2022
@mattsse
Copy link
Member

mattsse commented Aug 25, 2022

@onbjerg this came up here #2520 as well.

from a DX perspective it'd be more convenient to simply print the error, even though it may not match the order of the test output

@cxkoda
Copy link

cxkoda commented Sep 5, 2022

I'm facing a similar problem where all I'm interested in is the exit code of an external program.
For me it would be best if ffi returned something like (bytes memory result, uint8 errno). Might be worth considering to generalize it even further and give the caller full control over all outputs by returning something like (bytes memory stdout, bytes memory stderr, uint8 errno) via a dedicated cheatcode?

@mattsse
Copy link
Member

mattsse commented Sep 5, 2022

I can see that this is useful, maybe we add a tryFfi cheatcode that returns both stdout and sterr @onbjerg ?

@gakonst
Copy link
Member

gakonst commented Sep 6, 2022

Yeah supportive of tryFfi and returning the error code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cheatcodes Area: cheatcodes T-feature Type: feature
Projects
Archived in project
5 participants