File: Compile.pm

package info (click to toggle)
libur-perl 0.470%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 7,184 kB
  • sloc: perl: 61,813; javascript: 255; xml: 108; sh: 13; makefile: 9
file content (54 lines) | stat: -rw-r--r-- 1,243 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54

package UR::Namespace::Command::Test::Compile;

use strict;
use warnings;
use UR;
our $VERSION = "0.47"; # UR $VERSION;

UR::Object::Type->define(
    class_name => __PACKAGE__,
    is => "UR::Namespace::Command::RunsOnModulesInTree",
);

sub help_brief {
    "Attempts to compile each module in the namespace in its own process."
}

sub help_synopsis {
    return <<EOS
ur test complie

ur test compile Some::Module Some::Other::Module

ur test complile Some/Module.pm Some/Other/Mod*.pm
EOS
}

sub help_detail {
    return <<EOS
This command runs "perl -c" on each module in a separate process and aggregates results.
Running with --verbose will list specific modules instead of just a summary.

Try "ur test use" for a faster evaluation of whether your software tree is broken. :)
EOS
}

sub for_each_module_file {
    my $self = shift;
    my $module_file = shift;
    my $lib_path = $self->lib_path;
    my @response = `cd $lib_path; perl -I $lib_path -c $module_file 2>&1`;
    if (grep { $_ eq "$module_file syntax OK\n" } @response) {
        print "$module_file syntax OK\n"
    }
    else {
        chomp @response;
        print "$module_file syntax FAILED\n"
            . join("\n\t",@response), "\n";
    }
    return 1;
}

1;