Selecting a single test makes forge fail with `no matching artifact found`
Component
Forge
Have you ensured that all of these are up to date?
- [x] Foundry
- [x] Foundryup
What version of Foundry are you on?
forge Version: 1.4.2-stable Commit SHA: 828441d243f552f82c5a89bdc818e52bdd57b26b Build Timestamp: 2025-10-18T08:18:52.010540957Z (1760775532) Build Profile: maxperf
What version of Foundryup are you on?
foundryup: 1.0.1
What command(s) is the bug in?
forge test
Operating System
Linux
Describe the bug
On this repo, doing forge test goes through, but forge test --mt testDeployMorpho fails with [FAIL: vm.getCode: no matching artifact found] testDeployMorpho() (gas: 3475).
To see changes compared to the first commit: https://github.com/QGarchery/forge-deploy-code/compare/401cb00cb7964f04a96d6ab10d535d1acc40f019..f6a107856564a12b15b078e91f1cf356c0e027ec
thanks @QGarchery , indeed the artifact is not included in single test available artifacts, hence the problem, quick workaround until fix is you could just import it in test too
import {Test} from "forge-std/Test.sol";
import {Counter} from "../src/Counter.sol";
+import "../lib/morpho-blue/src/Morpho.sol";
(you can debug this scenarios and figure out which artifacts missing / need to import in test by running test with -vvv)
[3475] CounterTest::testDeployMorpho()
├─ [0] VM::getCode("Morpho.sol") [staticcall]
│ └─ ← [Revert] vm.getCode: no matching artifact found
└─ ← [Revert] vm.getCode: no matching artifact found
Note that the workaround is not always possible, notably if the pragma of the current file (the test file here, which could import a fixed pragma file) is incompatible with the pragma of the artifact (Morpho.sol in this case is fixed to 0.8.19)
Hey @grandizzy! When is the fix planned? This is basically making --mt --mc or --rerun unusable if you have one single deployment through getCode, which is quite annoying... Thanks in advance for the help.