-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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: support absolute paths when matching paths #7362
feat: support absolute paths when matching paths #7362
Conversation
8bb3001
to
f3a9674
Compare
…-forge-test-absolute-path
Co-authored-by: Arsenii Kulikov <[email protected]>
I've just run the failing tests locally. Every test either fails when using the code from the repo, or passes when using both the code from the repo and the new code: forge::cli config::can_prioritise_closer_lib_remappings (fails with original code and new code) |
yeah, the ci is a little bit broken right now after forge-std release, we will fix this soon |
is fixed on master |
I just synced it again |
I just ran the following tests locally before and after syncing with master. They all passed with both versions. forge::cli script::can_broadcast_script_skipping_simulation |
Please review when you get the chance |
Thanks for your PR! I've pushed some changes to fix the merge conflict ( |
…om:matthewliu10/foundryCopy into bugfix/issue-7350-forge-test-absolute-path
pending @klkvr |
Motivation
Closes #7350
forge test --match-path absolute_path will report No tests match the provided pattern, only relative path works.
--match-path should work for both absolute path and relative path.
Solution
If the path given by the user is absolute, and the path given to the function is relative, it uses the canonicalize() function to turn the path given to the function into an absolute path so that the paths can be compared.
Notes
I initially tried converting both paths into their canonical forms using canonicalize and directly comparing them, however this failed on the can_test_with_match_path test because it would attempt to canonicalize "*src/ATest.t.sol" which causes an error.
There may be cases where the paths refer to the same location but is_match() still returns false. For example, if the user inputs "/home/user/a/b/../..//c/", it may not match with "/home/user/c/" even though they are equivalent. Note: canonicalize() resolves any symbolic links, relative path components, and removes any redundant components in the path.
Tests
The following 5 tests fail when running cargo test --all --all-features:
cmd::can_install_missing_deps_build
cmd::can_install_missing_deps_test
cmd::can_update_library_with_outdated_nested_dependency
config::can_parse_default_fs_permissions
ext_integration::snekmate
However, the following 4 tests still failed when I reverted the changes that I made (reverted code to the original code that I pulled from the repo):
cmd::can_install_missing_deps_build
cmd::can_install_missing_deps_test
cmd::can_update_library_with_outdated_nested_dependency
ext_integration::snekmate
The following test failed when I ran cargo test --all --all-features, but passed when I ran it individually:
config::can_parse_default_fs_permissions