| 1 | package P5U::Command::AutoProve; | ||
| 2 | |||
| 3 | use 5.010; | ||
| 4 | use strict; | ||
| 5 | use utf8; | ||
| 6 | use P5U-command; | ||
| 7 | |||
| 8 | BEGIN { | ||
| 9 | $P5U::Command::AutoProve::AUTHORITY = 'cpan:TOBYINK'; | ||
| 10 | $P5U::Command::AutoProve::VERSION = '0.100'; | ||
| 11 | }; | ||
| 12 | |||
| 13 | use Cwd 'cwd'; | ||
| 14 | |||
| 15 | use constant { | ||
| 16 | abstract => q[automatically find the most likely test suite, and run it], | ||
| 17 | usage_desc => q[%c auto-prove %o], | ||
| 18 | }; | ||
| 19 | |||
| 20 | sub command_names | ||
| 21 | { | ||
| 22 | qw( | ||
| 23 | auto-prove | ||
| 24 | ap | ||
| 25 | ); | ||
| 26 | } | ||
| 27 | |||
| 28 | sub description | ||
| 29 | { | ||
| 30 | <<'DESCRIPTION' | ||
| 31 | The auto-prove command climbs up your directory hierarchy, looking for a | ||
| 32 | directory which has a subdirectory called "t". It then performs a chdir to | ||
| 33 | that directory, runs "prove" with the most likely options and does a chdir | ||
| 34 | back to where you started. | ||
| 35 | |||
| 36 | In short, if you're in a terminal working in some deeply nested directory | ||
| 37 | containing code files, you don't need to play the "guess how many | ||
| 38 | dot-dot-slashes game". Just type "p5u ap". | ||
| 39 | |||
| 40 | You can additionally run author tests using "p5u ap --xt". | ||
| 41 | DESCRIPTION | ||
| 42 | } | ||
| 43 | |||
| 44 | sub opt_spec | ||
| 45 | { | ||
| 46 | require P5U::Lib::AutoProve; | ||
| 47 | return ( | ||
| 48 | [ xt => 'run "xt" tests too' ], | ||
| 49 | map { [ $_ => 'passed through to "prove"' ] } P5U::Lib::AutoProve->opts | ||
| 50 | ); | ||
| 51 | } | ||
| 52 | |||
| 53 | sub execute | ||
| 54 | { | ||
| 55 | require P5U::Lib::AutoProve; | ||
| 56 | my ($self, $opt, $args) = @_; | ||
| 57 | $self->usage_error("This command takes no non-option arguments.") | ||
| 58 | if @$args; | ||
| 59 | my ($wd, $app) = P5U::Lib::AutoProve::->get_app(%$opt); | ||
| 60 | my $orig = cwd; | ||
| 61 | |||
| 62 | chdir $wd; | ||
| 63 | $app->run; | ||
| 64 | chdir $orig; | ||
| 65 | } | ||
| 66 | |||
| 67 | 1; |