-
Notifications
You must be signed in to change notification settings - Fork 24
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
Unexpected behavior from has_dirname() criterion #44
Comments
Thanks for the detailed description. I think I confused |
Scratch that, I now better understand the problem. PR coming. |
- The `is_dirname()` criterion no longer considers sibling directories (#44).
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary. |
I am getting unexpected behavior from
has_dirname
as a criterion:Reproducible example
Consider this reprex:
Created on 2019-12-26 by the reprex package (v0.3.0)
Expected behavior
The documentation says:
This makes it sound as though the function is checking whether the parent node of the candidate path (
base::dirname(path)
) has a given name.On the other hand,
get_root_desc()
says that./tmp/foo
is a root because "directory name isboohoo
", which makes it sound like the criterion is that the leaf node of the candidate path (base::basename(path)
) has a given name.The documentation and the output from
get_root_desc
are confusing and seem inconsistent with each other.But in either case, based on the documentation and the output from
get_root_desc
, I would expectfind_root(crit, "tmp/foo/bar")
to fail with an error message whencrit
ishas_dirname("boohoo")
and forcrit.testfun[1]("tmp/foo")
to returnFALSE
.Actual behavior
However, the criterion really checks whether the parent node has a child with the given name.
This means that a directory can fulfill the criterion if it has a sibling with the specified name, as in the example above:
tmp/foo
andtmp/boohoo
are siblings, andtmp/foo
satisfies thehas_dirname("boohoo")
criterion andfind_root(has_dirname("boohoo"), "tmp/foo/bar")
succeeds and returnstmp/foo
instead of failing, as I would expect, andhas_dirname("boohoo").testfun[1]("tmp/foo")
returnsTRUE
instead of the expectedFALSE
Possible remedies:
Update Documentation for
has_dirname()
If this is the desired behavior, then it would be good to make the documentation clearer, and perhaps provide an example to illustrate the behavior.
Change behavior of
has_dirname()
If it is not the desired behavior, then changing the testfun from
to something like
With this latter function,
tmp/foo/bar
would satisfyhas_dirname("foo")
andtmp/foo
andtmp/boohoo
would both satisfyhas_dirname("tmp")
, buttmp/foo
would not satisfyhas_dirname("boohoo")
andtmp/boohoo
would not satisfyhas_dirname("foo")
.Alternately (another possible interpretation of the intended behavior) would be
In this case,
tmp/foo
would satisfyhas_dirname("foo")
andtmp/boohoo
would satisfyhas_dirname("boohoo")
, buttmp/foo
would not satisfyhas_dirname("boohoo")
.Session Info
The text was updated successfully, but these errors were encountered: