« blib/lib/UR/Namespace/Command/Test/Callcount/List.pm
↑ Summary
blib/lib/UR/Namespace/Command/Test/Eval.pm »
| 1 | |||
| 2 | package UR::Namespace::Command::Test::Compile; | ||
| 3 | |||
| 4 | use strict; | ||
| 5 | use warnings; | ||
| 6 | use UR; | ||
| 7 | our $VERSION = "0.46"; # UR $VERSION; | ||
| 8 | |||
| 9 | UR::Object::Type->define( | ||
| 10 | class_name => __PACKAGE__, | ||
| 11 | is => "UR::Namespace::Command::RunsOnModulesInTree", | ||
| 12 | ); | ||
| 13 | |||
| 14 | sub help_brief { | ||
| 15 | "Attempts to compile each module in the namespace in its own process." | ||
| 16 | } | ||
| 17 | |||
| 18 | sub help_synopsis { | ||
| 19 | return <<EOS | ||
| 20 | ur test complie | ||
| 21 | |||
| 22 | ur test compile Some::Module Some::Other::Module | ||
| 23 | |||
| 24 | ur test complile Some/Module.pm Some/Other/Mod*.pm | ||
| 25 | EOS | ||
| 26 | } | ||
| 27 | |||
| 28 | sub help_detail { | ||
| 29 | return <<EOS | ||
| 30 | This command runs "perl -c" on each module in a separate process and aggregates results. | ||
| 31 | Running with --verbose will list specific modules instead of just a summary. | ||
| 32 | |||
| 33 | Try "ur test use" for a faster evaluation of whether your software tree is broken. :) | ||
| 34 | EOS | ||
| 35 | } | ||
| 36 | |||
| 37 | sub for_each_module_file { | ||
| 38 | my $self = shift; | ||
| 39 | my $module_file = shift; | ||
| 40 | my $lib_path = $self->lib_path; | ||
| 41 | my @response = `cd $lib_path; perl -I $lib_path -c $module_file 2>&1`; | ||
| 42 | if (grep { $_ eq "$module_file syntax OK\n" } @response) { | ||
| 43 | print "$module_file syntax OK\n" | ||
| 44 | } | ||
| 45 | else { | ||
| 46 | chomp @response; | ||
| 47 | print "$module_file syntax FAILED\n" | ||
| 48 | . join("\n\t",@response), "\n"; | ||
| 49 | } | ||
| 50 | return 1; | ||
| 51 | } | ||
| 52 | |||
| 53 | 1; | ||
| 54 |