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

:TestFiles returns all files under the t/ directory, not only *.t files run by prove #407

Closed
choroba opened this issue Jan 11, 2015 · 6 comments

Comments

@choroba
Copy link

choroba commented Jan 11, 2015

This leads e.g. to a release test error for Net::HTTP::Spore which contains t/specs/content.tgz - but it makes no sense to test a binary file for tabs.

@choroba
Copy link
Author

choroba commented Jan 11, 2015

See _setup_default_plugins in Dist::Zilla::Dist::Builder:

sub { local $_ = $_->name; m{\At/} }

Should probably rather be

sub { local $_ = $_->name; m{\At/.*\.t\Z} }

@choroba choroba changed the title :TestFiles returns all files under the t/ directory, not only *.t files run by prove :TestFiles returns all files under the t/ directory, not only *.t files run by prove Jan 11, 2015
@karenetheridge
Copy link
Contributor

We actually do want :TestFiles to return all t/ files - e.g. AutoPrereqs uses this to find all test prereqs.

To mark a file as binary/unscannable by plugins, set its encoding to 'bytes' in dist.ini -- see the docs for Dist::Zilla::Plugin::Encoding.

@choroba
Copy link
Author

choroba commented Jan 11, 2015

Ah, thanks. What about TSV files or shell scripts with <<-HERE documents? Is bytes still appropriate, or should one rather use a custom file gatherer?

Moreover, Net::HTTP::Spore already mentions the file:

[Encoding]
encoding = bytes
filename = t/specs/content.tgz

But the test still fails:

t/author-no-tabs.t ................... 1/? 
#   Failed test 'No tabs in 't/specs/content.tgz' on line 1'
#   at t/author-no-tabs.t line 87.

@karenetheridge
Copy link
Contributor

Ah, thanks. What about TSV files or shell scripts with <<-HERE documents? Is bytes still appropriate, or should one rather use a custom file gatherer?

It all depends on what you want to achieve. Some things may still want to look at files in t/ that aren't perl code.

But the (no tabs) test still fails:

Then you're in the wrong issue queue. But never fear, the maintainer has just uploaded a fix: https://metacpan.org/release/Dist-Zilla-Plugin-Test-NoTabs

@choroba
Copy link
Author

choroba commented Jan 12, 2015

Thanks :-)

@choroba choroba closed this as completed Jan 12, 2015
@dolmen
Copy link
Contributor

dolmen commented Jan 15, 2015

@choroba For the specific case of Net::HTTP::Spore, another solution would be to use a custom finder.
DZP::Test::NoTabs uses the FileFinderUser role, so you can override from dist.ini the default finders list that contains [ ':InstallModules', ':ExecFiles', ':TestFiles' ].

You could try something like that in the dist.ini:

; Build a finder that inherits from :TestFiles but keeps only *.t
[FileFinder::Filter / TestCodeFiles]
finder = :TestFiles
skip = [^.][^t]$

[NoTabs]
finder = :InstallModules
finder = :ExecFiles
; see above
finder = TestCodeFiles

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

3 participants