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

weaken type constraint of "directory" attribute #69

Merged
merged 3 commits into from
Feb 17, 2024

Conversation

XSven
Copy link
Contributor

@XSven XSven commented Feb 15, 2024

This should fix the issue #68. For all the classes that have a directory attribute the isa type constraint was changed from Str (belonging to Types::Standard) to Path (belong to Types::Path::Tiny) and coercion was enabled.

@oalders
Copy link
Collaborator

oalders commented Feb 15, 2024

Could we add a regression test?

@XSven
Copy link
Contributor Author

XSven commented Feb 15, 2024

It is not entirely clear to me what you are looking for. Im usually not testing how a class is declared that means in the current case how the isa properties of the attributes are set. What we could do is we could adjust existing tests like for example t/03_inject.t in a way that once we are calling the OrePAN2::Indexer constructor with a Str directory and a second time we are calling the OrePAN2::Indexer constructor with a Path (Path::Tiny) directory. Does this meet your expectation?

@oalders
Copy link
Collaborator

oalders commented Feb 15, 2024

Yes, that's exactly it. 😄

@XSven
Copy link
Contributor Author

XSven commented Feb 15, 2024

Ok this is the first thing I will work on tomorrow morning (Hamburg time).

@oalders
Copy link
Collaborator

oalders commented Feb 15, 2024

Alles klar!

@XSven
Copy link
Contributor Author

XSven commented Feb 16, 2024

The constructor of the class OrePAN2::Repository::Cache wasn't tested explicitly: There is an implicit test because the test code coverage report shows that OrePAN2::Repository::_build_cache() is called and $self->directory from now on returns a Path::Tiny object due to coercion.

The behaviour of the directory() getter method is the only thing that is no longer backwards compatible: Coercion weakens the type constraint on the input side but what you get back is all the time a Path::Tiny object.

@oalders
Copy link
Collaborator

oalders commented Feb 16, 2024

The behaviour of the directory() getter method is the only thing that is no longer backwards compatible: Coercion weakens the type constraint on the input side but what you get back is all the time a Path::Tiny object.

We don't anticipate anything breaking with end users, though?

@XSven
Copy link
Contributor Author

XSven commented Feb 17, 2024

No we don't, although we were already tricked by the fact that Path::Tiny objects were used as values for the directory attribute. From what I know now this is a problem with improper implemenetation encapsulation: The File::Spec::catfile() class method that is used internally by the core OrePAN2 classes, can digest Strings and Path::Tiny objects. I doubt that this design was done on purpose but at least shouldn't have been leaked to the outside.

@oalders oalders merged commit a7e0bda into tokuhirom:master Feb 17, 2024
29 checks passed
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

Successfully merging this pull request may close these issues.

2 participants