Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

fix for dbic-migration help command + test #1

Merged
merged 3 commits into from

2 participants

@felliott

Hello,

On my system dbic-migration help doesn't produce any output. I think this is because pod2usage doesn't know which module to pull the pod from. According to the Pod::Usage docs, this can be fixed by passing the -input arg to pod2usage. I've added this and it works on my system. I've also added a test to make sure it produces the correct output. I've split this into 3 commits:

1.) HEAD^^ fixes the bug using Pod::Find per the Pod::usage docs

2.) HEAD^ adds Pod::Find to the prereqs in dist.ini. Pod::Find is in the same dist as Pod::Usage, and I wasn't sure if you liked explicit dependencies or not.

3.) HEAD adds a new test script, t/script.t, that checks the output of the help command. One caveat: since pod2usage calls exit(), I had to add a dependency on Test::Trap in order to capture the output. Test::Trap currently has failing tests on my system, though they're minor (in comparing error messages, a trailing period was missed). I could put it in a SKIP block, if you'd prefer.

Cheers,
Fitz

@jjn1056 jjn1056 merged commit 137de5a into from
@jjn1056
Owner

BTW, I'll poke around Test::Trap a bit and see if I can find someone to fix this

@felliott

Thank you! I submitted a bug report + patch to RT: https://rt.cpan.org/Public/Bug/Display.html?id=75430

Cheers,
Fitz

@jjn1056
Owner

Hey,

just FYI this in on the way to cpan, along with yet another fix for a failing test case (unrelated to you patch). I decided to make the help test option and run only if Test::Trap is already installed. I will consider that an author side test for now, until trap trap stabilizes a bit more. Thanks for the patch and more help me make this dist better and easier to use.

Johnn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 24 additions and 2 deletions.
  1. +2 −1  dist.ini
  2. +5 −1 lib/DBIx/Class/Migration/Script.pm
  3. +17 −0 t/script.t
View
3  dist.ini
@@ -26,6 +26,7 @@ File::ShareDir::ProjectDistDir = 0
MooseX::Attribute::ENV = 0
Devel::PartialDump = 0
DBD::SQLite = 0
+Pod::Find = 0
Pod::Usage = 0
Config::Tiny = 0
@@ -34,4 +35,4 @@ Test::Most = 0
File::Spec::Functions = 0
File::Path = 0
Test::Requires = 0
-
+Test::Trap = 0
View
6 lib/DBIx/Class/Migration/Script.pm
@@ -3,6 +3,7 @@ package DBIx::Class::Migration::Script;
use Moose;
use MooseX::Attribute::ENV;
use MooseX::Types::LoadableClass 'LoadableClass';
+use Pod::Find ();
use Pod::Usage ();
with 'MooseX::Getopt';
@@ -152,7 +153,10 @@ sub cmd_help {
if($subhelp) {
die "detailed help not yet available";
} else {
- Pod::Usage::pod2usage(-sections=>['COMMANDS'],-verbose=>99);
+ Pod::Usage::pod2usage(
+ -sections=>['COMMANDS'],-verbose=>99,
+ -input => Pod::Find::pod_where({-inc => 1}, __PACKAGE__)
+ );
}
}
View
17 t/script.t
@@ -0,0 +1,17 @@
+#!/usr/bin/env perl
+
+use lib 't/lib';
+use Test::Most;
+use Test::Trap qw(trap $trap);
+use DBIx::Class::Migration::Script;
+
+sub run_cli {
+ DBIx::Class::Migration::Script->run_with_options(@_);
+}
+
+my @r = trap { run_cli(argv =>["help"]); };
+like $trap->stdout,
+ qr/^Commands:.*^\s+help:.*^\s+version:.*^\s+status:/sm,
+ 'help command produces output';
+
+done_testing;
Something went wrong with that request. Please try again.