-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Expand forge test --match interface (again) #662
Expand forge test --match interface (again) #662
Conversation
Thanks for this write up! rn we're storing the paths to the artifact files relative to the output dir in the cache, but the keys (the file path) absolute, because that makes it consistent, because it's not guaranteed that all solidity source files are contained inside the project's dir (remappings, relative imports). I've added a couple of helper functions that strip/join with a base path (the project root) for example, like this https://github.com/gakonst/ethers-rs/blob/072bbb514721df67ca5359682dc081434aa632fc/ethers-solc/src/compile/output.rs#L85
we can't use
I think this would be possible now that we have a graph so we only (re)compile the contract and it's imports in question. |
Yeah, I'll take a look, thanks.
Good point, my thought was these would likely be non-test files (the versioned files) but it's better to not make that assumption.
Not sure what your eta is for the rewrite but I'll draft this over your branch? Ditto filtering. I was thinking it's probably possible for the graph to point to deps that are in excluded dirs, so they'd have to get picked up anyway, but pruning opportunistically and then filtering the output would probably cover all cases, while giving a speedup where a large % of contracts are being filtered out. |
Agree on pruning unneeded contracts. In general, we should imo only be compiling test contracts at the edge of the graph, and not explicitly compiling imported contracts as they're not really being used. This will yield significant compilation speedup. Right now we check for test contracts using the ABI which obviously requires having compiled them, may make sense to check the raw source for occurrences of the "function test" string to filter without needing to compile. The only time we need to compile all is when doing forge build I think. |
@gakonst @mattsse I'm going to separate pre-compile filtering into a separate PR, so I've left that out. I think it's worth discussing artifact naming more: In another issue, we had decided that it would be best to match dapptools style output for naming artifacts:
@mattsse pointed out that we're (maybe) compiling multiple versions of contracts, so it no longer makes sense to treat source paths as unique anymore. That's how I understood what you said at least. I'm not sure that guarantees uniqueness however, since it's possible to compile For keying it seems we would need a combo of relative source path + artifact version to ensure uniqueness. For display however, I'd suggest sth looser as:
I'd suggest this combo:
Maybe I'm overlooking sth here, what do you gents think? |
dd690ab
to
bc613e1
Compare
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.
so far so good,
smol nits
NB: I've bumped semver to 1.0.5 as that's required to develop locally with ethers-rs |
@gakonst @mattsse @brockelmore I'm integrating the new I noticed this: #586 (review) I'm also unable to put together a test project that will return anything from I'm trying to build a passing test case for the linking steps. |
https://github.com/gakonst/foundry/blob/master/cli/testdata/run_test_lib_linking.sol < see here for an example of constructing a project that needs linking |
Thanks @brockelmore 👍 |
I'm putting together a test for the linking that I'm running into keying issues since we're producing versioned artifacts and Sanity check: Am I overlooking something or do we need |
I think I can follow. the references of course refer to those contracts compiled with the same version. Reading this makes me think that we need a more sophisticated type that
I hope that made sense @lattejed ? |
@mattsse sorry if I wasn't clear. I'll give a contrived example. We have:
^ both are identical, just diff versions Both link to lib We get compiler output:
For artifact output, we get versioned names For linked references, we get Now, this is correct, since I assume we want to reference the versioned output since it may differ. We're already breaking from the |
@mattsse yeah, I do understand what you're suggesting. My question, is it more correct to:
Embedded in that - is using a combo of source names and versioned artifacts names internally in Again, I may be overlooking sth or my OCD may be creating issues where there are none -- just want to clarify this so I don't ship a new source of bugs. |
There'll be some Artifact type changes here gakonst/ethers-rs#907 and here #762
yeah, this is what I was thinking here #662 (comment), right?
Good idea, we want everything to be identifiable, either
sgtm |
3580486
to
74ec1d5
Compare
lgtm, @lattejed any objections? the ethers-rs version bug is fixed here gakonst/ethers-rs#930 |
9236bbc
to
99d6b6b
Compare
99d6b6b
to
1adc9a0
Compare
From here #388 (comment)
@gakonst I'd suggest this adds
--match-path
--no-match-path
to conform to the other match flags and because there's not a 1:1 between source paths and contract names.
@mattsse was looking at gakonst/ethers-rs#802 (great work btw, looks a lot cleaner) and it looks like here and here the compiler is now returning the artifact path. Is that now a relative path (matching the relative source path) or flat in the artifacts dir?
For #392 I understood the goal was to match dapptools which would require keying on / displaying the relative source path (e.g.,
src/test/Greeter.t.sol:Greet
)Specific to this PR we do need the (relative) source paths to filter against. Ideally
into_artifacts
would return this.It looks like you're almost done, I don't know if you want to add this in (if necessary) if not I'm happy to do it once you're done.
Also, @gakonst @mattsse I'm wondering if it's worthwhile to have the compiler skip compiling filtered-out sources? If a user is filtering out a large folder they would probably expect both testing and compilation to be skipped right?
If that makes sense,
Project
(assuming the name hasn't changed) could take a filter and filter source files or sth equivalent.