@@ -68,7 +68,7 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None:
6868 Args:
6969 crytic_compile (CryticCompile): CryticCompile object to populate
7070 **kwargs: optional arguments. Used: "foundry_ignore_compile", "foundry_out_directory",
71- "foundry_build_info_directory", "foundry_deny"
71+ "foundry_build_info_directory", "foundry_deny", "foundry_no_force"
7272
7373 """
7474
@@ -105,9 +105,24 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None:
105105 ]
106106
107107 compile_all = kwargs .get ("foundry_compile_all" , False )
108+ no_force = kwargs .get ("foundry_no_force" , False )
108109
109110 foundry_config = self .config (self ._project_root )
110111
112+ # When no_force is enabled, we must compile all files (including tests)
113+ # to ensure test changes are detected. Otherwise tests would be skipped
114+ # and test modifications wouldn't trigger recompilation.
115+ # We also clean build-info to prevent multiple compilation units from accumulating.
116+ if no_force :
117+ compile_all = True
118+ out_dir = foundry_config .out_path if foundry_config else "out"
119+ build_info_dir = Path (self ._project_root , out_dir , "build-info" )
120+ if build_info_dir .exists ():
121+ import shutil
122+
123+ shutil .rmtree (build_info_dir )
124+ LOGGER .info ("Cleaned %s for fresh build-info generation" , build_info_dir )
125+
111126 if not targeted_build and not compile_all and foundry_config :
112127 compilation_command += [
113128 "--skip" ,
0 commit comments