-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(forge): added --json argument to
forge build
command (#6465)
* feat(forge): added --json argument to `forge build` command * refactor(forge): added standalone functions for suppress_compile* instead of an additional parameter * fix(forge): addec conflict constraint and renamed argument to format-json to avoid conflict with the test args * test(forge): added test for conflicts with silent argument * test(forge): added cli compile command with json argument test * rustfmt * lock --------- Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
- Loading branch information
1 parent
96bc0dc
commit 8b7500b
Showing
6 changed files
with
107 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use foundry_test_utils::{forgetest, util::OutputExt}; | ||
use std::path::PathBuf; | ||
|
||
// tests that json is printed when --json is passed | ||
forgetest!(compile_json, |prj, cmd| { | ||
prj.add_source( | ||
"jsonError", | ||
r" | ||
contract Dummy { | ||
uint256 public number; | ||
function something(uint256 newNumber) public { | ||
number = newnumber; // error here | ||
} | ||
} | ||
", | ||
) | ||
.unwrap(); | ||
|
||
// set up command | ||
cmd.args(["compile", "--format-json"]); | ||
|
||
// run command and assert | ||
cmd.unchecked_output().stdout_matches_path( | ||
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/compile_json.stdout"), | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"errors": [ | ||
{ | ||
"sourceLocation": { | ||
"file": "src/jsonError.sol", | ||
"start": 184, | ||
"end": 193 | ||
}, | ||
"type": "DeclarationError", | ||
"component": "general", | ||
"severity": "error", | ||
"errorCode": "7576", | ||
"message": "Undeclared identifier. Did you mean \"newNumber\"?", | ||
"formattedMessage": "DeclarationError: Undeclared identifier. Did you mean \"newNumber\"?\n --> src/dummy.sol:7:18:\n |\n7 | number = newnumber; // error here\n | ^^^^^^^^^\n\n" | ||
} | ||
], | ||
"sources": {}, | ||
"contracts": {}, | ||
"build_infos": {} | ||
} |