-
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
feat(forge): implement glob pattern for forge build --skip #5267
Conversation
/// | ||
/// The glob `./test/*` won't match absolute paths like `test/Contract.sol`, which is common | ||
/// format here, so we also handle this case here | ||
pub fn is_match(&self, path: &str) -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally to match /private/var/folders/test/Foo.sol
(this is how it appears in the tests) one wouldn't need */test/**
and could instead use ./test/*
. I don't have insight into how paths are passed around in Foundry (are they always absolute?), but I could appreciate clarification on this point.
For example, this is the cause of the failing test:
let file = Path::new("/private/var/folders/test/Foo.sol");
assert!(!SkipBuildFilter::Custom("*/test/**".to_string()).is_match(file)); // passes
assert!(!SkipBuildFilter::Custom("./test/**".to_string()).is_match(file)); // fails
let file = Path::new("script/Contract.sol");
assert!(!SkipBuildFilter::Custom("*/script/**".to_string()).is_match(file)); // fails
assert!(!SkipBuildFilter::Custom("./script/**".to_string()).is_match(file)); // passes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have insight into how paths are passed around in Foundry (are they always absolute?)
they're relative to the configured root when dealing solc, outside of solc they always should be absolute, so foundry should always have absolute paths
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, tysm for this.
a few nits, tests look good though
/// | ||
/// The glob `./test/*` won't match absolute paths like `test/Contract.sol`, which is common | ||
/// format here, so we also handle this case here | ||
pub fn is_match(&self, path: &str) -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have insight into how paths are passed around in Foundry (are they always absolute?)
they're relative to the configured root when dealing solc, outside of solc they always should be absolute, so foundry should always have absolute paths
common/src/compile.rs
Outdated
@@ -528,8 +528,9 @@ impl FileFilter for SkipBuildFilter { | |||
/// This is returns the inverse of `file.name.contains(pattern)` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to update docs here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
6cc5074
to
1b35170
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm! thank you for this!
just a super small nit for consistency
Co-authored-by: evalir <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
tysm!
Motivation
Currently,
forge build --skip test --skip script
is unreliable as some projects do not consistently use.t.sol
or.s.sol
. This PR enables glob patterns like--skip */test/** --skip */script/**
to enable only buildingsrc
.Closes #4628
Solution
I moved an existing glob matcher util to
common
and used it in the theFileFilter
impl