Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
klkvr committed Sep 17, 2024
1 parent 814a4d9 commit 488a4cd
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,5 @@ yansi = "1.0"
# async
futures-util = "0.3"
tokio = { version = "1.35", features = ["rt-multi-thread"] }

snapbox = "0.6.9"
1 change: 1 addition & 0 deletions crates/compilers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ fd-lock = "4.0.0"
tokio = { version = "1.35", features = ["rt-multi-thread", "macros"] }
reqwest = "0.12"
tempfile = "3.9"
snapbox.workspace = true
foundry-compilers-core = { workspace = true, features = ["test-utils"] }

[features]
Expand Down
28 changes: 27 additions & 1 deletion crates/compilers/src/resolver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ impl<L: Language, D: ParsedSource<Language = L>> Graph<D> {
line.push_str(&format!(" {req}"));
}

write!(f, "{} ", line.paint(color))
write!(f, "{}", line.paint(color))
};
format_node(idx, f)?;
write!(f, " imports:")?;
Expand Down Expand Up @@ -1052,6 +1052,32 @@ src/Dapp.t.sol >=0.6.6
);
}

#[test]
#[cfg(feature = "svm-solc")]
fn test_print_unresolved() {
let root =
Path::new(env!("CARGO_MANIFEST_DIR")).join("../../test-data/incompatible-pragmas");
let paths = ProjectPathsConfig::dapptools(&root).unwrap();
let graph = Graph::<SolData>::resolve(&paths).unwrap();
let Err(SolcError::Message(err)) = graph.get_input_node_versions(
false,
&Default::default(),
&crate::solc::SolcCompiler::AutoDetect,
) else {
panic!("expected error");
};

snapbox::assert_data_eq!(
err,
snapbox::str![[r#"
Found incompatible versions:
src/A.sol =0.8.25 imports:
src/B.sol
src/C.sol =0.7.0
"#]]
);
}

#[cfg(target_os = "linux")]
#[test]
fn can_read_different_case() {
Expand Down
3 changes: 3 additions & 0 deletions test-data/incompatible-pragmas/src/A.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pragma solidity 0.8.25;

import "./B.sol";
1 change: 1 addition & 0 deletions test-data/incompatible-pragmas/src/B.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "./C.sol";
1 change: 1 addition & 0 deletions test-data/incompatible-pragmas/src/C.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pragma solidity 0.7.0;

0 comments on commit 488a4cd

Please sign in to comment.