-
Notifications
You must be signed in to change notification settings - Fork 15
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
Filenames with plus signs #11
Comments
Another idea: use raw identifiers for the test names. EDIT: Sadly that wouldn't work. I am thinking a inverted regex matching the opposite of https://doc.rust-lang.org/reference/identifiers.html character classes might be the exhaustive solution. |
This is simple to implement: // Form canonical name without any punctuation/delimiter or special character
fn canonical_fn_name(s: &str) -> String {
// remove delimiters and special characters
- s.replace(
- &['"', ' ', '.', ':', '-', '*', '/', '\\', '\n', '\t', '\r'][..],
- "_",
- )
+ // essentially `s/[^A-Za-z0-9]/_//`, see https://doc.rust-lang.org/reference/identifiers.html
+ // we probably cannot dedup multiple subsequent '_' as there is a chance of collision here as
+ // well.
+
+ s.chars()
+ .map(|ch| if ch.is_ascii_alphanumeric() { ch } else { '_' })
+ .collect()
} Trying it out will however manifest another issue: many files are mapped to same fn names. The current code needs to perform PathBuf -> String conversion in order to do the path to fn name mangling, and I am not sure if this is cross platform: test-generator/test-generator/src/lib.rs Lines 251 to 255 in ce45b1a
If it was or could be made as such, creating a mapping from I did not yet look but from the subjects I'd assume that this work would conflict with the open PRs by @svenfoo, so perhaps I'll revisit this later. |
Expected: example filenames with
+
to work.Actual:
test_generator::test_resources
panicked with message:"some_fn_name" is not a valid identifier
Looks like the issue is at
test-generator/test-generator/src/lib.rs
Lines 131 to 138 in ce45b1a
_
. Might be that there are so many caveats that #5 is the way to go when defaults fail to work? Though in this case I'd just re-create the name mangling with this additional character, so not sure how good overall solution that'd be.The text was updated successfully, but these errors were encountered: