This repository has been archived by the owner on Oct 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 795
feat: warnings as errors #1838
Merged
Merged
feat: warnings as errors #1838
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
123de71
feat: warnings as errors
jatkz 6bf0a92
changed the bool arg to Severity and updated its traits
jatkz be14b4c
reformat the test based on the linter
jatkz 3a4ffdf
renamed variable based on property type change and changed a few refs
jatkz b9f0ecc
updated changelog
jatkz 50464e9
Merge branch 'master' into warnings-as-errors
gakonst 8b68913
revert changelog iden change
gakonst db200ff
added test for combining compiler severity filter and ignored error c…
jatkz 8db929f
Merge branch 'warnings-as-errors' of https://github.com/JaredTokuz/et…
jatkz 90923c9
adjusted has_error to utilize ge functionality in case of info errors
jatkz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
3 changes: 3 additions & 0 deletions
3
ethers-solc/test-data/test-contract-warnings/LicenseWarning.sol
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,3 @@ | ||
pragma solidity 0.8.6; | ||
|
||
contract LicenseWarning {} |
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 |
---|---|---|
|
@@ -1618,6 +1618,81 @@ fn can_compile_model_checker_sample() { | |
assert!(compiled.has_compiler_warnings()); | ||
} | ||
|
||
#[test] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. perhaps worth adding a test where There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes please! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great catch, I wrote a new test which failed as predicted by David. I adjusted the has_error() fn to be a conjunction of the two solutions. Ty for the guidance everyone 🙏 |
||
fn test_compiler_severity_filter() { | ||
fn gen_test_data_warning_path() -> ProjectPathsConfig { | ||
let root = | ||
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("test-data/test-contract-warnings"); | ||
let paths = ProjectPathsConfig::builder().sources(root).build().unwrap(); | ||
paths | ||
} | ||
|
||
let project = Project::builder() | ||
.no_artifacts() | ||
.paths(gen_test_data_warning_path()) | ||
.ephemeral() | ||
.build() | ||
.unwrap(); | ||
let compiled = project.compile().unwrap(); | ||
assert!(compiled.has_compiler_warnings()); | ||
assert!(!compiled.has_compiler_errors()); | ||
|
||
let project = Project::builder() | ||
.no_artifacts() | ||
.paths(gen_test_data_warning_path()) | ||
.ephemeral() | ||
.set_compiler_severity_filter(ethers_solc::artifacts::Severity::Warning) | ||
.build() | ||
.unwrap(); | ||
let compiled = project.compile().unwrap(); | ||
assert!(compiled.has_compiler_warnings()); | ||
assert!(compiled.has_compiler_errors()); | ||
} | ||
|
||
#[test] | ||
fn test_compiler_severity_filter_and_ignored_error_codes() { | ||
fn gen_test_data_licensing_warning() -> ProjectPathsConfig { | ||
let root = | ||
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("test-data/test-contract-warnings/LicenseWarning.sol"); | ||
let paths = ProjectPathsConfig::builder().sources(root).build().unwrap(); | ||
paths | ||
} | ||
|
||
let missing_license_error_code = 1878; | ||
|
||
let project = Project::builder() | ||
.no_artifacts() | ||
.paths(gen_test_data_licensing_warning()) | ||
.ephemeral() | ||
.build() | ||
.unwrap(); | ||
let compiled = project.compile().unwrap(); | ||
assert!(compiled.has_compiler_warnings()); | ||
|
||
let project = Project::builder() | ||
.no_artifacts() | ||
.paths(gen_test_data_licensing_warning()) | ||
.ephemeral() | ||
.ignore_error_code(missing_license_error_code) | ||
.build() | ||
.unwrap(); | ||
let compiled = project.compile().unwrap(); | ||
assert!(!compiled.has_compiler_warnings()); | ||
assert!(!compiled.has_compiler_errors()); | ||
|
||
let project = Project::builder() | ||
.no_artifacts() | ||
.paths(gen_test_data_licensing_warning()) | ||
.ephemeral() | ||
.ignore_error_code(missing_license_error_code) | ||
.set_compiler_severity_filter(ethers_solc::artifacts::Severity::Warning) | ||
.build() | ||
.unwrap(); | ||
let compiled = project.compile().unwrap(); | ||
assert!(!compiled.has_compiler_warnings()); | ||
assert!(!compiled.has_compiler_errors()); | ||
} | ||
|
||
fn remove_solc_if_exists(version: &Version) { | ||
if Solc::find_svm_installed_version(version.to_string()).unwrap().is_some() { | ||
svm::remove_version(version).expect("failed to remove version") | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps follow convention here and change to: