fix(solc): skip artifacts check for files without artifacts (#1018)
This commit is contained in:
parent
beffe32f15
commit
6b0a1f7911
|
@ -638,23 +638,28 @@ impl<'a, T: ArtifactOutput> ArtifactsCacheInner<'a, T> {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
if !entry.contains_version(version) {
|
// only check artifact's existence if the file generated artifacts.
|
||||||
tracing::trace!(
|
// e.g. a solidity file consisting only of import statements (like interfaces that
|
||||||
"missing linked artifacts for source file `{}` for version \"{}\"",
|
// re-export) do not create artifacts
|
||||||
file.display(),
|
if !entry.artifacts.is_empty() {
|
||||||
version
|
if !entry.contains_version(version) {
|
||||||
);
|
tracing::trace!(
|
||||||
return true
|
"missing linked artifacts for source file `{}` for version \"{}\"",
|
||||||
}
|
file.display(),
|
||||||
|
version
|
||||||
if entry.artifacts_for_version(version).any(|artifact_path| {
|
);
|
||||||
let missing_artifact = !self.cached_artifacts.has_artifact(artifact_path);
|
return true
|
||||||
if missing_artifact {
|
}
|
||||||
tracing::trace!("missing artifact \"{}\"", artifact_path.display());
|
|
||||||
|
if entry.artifacts_for_version(version).any(|artifact_path| {
|
||||||
|
let missing_artifact = !self.cached_artifacts.has_artifact(artifact_path);
|
||||||
|
if missing_artifact {
|
||||||
|
tracing::trace!("missing artifact \"{}\"", artifact_path.display());
|
||||||
|
}
|
||||||
|
missing_artifact
|
||||||
|
}) {
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
missing_artifact
|
|
||||||
}) {
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
// all things match, can be reused
|
// all things match, can be reused
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -683,3 +683,51 @@ fn can_recompile_with_changes() {
|
||||||
assert!(compiled.find("A").is_some());
|
assert!(compiled.find("A").is_some());
|
||||||
assert!(compiled.find("B").is_some());
|
assert!(compiled.find("B").is_some());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn can_recompile_unchanged_with_empty_files() {
|
||||||
|
let tmp = TempProject::dapptools().unwrap();
|
||||||
|
|
||||||
|
tmp.add_source(
|
||||||
|
"A",
|
||||||
|
r#"
|
||||||
|
pragma solidity ^0.8.10;
|
||||||
|
import "./B.sol";
|
||||||
|
contract A {}
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
tmp.add_source(
|
||||||
|
"B",
|
||||||
|
r#"
|
||||||
|
pragma solidity ^0.8.10;
|
||||||
|
import "./C.sol";
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let c = r#"
|
||||||
|
pragma solidity ^0.8.10;
|
||||||
|
contract C {}
|
||||||
|
"#;
|
||||||
|
tmp.add_source("C", c).unwrap();
|
||||||
|
|
||||||
|
let compiled = tmp.compile().unwrap();
|
||||||
|
assert!(!compiled.has_compiler_errors());
|
||||||
|
assert!(compiled.find("A").is_some());
|
||||||
|
assert!(compiled.find("C").is_some());
|
||||||
|
|
||||||
|
let compiled = tmp.compile().unwrap();
|
||||||
|
assert!(compiled.find("A").is_some());
|
||||||
|
assert!(compiled.find("C").is_some());
|
||||||
|
assert!(compiled.is_unchanged());
|
||||||
|
|
||||||
|
// modify C.sol
|
||||||
|
tmp.add_source("C", format!("{}\n", c)).unwrap();
|
||||||
|
let compiled = tmp.compile().unwrap();
|
||||||
|
assert!(!compiled.has_compiler_errors());
|
||||||
|
assert!(!compiled.is_unchanged());
|
||||||
|
assert!(compiled.find("A").is_some());
|
||||||
|
assert!(compiled.find("C").is_some());
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue