Skip to content

Commit 4b0d057

Browse files
authored
fix: request ABI in solar_project (#11697)
* fix: request ABI in solar_project We need to request something so that we populate the artifacts in the cache in case it is the first compiler invocation. Requesting nothing at all will not return anything in the output, and so we would have no artifacts in the cache entry, resulting in incorrect "nothing to compile" results after the first run. * test
1 parent 79a5eb8 commit 4b0d057

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

crates/config/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,9 @@ impl Config {
963963
let ui_testing = std::env::var_os("FOUNDRY_LINT_UI_TESTING").is_some();
964964
let mut project = self.create_project(self.cache && !ui_testing, false)?;
965965
project.update_output_selection(|selection| {
966-
*selection = OutputSelection::common_output_selection([]);
966+
// We have to request something to populate `contracts` in the output and thus
967+
// artifacts.
968+
*selection = OutputSelection::common_output_selection(["abi".into()]);
967969
});
968970
Ok(project)
969971
}

crates/forge/tests/cli/eip712.rs

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use foundry_config::fs_permissions::PathPermission;
22

33
forgetest!(test_eip712, |prj, cmd| {
4-
let path = prj.add_source(
5-
"Structs",
4+
let path = prj.add_test(
5+
"Structs.sol",
66
r#"
77
library Structs {
88
struct Foo {
@@ -50,14 +50,20 @@ library Structs2 {
5050
Structs.Rec rec;
5151
}
5252
}
53+
54+
contract DummyTest {
55+
function testDummy() public pure {
56+
revert("test");
57+
}
58+
}
5359
"#,
5460
);
5561

5662
cmd.forge_fuse().args(["eip712", path.to_string_lossy().as_ref()]).assert_success().stdout_eq(
5763
str![[r#"
5864
[COMPILING_FILES] with [SOLC_VERSION]
5965
[SOLC_VERSION] [ELAPSED]
60-
No files changed, compilation skipped
66+
Compiler run successful!
6167
Structs.sol > Structs > Foo:
6268
- type: Foo(Bar bar)Art(uint256 id)Bar(Art art)
6369
- hash: 0x6d9b732373bd999fde4072274c752e03f7437067dd75521eb406d8edf1d30f7d
@@ -150,6 +156,26 @@ Structs.sol > Structs2 > FooBar:
150156
151157
"#]],
152158
);
159+
160+
// Testing `solar_project` doesn't mess up cache.
161+
cmd.forge_fuse().arg("test").assert_failure().stdout_eq(str![[r#"
162+
[COMPILING_FILES] with [SOLC_VERSION]
163+
[SOLC_VERSION] [ELAPSED]
164+
Compiler run successful!
165+
166+
Ran 1 test for test/Structs.sol:DummyTest
167+
[FAIL: test] testDummy() ([GAS])
168+
Suite result: FAILED. 0 passed; 1 failed; 0 skipped; [ELAPSED]
169+
170+
Ran 1 test suite [ELAPSED]: 0 tests passed, 1 failed, 0 skipped (1 total tests)
171+
172+
Failing tests:
173+
Encountered 1 failing test in test/Structs.sol:DummyTest
174+
[FAIL: test] testDummy() ([GAS])
175+
176+
Encountered a total of 1 failing tests, 0 tests succeeded
177+
178+
"#]]);
153179
});
154180

155181
forgetest!(test_eip712_free_standing_structs, |prj, cmd| {
@@ -180,7 +206,7 @@ library InsideLibrary {
180206
str![[r#"
181207
[COMPILING_FILES] with [SOLC_VERSION]
182208
[SOLC_VERSION] [ELAPSED]
183-
No files changed, compilation skipped
209+
Compiler run successful!
184210
FreeStanding:
185211
- type: FreeStanding(uint256 id,string name)
186212
- hash: 0xfb3c934b2382873277133498bde6eb3914ab323e3bef8b373ebcd423969bf1a2

0 commit comments

Comments
 (0)