-
Notifications
You must be signed in to change notification settings - Fork 104
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
(PDK-1167) Validator should honor case sensitive of the file system #646
Merged
rodjek
merged 3 commits into
puppetlabs:master
from
glennsarti:pdk-1167-case-sensitive-paths
Apr 2, 2019
Merged
(PDK-1167) Validator should honor case sensitive of the file system #646
rodjek
merged 3 commits into
puppetlabs:master
from
glennsarti:pdk-1167-case-sensitive-paths
Apr 2, 2019
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
glennsarti
changed the title
(PDK-1167) Validator should honor case sensitive of the file system
{WIP}(PDK-1167) Validator should honor case sensitive of the file system
Apr 2, 2019
Previously the validator expected that any targets passed into the parse_targets method were always case sensitive due to the way File.fnmatch matches file names and paths. Due to the glob based searching, any paths returned from the method will always represent what's on disk, as opposed to the originating target path. This commit updates the File.fnmatch method to instead base the matching on the canonical directory name (from PDK::Util.canonical_path) which converts case insensitive targets into their actual on-disk name. This commit also adds a test for this scenario.
glennsarti
force-pushed
the
pdk-1167-case-sensitive-paths
branch
from
April 2, 2019 03:06
ec04a0a
to
af49b2a
Compare
Previously the testing for the parse_targets method was being performed in multiple places for no added test coverage. Also in order to test this method required pervasive mocking of the file system which had many side effects. This commit refactors the parse_targets testing: * Any actual File and Dir methods used in parse_targets was refactored to the PDK::Util::FileSystem module, in order to make mocking less intrusive. In particular the mocking of .file?, .directory? and .glob? made it impossible to debug tests because tools like pry use these methods. Without this refactor it was impossible to debug tests. Note that "readonly" operations like File.join were not refactored as they are not mocked in tests and do not actually touch the host operating system, unlike glob, and file? etc. * The tests for vase_validator were modified to mock the PDK:Util:FileSystem module, not the actual File and Dir classes. * The puppet_syntax_spec.rb file used to test the .parse_targets method however this was unnecssary. The test for the .pattern_ignore property were moved from puppet_syntax_spec.rb into base_validator_spec.rb as this is what was _actually_ being tested. puppet_syntax_spec.rb now just ensures that the pattern_ignore method is set correctly * Both the it_accepts_metadata_json_targets and it_accepts_pp_targets helper files were testing functionality that was already being tested in the base_validator_spec.rb (Namely filtering on pattern). In this case the duplicate test is removed and instead we test that the pattern property is as we expect. * Superfluous mocking of the File class was removed from any tests. * Fixed a minor typo in the pattern for the puppet_syntax validator whereby the pattern should be '**/*.pp' * All of the File and Dir mocking was removed from the name_spec.rb test file and instead we just mock the return from the parse_targets method of the base validator. The duplicate testing of the parse_targets method we not required and actually reflects what the test is testing for.
Previously many of the validate spec tests were created, or moved, so that the directory structure mimiced that of lib. However some files were not. This commit moves the remaining validation files so that spec mimics lib.
glennsarti
force-pushed
the
pdk-1167-case-sensitive-paths
branch
from
April 2, 2019 03:15
af49b2a
to
9f33c38
Compare
glennsarti
changed the title
{WIP}(PDK-1167) Validator should honor case sensitive of the file system
(PDK-1167) Validator should honor case sensitive of the file system
Apr 2, 2019
rodjek
approved these changes
Apr 2, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Blocked on fb12b97 being merged
Previously the validator expected that any targets passed into the parse_targets
method were always case sensitive due to the way File.fnmatch matches file
names and paths. Due to the glob based searching, any paths returned from the
method will always represent what's on disk, as opposed to the originating
target path.
This commit updates the File.fnmatch method to instead base the matching on the
canonical directory name (from PDK::Util.canonical_path) which converts
case insensitive targets into their actual on-disk name.
This commit also adds a test for this scenario.
Previously the testing for the parse_targets method was being performed in
multiple places for no added test coverage. Also in order to test this method
required pervasive mocking of the file system which had many side effects. This
commit refactors the parse_targets testing:
Any actual File and Dir methods used in parse_targets was refactored to the
PDK::Util::FileSystem module, in order to make mocking less intrusive. In
particular the mocking of .file?, .directory? and .glob? made it impossible
to debug tests because tools like pry use these methods. Without this refactor
it was impossible to debug tests.
Note that "readonly" operations like File.join were not refactored as they are
not mocked in tests and do not actually touch the host operating system,
unlike glob, and file? etc.
The tests for vase_validator were modified to mock the PDK:Util:FileSystem
module, not the actual File and Dir classes.
The puppet_syntax_spec.rb file used to test the .parse_targets method however
this was unnecssary. The test for the .pattern_ignore property were moved
from puppet_syntax_spec.rb into base_validator_spec.rb as this is what was
actually being tested. puppet_syntax_spec.rb now just ensures that the
pattern_ignore method is set correctly
Both the it_accepts_metadata_json_targets and it_accepts_pp_targets helper
files were testing functionality that was already being tested in the
base_validator_spec.rb (Namely filtering on pattern). In this case the
duplicate test is removed and instead we test that the pattern property is as
we expect.
Superfluous mocking of the File class was removed from any tests.
Fixed a minor typo in the pattern for the puppet_syntax validator whereby the
pattern should be '**/*.pp'
All of the File and Dir mocking was removed from the name_spec.rb test file
and instead we just mock the return from the parse_targets method of the base
validator. The duplicate testing of the parse_targets method we not required
and actually reflects what the test is testing for.