Skip to content
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

Multiple paths-to-mutate,exclude or test are not correctly parsed #254

Open
gregori opened this issue Aug 5, 2022 · 7 comments
Open

Multiple paths-to-mutate,exclude or test are not correctly parsed #254

gregori opened this issue Aug 5, 2022 · 7 comments

Comments

@gregori
Copy link

gregori commented Aug 5, 2022

If you pass multiple paths to any of the path switches, they're not correctly parsed if the pathname contains a "/".

i.e.: --paths-to-mutate app/model,app/service,app/controller

I've checked the code and the problem relies on the get_pattern method. It can simply be solved by changing the regex there:

def get_pattern(char):
        return re.compile(rf"^([\w\/]+)({char}\s*[\w\/]+)*$")
@boxed
Copy link
Owner

boxed commented Aug 6, 2022

Looks like you're on unix. The correct separator for paths is : in unix.

@gregori
Copy link
Author

gregori commented Aug 6, 2022

In fact it doesn't work, neither with ":" nor ",". The problem is the matching RE pattern.

\w means [a-zA-Z0-9_], but if you pass a filename with any directories, it won't work.
i.e: app/package or in windows app\package

now that you mention, my suggestion for that pattern build must also include \. Maybe we should use:

def get_pattern(char):
    return re.compile(rf"^(\w\/\\]+)({char}\s*[\w\/\\]+)*$")

@boxed
Copy link
Owner

boxed commented Aug 22, 2022

Hmm. yea ok. I guess the split should include both / and \ on windows, but only \ on unix? Ugh.

@DanJBower
Copy link

@gregori @boxed I'm confused, where is get_pattern defined? I tried using --paths-to-mutate on Windows but it only seems to accept 1 path and not multiple. If more than one is provided it raises an error saying it is either expecting a file path or an integer

@boxed
Copy link
Owner

boxed commented Sep 10, 2022

@DanJBower yea, this issue is saying that paths-to-mutate doesn't work for multiple paths.

@DanJBower
Copy link

Ah okay, thanks for clarifying

When I read it yesterday, I thought it was unix specific

@dversoza
Copy link

I just added a PR to explain better how the paths-to-mutate attribute works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants