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

Foundry --skip test script by default #466

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions crytic_compile/cryticparser/cryticparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
)
1 change: 1 addition & 0 deletions crytic_compile/cryticparser/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
24 changes: 16 additions & 8 deletions crytic_compile/platform/foundry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"test",
"script",
"'*/test/**'",
"'*/script/**'",
"--force",

This is necessary because not all test and scripts follow the foundry naming convention and if there's test/script artifacts in the cache they need to be removed

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tested like this, but strangely, it was not working correctly (not skipping), if you wrap it with single quotes. At the same time, If I copy-paste the output from logs, forge build --build-info --skip '*/test/**' '*/script/**' --force and run it, that is working. (No idea, if it is a python/OS issue)

Then I tried without quotes (seems like the forge supports this), and it worked.

]

run(commands_to_run, cwd=self._target)

build_directory = Path(
self._target,
Expand Down