Skip to content

Commit 57ff72f

Browse files
authored
fix(forge): consistent handling unresolved imports (#11164)
* fix(forge): consistent handling unresolved imports * Add test
1 parent ad3bc41 commit 57ff72f

File tree

3 files changed

+54
-11
lines changed

3 files changed

+54
-11
lines changed

Cargo.lock

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ foundry-linking = { path = "crates/linking" }
204204

205205
# solc & compilation utilities
206206
foundry-block-explorers = { version = "0.20.0", default-features = false }
207-
foundry-compilers = { version = "0.18.0", default-features = false }
207+
foundry-compilers = { version = "0.18.1", default-features = false }
208208
foundry-fork-db = "0.16"
209209
solang-parser = { version = "=0.3.9", package = "foundry-solang-parser" }
210210
solar-ast = { version = "=0.1.5", default-features = false }

crates/forge/tests/cli/build.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,3 +329,46 @@ contract ValidContract {}
329329

330330
cmd.args(["build"]).assert_success();
331331
});
332+
333+
// <https://github.com/foundry-rs/foundry/issues/11149>
334+
forgetest_init!(test_consistent_build_output, |prj, cmd| {
335+
prj.add_source(
336+
"AContract.sol",
337+
r#"
338+
import {B} from "/badpath/B.sol";
339+
340+
contract A is B {}
341+
"#,
342+
)
343+
.unwrap();
344+
345+
prj.add_source(
346+
"CContract.sol",
347+
r#"
348+
import {B} from "badpath/B.sol";
349+
350+
contract C is B {}
351+
"#,
352+
)
353+
.unwrap();
354+
355+
cmd.args(["build", "src/AContract.sol"]).assert_failure().stdout_eq(str![[r#"
356+
...
357+
Unable to resolve imports:
358+
"/badpath/B.sol" in "[..]"
359+
with remappings:
360+
forge-std/=[..]
361+
[COMPILING_FILES] with [SOLC_VERSION]
362+
[SOLC_VERSION] [ELAPSED]
363+
364+
"#]]);
365+
cmd.forge_fuse().args(["build", "src/CContract.sol"]).assert_failure().stdout_eq(str![[r#"
366+
Unable to resolve imports:
367+
"badpath/B.sol" in "[..]"
368+
with remappings:
369+
forge-std/=[..]
370+
[COMPILING_FILES] with [SOLC_VERSION]
371+
[SOLC_VERSION] [ELAPSED]
372+
373+
"#]]);
374+
});

0 commit comments

Comments
 (0)