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

Fix has_sources. #4792

Merged

Conversation

jsirois
Copy link
Contributor

@jsirois jsirois commented Aug 8, 2017

Previously the default implementation failed to handle an extension of None
even though it accepted the argument first class. This is fixed with test
coverage added and Resources is fixed to delegate to the fixed implementation
after performing its special check.

@jsirois
Copy link
Contributor Author

jsirois commented Aug 8, 2017

Came across this working #4780

@jsirois jsirois requested a review from baroquebobcat August 8, 2017 15:51
@jsirois jsirois force-pushed the jsirois/issues/4780-fix-resources branch from 65d1463 to 2c9550a Compare August 8, 2017 16:06
Copy link
Member

@stuhood stuhood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks John... one potential change.

return self._ref_address

def has_sources(self, extension=None):
if not self.source_paths:
return False
if not extension:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm... "True if no extension" is an odd case. AFAICT, this method is only used in Target... would probably be good to inline the logic there so that it is more obvious that it is completely overridden by Resources. Would that also make this check unnecessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic is actually if source_paths and not extension; ie at least 1 source and extension doesn't matter - so not so odd? Agreed its hard to read, but it is now tested at least.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, but the inlining makes sense maybe, I'll look at that...

jsirois added 2 commits August 8, 2017 13:18
Previously the default implementation failed to handle an extension of None
even though it accepted the argument first class. This is fixed with test
coverage added and Resources is fixed to delegate to the fixed implementation
after performing its special check.
@jsirois jsirois force-pushed the jsirois/issues/4780-fix-resources branch from 2c9550a to d1970e1 Compare August 8, 2017 19:18
Resources,
sources=Globs.create_fileset_with_spec('resources', '*.rs'))
self.assertFalse(no_resources.has_sources())
self.assertFalse(no_resources.has_sources('*.java'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confused about the *.java here. Shouldn't it be just .java

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, fixed.

Resources,
sources=Globs.create_fileset_with_spec('resources', '*.java'))
self.assertTrue(resources.has_sources())
self.assertFalse(resources.has_sources('*.java'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same Q.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@jsirois jsirois merged commit 40428ed into pantsbuild:master Aug 8, 2017
@jsirois jsirois deleted the jsirois/issues/4780-fix-resources branch August 8, 2017 21:51
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.

3 participants