-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
feat: define solidity test sources in config #5870
base: v-next
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
b0bdb71
to
8d671af
Compare
980d558
to
9721ff4
Compare
9721ff4
to
c6e7ae9
Compare
c6e7ae9
to
c03c9f7
Compare
c03c9f7
to
c829cb3
Compare
c829cb3
to
4958af2
Compare
4958af2
to
3ce0176
Compare
3ce0176
to
0ebcfbf
Compare
@@ -161,6 +161,11 @@ const config: HardhatUserConfig = { | |||
tests: { | |||
mocha: "test/mocha", | |||
nodeTest: "test/node", | |||
solidity: [ | |||
"contracts/Counter.sol", |
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.
The semantics of this are slightly different than what the other tests
entries use. Here this is "files to be compiled", while the others are "folders where tests can be found".
If we use the rules to find solidity tests files discussed in my other comment, the "folders" approach makes more sense.
} | ||
}), | ||
hre.config.paths.tests.solidity | ||
.map((p) => resolveFromRoot(hre.config.paths.root, p)) |
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.
This would change based on the other comments
// NOTE: The uncached sources will still be compiled event if `noCompile` | ||
// is true. We could consider adding a `cacheOnly` option to support true | ||
// `noCompile` behavior. | ||
force: !noCompile, |
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.
If I run npx hardhat test solidity
it will force and recompile everything
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.
Maybe add an issue and address it after we have the compilation cache in place, and when we have the split between production and test compilation caches or while implementing that.
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.
We should also consider removing this option
* It throws a HardhatError if the build results indicate that the compilation | ||
* job failed. | ||
*/ | ||
export function throwIfSolidityBuildFailed( |
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.
For a future PR: we should use the same implementation here and during compile
.
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.
mostly to have a consistent ui
@@ -257,8 +257,9 @@ describe("HookManager", () => { | |||
_context: HookContext, | |||
givenHre: HardhatRuntimeEnvironment, | |||
): Promise<void> => { | |||
givenHre.config.paths.tests = | |||
"./test-folder-from-plugin1"; | |||
givenHre.config.paths.tests = { |
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.
This is a bit confusing, maybe not needed.
We chatted about this on a call: we'd treat solidity files as solidity test file if they either end in
Let's default to |
This PR:
solidity
key to thepaths.tests
user config (defaults topaths.sources.solidity
value)compile
task from thetest:solidity
taskpaths.tests.solidity
to thetest:solidity
taskTo compile a subset of sources for solidity tests, I use the build function from the build system programmatically (and prepare required inputs in the solidity test task action).
To make the artifact discovery work properly, I had to add
contractArtifactsGenerated
property to theCacheHitFileBuildResult
. This is because given a compilation job, we need to be able to tell what artifacts were generated, even if that job was cached.One alternative/extension considered was to define the solidity test paths per build profile. This would have allowed greater level of configuration. We decided not to proceed with that, at least for now.