-
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
forge build and forge test exit with No files changed, compilation skipped
message
#1244
Comments
I tried doing a minimal repro of the faulty setup here: https://github.com/karmacoma-eth/foundry-symlink-issue/pull/1/files ... but I am not actually able to reproduce 🤨 |
I think what may be happening is a combination of a forge feature and a bug: (1) Files are not recompiled if the content hasn't changed, even if the timestamp is newer than compilation outputs (2) If an error occurs during compilation, that file is still marked "not dirty" and won't be recompiled again until its contents change. This can lead to unexpected results, where you have an syntax error in a contract, and then don't save the file after fixing it, and run the E.g., Test.sol is a test for Tested.sol. Both have syntax errors. |
thanks so much for looking into this, this makes sense, will try to confirm and fix! |
While you are at it, please consider adding a feature/flag to force recompilation of units that have previously emitted warnings. --force is sometimes too aggressive but if you're trying to clean up warnings, you have to basically keep recompiling the world. |
maybe a I think we need to cache the errors as well, which is probably a good idea anyway. |
Whatever works for you. The usecase is to make cleaning up warnings not a pain. |
but cleaning up warnings always involves modifying the file? |
I think you're assuming that these ephemeral warnings are saved somewhere by the foundry user. Not every workflow involves an editor or IDE that has parsed and saved all the errors somewhere for the user to see later. Sometimes people issue a forge build or forge test specifically to cause the compiler to emit the same warnings they saw the last time they ran that command. If you implement a strict mode, and those files have not been touched, they should still invoke the compiler, so that the same messages will be emitted. Imagine a terminal based workflow where the user has cleared the terminal and needs to regenerate the warnings. As is, the user doesn't even know which files to touch and worse it's not enough to just touch them, the user has to make a content change. |
After foundryup earlier today. Not sure if that installs latest nightly. Also, maybe my cache was in a weird state from prior version but I don't think so (because I did a --force using latest after installing latest). I'll try to catch the sequence of events that leads to this. In case it's not obvious, the problem is that I asked for a test to be run, but got silent nothing, until I asked again with --force. If the |
thank you for your insights here! I definitely found an issue with the cache file that could lead to such a state, I wasn't able to reproduce this 1:1 but I think it's related. |
I would definitely add some output on non-matched That in and of itself may be worth a seperate Issue. |
that's a good idea for UX improvement, wdyt @onbjerg? we should track this separately I think |
We should track separately. Not sure if we want to error with exit code 1, but we should at least print the "x tests run; x ignored" etc. message. |
There is still a bug here. If forge build --force yields an error a subsequent forge built without --force will not recompile the failed file! |
thanks, any way to reproduce this? |
As described. Make a project with 2-3 files in it. Create a syntax error in one of the files. forge test/build --force. Your next forge test/build (without the force) won't rebuild the file that had the error if that file hasn't been touched. Maybe there's a philosophical issue here. Personally I expect if a file has errors, the build command should retry the build irrespective of whether it thinks the compilation source changed. Warnings may deserve a --force to rebuild. Better would be the --strict you previously suggested, where only the files with warnings would be rebuilt (vs all files). |
thanks, will investigate asap |
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (9c24694 2022-04-08T00:20:01.154330+00:00)
What command(s) is the bug in?
forge test
Operating System
macOS (amd)
Describe the bug
I got into a state where every
forge build
andforge test
command just returned some output like this, not actually building or testing anything:Even though I definitely have changed files. I added some
assert(false)
in my contracts, which should definitely blow up some tests, but I'm still getting the same.Some things I've tried:
cache/
out/
, but there is noout/
folder even afterforge build
forge test --force
, same thingforge test --run-all
, same thingThe context for the symlink is that I was trying to find a way to import a dependency that would work for both hardhat and foundry. I was able to deploy using hardhat with the symlink, but that turned out to break my foundry build/tests. I can go back to using the remapping, but that breaks hardhat deploys...
The text was updated successfully, but these errors were encountered: