From 3ca192cd4f8f2613cbd44270e0275a5ca05a2ff1 Mon Sep 17 00:00:00 2001 From: Graham Ollis Date: Sat, 28 Sep 2013 12:36:00 -0400 Subject: [PATCH] new diagnostic --- t/{01-ioloop.t => 00_diag.pl} | 8 +++--- t/00_diag.t | 51 +++++++++++++++++++++++++++++++++++ t/00_diag.txt | 24 +++++++++++++++++ t/{00-load.t => 00_load.t} | 0 4 files changed, 80 insertions(+), 3 deletions(-) rename t/{01-ioloop.t => 00_diag.pl} (54%) create mode 100644 t/00_diag.t create mode 100644 t/00_diag.txt rename t/{00-load.t => 00_load.t} (100%) diff --git a/t/01-ioloop.t b/t/00_diag.pl similarity index 54% rename from t/01-ioloop.t rename to t/00_diag.pl index 46aac73..6b9b235 100644 --- a/t/01-ioloop.t +++ b/t/00_diag.pl @@ -1,11 +1,13 @@ use strict; use warnings; -use Test::More tests => 1; +use Test::More; use Mojo::IOLoop; +our $format; + my $loop = eval { Mojo::IOLoop->singleton }; diag $@ if $@; -ok $loop; -diag ref eval { $loop->reactor }; +diag sprintf $format, 'mojo io loop', ref eval { $loop->reactor }; diag $@ if $@; +1; diff --git a/t/00_diag.t b/t/00_diag.t new file mode 100644 index 0000000..7bc41a5 --- /dev/null +++ b/t/00_diag.t @@ -0,0 +1,51 @@ +use strict; +use warnings; +use Test::More tests => 1; +BEGIN { eval q{ use EV } } +eval q{ + use FindBin (); + use File::Spec; + 1; +} || die $@; + +pass 'okay'; + +my @modules; +do { + my $fh; + open($fh, '<', File::Spec->catfile($FindBin::Bin, '00_diag.txt')); + @modules = <$fh>; + close $fh; + chomp @modules; +}; + +my $max = 1; +$max = $_ > $max ? $_ : $max for map { length $_ } @modules; +our $format = "%-${max}s %s"; + +diag ''; +diag ''; +diag ''; + +diag sprintf $format, 'perl ', $^V; + +require(File::Spec->catfile($FindBin::Bin, '00_diag.pl')) + if -e File::Spec->catfile($FindBin::Bin, '00_diag.pl'); + +foreach my $module (@modules) +{ + if(eval qq{ use $module; 1 }) + { + my $ver = eval qq{ \$$module\::VERSION }; + $ver = 'undef' unless defined $ver; + diag sprintf $format, $module, $ver; + } + else + { + diag sprintf $format, $module, '-'; + } +} + +diag ''; +diag ''; +diag ''; diff --git a/t/00_diag.txt b/t/00_diag.txt new file mode 100644 index 0000000..f8ceaec --- /dev/null +++ b/t/00_diag.txt @@ -0,0 +1,24 @@ +Carp +Cwd +EV +ExtUtils::MakeMaker +File::Spec +File::Temp +FindBin +IO::Handle +IPC::Open3 +Mojo::Base +Mojo::ByteStream +Mojo::IOLoop +Mojolicious +Mojolicious::Lite +Mojolicious::Plugin +POSIX +Scalar::Util +Template +Template::Provider +Test::CPAN::Meta +Test::Mojo +Test::More +lib +utf8 diff --git a/t/00-load.t b/t/00_load.t similarity index 100% rename from t/00-load.t rename to t/00_load.t