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 script --json always returns a zero status #2508

Closed
2 tasks done
Inphi opened this issue Jul 29, 2022 · 1 comment · Fixed by #7071
Closed
2 tasks done

forge script --json always returns a zero status #2508

Inphi opened this issue Jul 29, 2022 · 1 comment · Fixed by #7071
Assignees
Labels
C-forge Command: forge Cmd-forge-script Command: forge script T-bug Type: bug

Comments

@Inphi
Copy link
Contributor

Inphi commented Jul 29, 2022

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (2f4dc6c 2022-07-29T00:03:54.821792323Z)

What command(s) is the bug in?

forge script --json Contract

Operating System

Linux

Describe the bug

Errors in a solidity script caused by reverts, asserts, etc, induce a non-zero exit code. However, running the script with the --json option always returns zero.

$ forge script AlwaysReverts --json && echo "success"
[⠰] Compiling...
[⠔] Compiling 4 files with 0.8.14
[⠃] Compiling 6 files with 0.8.9
[⠊] Solc 0.8.9 finished in 1.27s
[⠆] Solc 0.8.14 finished in 1.29s
Compiler run successful

{"logs":[],"gas_used":299261,"returns":{}}
success

$ forge script AlwaysReverts && echo exited
[⠰] Compiling...
[⠑] Compiling 5 files with 0.8.9
[⠃] Solc 0.8.9 finished in 1.24s
Compiler run successful


Script failed.
Gas used: 299261

== Return ==
Error:
Script failed.

This is a surprising behavior and I'd expect the exit status when adding --json to work the same way without the option.

@Inphi Inphi added the T-bug Type: bug label Jul 29, 2022
@mattsse mattsse added the Cmd-forge-script Command: forge script label Jul 29, 2022
@onbjerg onbjerg added this to the v1.0.0 milestone Jul 30, 2022
@onbjerg onbjerg added the C-forge Command: forge label Jul 30, 2022
@onbjerg onbjerg removed this from the v1.0.0 milestone Aug 23, 2022
@mds1
Copy link
Collaborator

mds1 commented Apr 11, 2023

Confirmed that forge test --json exits with an error, but forge script --json does not. Going to add this to #4444 to track

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-forge Command: forge Cmd-forge-script Command: forge script T-bug Type: bug
Projects
Status: Completed
Development

Successfully merging a pull request may close this issue.

5 participants