diff options
author | Salvatore Bonaccorso <carnil@debian.org> | 2018-08-06 11:09:58 +0200 |
---|---|---|
committer | Salvatore Bonaccorso <carnil@debian.org> | 2018-08-06 11:09:58 +0200 |
commit | 1c430a92837eb5ba044910d01203eef67b15138c (patch) | |
tree | 61952b837dc8fc91425ab13617e50f1371d88844 /t | |
parent | 852b9f26c719478b8bb2f345e75c3b96a71349ca (diff) | |
parent | f506640efab2ce086c797c23c44dedb1489efe08 (diff) |
New upstream version 0.29
Diffstat (limited to 't')
-rw-r--r-- | t/000-report-versions-tiny.t | 77 | ||||
-rw-r--r-- | t/11mimeinfo.t | 29 |
2 files changed, 106 insertions, 0 deletions
diff --git a/t/000-report-versions-tiny.t b/t/000-report-versions-tiny.t new file mode 100644 index 0000000..12a836a --- /dev/null +++ b/t/000-report-versions-tiny.t @@ -0,0 +1,77 @@ +use strict; +use warnings; +use Test::More 0.88; +# This is a relatively nice way to avoid Test::NoWarnings breaking our +# expectations by adding extra tests, without using no_plan. It also helps +# avoid any other test module that feels introducing random tests, or even +# test plans, is a nice idea. +our $success = 0; +END { $success && done_testing; } + +# List our own version used to generate this +my $v = "\nGenerated by Dist::Zilla::Plugin::ReportVersions::Tiny v1.10\n"; + +eval { # no excuses! + # report our Perl details + my $want = '5.006001'; + $v .= "perl: $] (wanted $want) on $^O from $^X\n\n"; +}; +defined($@) and diag("$@"); + +# Now, our module version dependencies: +sub pmver { + my ($module, $wanted) = @_; + $wanted = " (want $wanted)"; + my $pmver; + eval "require $module;"; + if ($@) { + if ($@ =~ m/Can't locate .* in \@INC/) { + $pmver = 'module not found.'; + } else { + diag("${module}: $@"); + $pmver = 'died during require.'; + } + } else { + my $version; + eval { $version = $module->VERSION; }; + if ($@) { + diag("${module}: $@"); + $pmver = 'died during VERSION check.'; + } elsif (defined $version) { + $pmver = "$version"; + } else { + $pmver = '<undef>'; + } + } + + # So, we should be good, right? + return sprintf('%-45s => %-10s%-15s%s', $module, $pmver, $wanted, "\n"); +} + +eval { $v .= pmver('Carp','any version') }; +eval { $v .= pmver('Exporter','any version') }; +eval { $v .= pmver('Fcntl','any version') }; +eval { $v .= pmver('Pod::Usage','any version') }; +eval { $v .= pmver('File::Spec','0.03') }; +eval { $v .= pmver('File::DesktopEntry','0.04') }; +eval { $v .= pmver('Test::More','0.88') }; +eval { $v .= pmver('Path::Tiny','any version') }; + + +# All done. +$v .= <<'EOT'; + +Thanks for using my code. I hope it works for you. +If not, please try and include this output in the bug report. +That will help me reproduce the issue and solve your problem. + +EOT + +diag($v); +ok(1, "we really didn't test anything, just reporting data"); +$success = 1; + +# Work around another nasty module on CPAN. :/ +no warnings 'once'; +$Template::Test::NO_FLUSH = 1; +exit 0; diff --git a/t/11mimeinfo.t b/t/11mimeinfo.t new file mode 100644 index 0000000..f8b4c98 --- /dev/null +++ b/t/11mimeinfo.t @@ -0,0 +1,29 @@ +use strict; +use warnings; + +use Test::More; + +use File::Spec; +use FindBin qw($Bin); + +eval "use IO::Scalar"; +my $have_io_scalar = !$@; + +my $mimetype_file = File::Spec->catfile($Bin, '..', 'mimetype'); + +my %tests = ( + 'mimeopen', 'application/x-perl', + 't/test.png', 'image/png', +); + +for my $test (sort keys %tests) { + my $result = $tests{$test}; + is(`$^X $mimetype_file --noalign $test`, "$test: $result\n", $test); + SKIP: { + skip "Skip stdin test because no IO::Scalar", 1 if !$have_io_scalar; + is(`$^X $mimetype_file --noalign --stdin < $test`, "STDIN: $result\n", + "$test (stdin)"); + }; +} + +done_testing; |