-
Notifications
You must be signed in to change notification settings - Fork 4k
Test cleanup and add solcover #178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
207cbe8
Moved all OVM files and deleted the package
smartcontracts 358ea4c
Started cleaning contracts
smartcontracts 922536a
Quick contract cleanup
smartcontracts 073448a
Added cleaned contracts
smartcontracts 64b7000
Fixed merge conflicts
smartcontracts ba1d7bc
Fixed package.json
smartcontracts 16b9374
Removed /ovm requirements
smartcontracts 30e6b2e
Fixed circular dependencies
smartcontracts 3e1801b
Fixed various linting errors
smartcontracts fc409d8
Fixed yet another ganache-core issue
smartcontracts 41bc77c
Fixed bug causing tests to fail
smartcontracts 3baed52
Fixed bug causing tests to fail
smartcontracts 64c7f01
Merged master
smartcontracts 78ce1bc
Merge branch 'master' of github.com:ethereum-optimism/optimism-monore…
smartcontracts 4593033
Added older RLPEncode file again
smartcontracts 5840831
Renamed rollup-contracts => contracts
smartcontracts 45e94f4
Transitioned contracts to use buidler
smartcontracts 470fbe1
Linted and added better export method
smartcontracts a2b9b85
Fixed a typo
smartcontracts 9b94f0d
Merged master
smartcontracts 2e3fa36
Removed unused imports
smartcontracts ef6a154
Removed unused variables
smartcontracts a0c695c
Started reworking test helpers
smartcontracts 5af729c
Clean up test helpers
smartcontracts 0259ab4
Fixed linting errors
smartcontracts 4519577
Support globs in solcover
smartcontracts 5d0c209
Merged master and linted
smartcontracts 753a147
Merge remote-tracking branch 'origin/master' into YAS-467/contracts/c…
smartcontracts 7cc641c
Removed ganache typings entirely
smartcontracts df9336d
Fixed missing import
smartcontracts 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 hidden or 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 hidden or 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,5 @@ | ||
| .coverage_artifacts/ | ||
| .coverage_cache/ | ||
| .coverage_contracts/ | ||
| coverage/ | ||
| coverage.json |
This file contains hidden or 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,69 @@ | ||
| /** | ||
| * SolCover configuration management: | ||
| * | ||
| * SolCover unfortunately doesn't provide us with the ability to exclusively | ||
| * generate coverage reports for a given file. Although we can use the | ||
| * `--testfiles`` parameter to limit tests to a particular glob, SolCover will | ||
| * still try to generate coverage reports for anything not covered within the | ||
| * `skipFiles` option exported below. `skipFiles` additionally does not parse | ||
| * globs, creating a mismatch between it and the `--testfiles` option. | ||
| * | ||
| * To address the above issues, we take the following steps: | ||
| * 1. Parse the `--testfiles` option from our command-line arguments. | ||
| * 2. Use the `--testfiles` option to find the list of contracts to be tested. | ||
| * 3. Find *all* contracts and exclude the results of (2). | ||
| * 4. Add the result of (3) to `skipFiles`. | ||
| * | ||
| * NOTE: The above will *only* work if contract test files follow the | ||
| * `<ContractName>.spec.ts` convention. Our function will fail to find the | ||
| * correct contracts otherwise. | ||
| */ | ||
|
|
||
| const path = require('path') | ||
| const glob = require('glob') | ||
| const ArgumentParser = require('argparse').ArgumentParser | ||
|
|
||
| const parser = new ArgumentParser() | ||
| parser.addArgument( | ||
| ['--testfiles'], | ||
| ) | ||
|
|
||
| /** | ||
| * Given a glob, finds all files to skip. | ||
| * @param skipFiles Path or glob of files to skip. | ||
| * @returns Paths to files to skip. | ||
| */ | ||
| const parseSkipFiles = (skipFiles) => { | ||
| return skipFiles.reduce((files, contract) => { | ||
| return files.concat(glob.sync(contract)) | ||
| }, []).map((contract) => { | ||
| return contract.replace('contracts/', '') | ||
| }) | ||
| } | ||
|
|
||
| /** | ||
| * Given a glob, finds all contracts to skip that are *not* the given files. | ||
| * @param includeFiles Path or glob of files not to skip. | ||
| * @returns Paths to files to skip. | ||
| */ | ||
| const parseIncludeFiles = (includeFiles) => { | ||
| const allFiles = parseSkipFiles(['contracts/**/*.sol']) | ||
| const includedFiles = parseSkipFiles(includeFiles) | ||
| return allFiles.filter((file) => { | ||
| return !includedFiles.includes(file) | ||
| }) | ||
| } | ||
|
|
||
| /** | ||
| * Parses command-line arguments and picks out the correct contracts to skip. | ||
| */ | ||
| const parseTestFiles = () => { | ||
| const args = parser.parseKnownArgs()[0] | ||
| const testFileName = path.basename(args.testfiles) | ||
| const contractFileName = testFileName.split('.')[0] + '.sol' | ||
| return parseIncludeFiles(['contracts/**/' + contractFileName]) | ||
| } | ||
|
|
||
| module.exports = { | ||
| skipFiles: parseTestFiles() | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
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.
General explainer for this file:
solcoveronly gives us the option to skip specific contracts during the instrumentation phase (so we can't explicitly list out the contracts we do want).solcoveralso doesn't allow us to use globs. This file pulls out thetestfilesargument from the coverage script insidepackage.jsonand automatically determines the corresponding contract. It then skips all contracts except the corresponding contract.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.
Could consider putting this explainer in as a comment in the file