Skip to content
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

Tests aren't recompiled when one of their imports changes #188

Closed
jparklev opened this issue Nov 29, 2021 · 5 comments
Closed

Tests aren't recompiled when one of their imports changes #188

jparklev opened this issue Nov 29, 2021 · 5 comments

Comments

@jparklev
Copy link
Contributor

jparklev commented Nov 29, 2021

The Problem

When running tests using forge test, an update to the contracts imported by the tests doesn't trigger recompilations for the tests. For example, if we have a test file test.t.sol:

import { Lad } from "../Lad.sol";
...
function testLad() public { assertEq(lad.flip(), 123); }
...

Then we update the implementation of lad.flip() to return 321 rather than 123, the tests still pass on the next forge test since the test.t.sol didn't recompile. Changing anything in the test file triggers a recompilation and then the tests fail as expected.

Possible Solution

My understanding is that this has to do with the way ethers-rs is caching and deciding when a file needs to be recompiled. A solution might be invalidate cached files if a) their source has changed, or b) the source of any of their imports has changed. I could be missing something about what ethers is doing atm, though. Haven't gotten into that src much yet.

Also lemme know if you'd like to push this issue over the the ethers repo for better tracking.

@jparklev jparklev changed the title Tests aren't automatically recompiled when one of their imports changes Tests aren't recompiled when one of their imports changes Nov 29, 2021
@mattsse
Copy link
Member

mattsse commented Nov 29, 2021

this is definitely an ethers-solc issue, and you're probably right with your diagnosis.
I assume the following is happening, during compilation we're mostly concerned with src contracts and not necessarily test contracts so that test files aren't properly checked for changes if the src contract is unchanged when we construct the dependency tree from the src contract's pov.

@mattsse
Copy link
Member

mattsse commented Nov 29, 2021

there were some ethers-solc changes yesterday that are already included on foundry master, so just to clarify this happens with the current master as well @jparklev ?

@jparklev
Copy link
Contributor Author

jparklev commented Nov 29, 2021

Actually I think i'm behind by a day or two, let me try with the latest @mattsse. brb

@jparklev
Copy link
Contributor Author

jparklev commented Nov 29, 2021

there were some ethers-solc changes yesterday that are already included on foundry master, so just to clarify this happens with the current master as well @jparklev ?

Confirmed on current master 👍

@gakonst
Copy link
Member

gakonst commented Nov 30, 2021

fixed in 0527eb9 / gakonst/ethers-rs#634, closing optimistically, please re-open if still a problem

charisma98 added a commit to charisma98/foundry that referenced this issue Mar 4, 2023
0129general added a commit to 0129general/FoundryProject that referenced this issue May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants