Strip common path prefix#247
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.
| })?; | ||
|
|
||
| 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.
@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.
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
_filesis stripped from the paths:Details
#fileshave been updated to expect common prefix stripped.#files.Addresses #212.