From b0622e9e5e2fab892ea05cae09487d02565cae5c Mon Sep 17 00:00:00 2001 From: Yhtyyar Sahatov Date: Tue, 4 Jul 2023 22:22:14 +0300 Subject: [PATCH 1/2] added --foundry-dont-skip flag --- crytic_compile/cryticparser/cryticparser.py | 8 +++++++ crytic_compile/cryticparser/defaults.py | 1 + crytic_compile/platform/foundry.py | 24 ++++++++++++++------- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/crytic_compile/cryticparser/cryticparser.py b/crytic_compile/cryticparser/cryticparser.py index f8848377..8b97f1c2 100755 --- a/crytic_compile/cryticparser/cryticparser.py +++ b/crytic_compile/cryticparser/cryticparser.py @@ -496,3 +496,11 @@ def _init_foundry(parser: ArgumentParser) -> None: dest="foundry_out_directory", default=DEFAULTS_FLAG_IN_CONFIG["foundry_out_directory"], ) + + group_foundry.add_argument( + "--foundry-dont-skip", + help='Do not add "--skip test script" flags', + action="store_true", + dest="foundry_dont_skip", + default=DEFAULTS_FLAG_IN_CONFIG["foundry_dont_skip"], + ) diff --git a/crytic_compile/cryticparser/defaults.py b/crytic_compile/cryticparser/defaults.py index fda8dc0a..b04ff494 100755 --- a/crytic_compile/cryticparser/defaults.py +++ b/crytic_compile/cryticparser/defaults.py @@ -45,6 +45,7 @@ "hardhat_artifacts_directory": None, "foundry_ignore_compile": False, "foundry_out_directory": "out", + "foundry_dont_skip": False, "export_dir": "crytic-export", "compile_libraries": None, } diff --git a/crytic_compile/platform/foundry.py b/crytic_compile/platform/foundry.py index f0d6c7f8..8cc56281 100755 --- a/crytic_compile/platform/foundry.py +++ b/crytic_compile/platform/foundry.py @@ -49,14 +49,22 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None: ) if not ignore_compile: - run( - [ - "forge", - "build", - "--build-info", - ], - cwd=self._target, - ) + commands_to_run = [ + "forge", + "build", + "--build-info", + ] + + dont_skip = kwargs.get("foundry_dont_skip", False) + if not dont_skip: + # Adding flags to skip test/ and script/ directory + commands_to_run += [ + "--skip", + "test", + "script", + ] + + run(commands_to_run, cwd=self._target) build_directory = Path( self._target, From 9de39f3fd31d9e22854bf3e52b474a7077b8ef84 Mon Sep 17 00:00:00 2001 From: Yhtyyar Sahatov Date: Wed, 5 Jul 2023 18:54:03 +0300 Subject: [PATCH 2/2] review fixes --- crytic_compile/platform/foundry.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crytic_compile/platform/foundry.py b/crytic_compile/platform/foundry.py index 8cc56281..70c6424d 100755 --- a/crytic_compile/platform/foundry.py +++ b/crytic_compile/platform/foundry.py @@ -60,8 +60,9 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None: # Adding flags to skip test/ and script/ directory commands_to_run += [ "--skip", - "test", - "script", + "*/test/**", + "*/script/**", + "--force", ] run(commands_to_run, cwd=self._target)