-
Notifications
You must be signed in to change notification settings - Fork 46
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
Strip common path prefix #247
base: master
Are you sure you want to change the base?
Conversation
… expression between String and PathBuf
Summary: 1. After gathering paths test files matching the glob pattern and building paths to these test files, relative to a base directory (CARGO_MANIFEST_DIR by default), find the maximum common prefix for all the test cases and strip that prefix from each test case name. 2. Update test cases for #files to strip common prefix from expected paths.
attr.error(&format!("Invalid absolute path {}", e.to_string_lossy())) | ||
})?; | ||
|
||
for (abs_path, relative_path) in abs_paths.iter().zip(relative_paths) { | ||
if !refs.is_valid(&relative_path) { |
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.
@la10736 this is_valid
applies the original glob pattern path to the truncated path, hence path exclusion will not work after prefix stripping. I will move is_valid
check to before path stripping.
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.
Fixed it in 76671c7: I changed is_valid
-> !is_excluded
and moved is_excluded
into find_paths
, so find_paths
now applies both include
and exclude
globs.
THX for this PR!! Really appreciated! |
No rush and thank you for getting to reviewing it. |
@la10736 could we hop on a call so this would get merged? |
Sorry, I was really busy in the last 2 weeks. I any case I don't want that the test name can leak some information about the file system outside of the project tree: for instance that means you cannot remove the I would like to introduce |
I agree that prefix stripping should be optional and not the default behaviour. I will implement the I don't see a point in |
About leaking paths: upstream I agree that prefix stripping exposes more information about paths than the current behaviour so I will document on the proposed |
@la10736 thanks for getting to the review! |
Why don't maintain the actual path rendering (always start from the
It seams to me the best option. If you would I could help on it and write the parser part: just make the business based on a policy |
Just another small thing... please, can you fix the failed tests? I guess that you missed something when you rebased your PR. |
Strip common path prefixes in test case names, generated with macro
#files
.Implementation
After test file paths have been built relative to the base dir (
CARGO_MANIFEST_DIR
), find the maximum common prefix for all test paths and remove this prefix from the test case names.Example
rstest/tests/rstest/mod.rs demonstrates the gist of the change:
Common prefix
_files
is stripped from the paths:Details
#files
have been updated to expect common prefix stripped.#files
.Addresses #212.